diff mbox series

[10/13] jfs: Convert inc_io and mp_anchor to take a folio

Message ID 20240201224605.4055895-11-willy@infradead.org (mailing list archive)
State New, archived
Headers show
Series JFS folio conversion | expand

Commit Message

Matthew Wilcox Feb. 1, 2024, 10:45 p.m. UTC
All their callers now have a folio, so pass it in.  No savings here,
just cleaning up some remnants.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/jfs/jfs_metapage.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

Comments

kernel test robot Feb. 3, 2024, 1:53 a.m. UTC | #1
Hi Matthew,

kernel test robot noticed the following build errors:

[auto build test ERROR on kleikamp-shaggy/jfs-next]
[also build test ERROR on linus/master v6.8-rc2 next-20240202]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Matthew-Wilcox-Oracle/jfs-Convert-metapage_read_folio-to-use-folio-APIs/20240202-064805
base:   https://github.com/kleikamp/linux-shaggy jfs-next
patch link:    https://lore.kernel.org/r/20240201224605.4055895-11-willy%40infradead.org
patch subject: [PATCH 10/13] jfs: Convert inc_io and mp_anchor to take a folio
config: loongarch-defconfig (https://download.01.org/0day-ci/archive/20240203/202402030956.qthlo2BE-lkp@intel.com/config)
compiler: loongarch64-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240203/202402030956.qthlo2BE-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202402030956.qthlo2BE-lkp@intel.com/

All error/warnings (new ones prefixed by >>):

   fs/jfs/jfs_metapage.c: In function 'remove_metapage':
   fs/jfs/jfs_metapage.c:130:38: error: passing argument 1 of 'folio_detach_private' from incompatible pointer type [-Werror=incompatible-pointer-types]
     130 |                 folio_detach_private(&folio->page);
         |                                      ^~~~~~~~~~~~
         |                                      |
         |                                      struct page *
   In file included from include/linux/buffer_head.h:15,
                    from fs/jfs/jfs_metapage.c:14:
   include/linux/pagemap.h:508:56: note: expected 'struct folio *' but argument is of type 'struct page *'
     508 | static inline void *folio_detach_private(struct folio *folio)
         |                                          ~~~~~~~~~~~~~~^~~~~
   fs/jfs/jfs_metapage.c: In function 'inc_io':
>> fs/jfs/jfs_metapage.c:137:37: warning: dereferencing 'void *' pointer
     137 |         atomic_inc(&mp_anchor(folio)->io_count);
         |                                     ^~
>> fs/jfs/jfs_metapage.c:137:37: error: request for member 'io_count' in something not a structure or union
   cc1: some warnings being treated as errors


vim +/io_count +137 fs/jfs/jfs_metapage.c

  > 14	#include <linux/buffer_head.h>
    15	#include <linux/mempool.h>
    16	#include <linux/seq_file.h>
    17	#include <linux/writeback.h>
    18	#include "jfs_incore.h"
    19	#include "jfs_superblock.h"
    20	#include "jfs_filsys.h"
    21	#include "jfs_metapage.h"
    22	#include "jfs_txnmgr.h"
    23	#include "jfs_debug.h"
    24	
    25	#ifdef CONFIG_JFS_STATISTICS
    26	static struct {
    27		uint	pagealloc;	/* # of page allocations */
    28		uint	pagefree;	/* # of page frees */
    29		uint	lockwait;	/* # of sleeping lock_metapage() calls */
    30	} mpStat;
    31	#endif
    32	
    33	#define metapage_locked(mp) test_bit(META_locked, &(mp)->flag)
    34	#define trylock_metapage(mp) test_and_set_bit_lock(META_locked, &(mp)->flag)
    35	
    36	static inline void unlock_metapage(struct metapage *mp)
    37	{
    38		clear_bit_unlock(META_locked, &mp->flag);
    39		wake_up(&mp->wait);
    40	}
    41	
    42	static inline void __lock_metapage(struct metapage *mp)
    43	{
    44		DECLARE_WAITQUEUE(wait, current);
    45		INCREMENT(mpStat.lockwait);
    46		add_wait_queue_exclusive(&mp->wait, &wait);
    47		do {
    48			set_current_state(TASK_UNINTERRUPTIBLE);
    49			if (metapage_locked(mp)) {
    50				unlock_page(mp->page);
    51				io_schedule();
    52				lock_page(mp->page);
    53			}
    54		} while (trylock_metapage(mp));
    55		__set_current_state(TASK_RUNNING);
    56		remove_wait_queue(&mp->wait, &wait);
    57	}
    58	
    59	/*
    60	 * Must have mp->page locked
    61	 */
    62	static inline void lock_metapage(struct metapage *mp)
    63	{
    64		if (trylock_metapage(mp))
    65			__lock_metapage(mp);
    66	}
    67	
    68	#define METAPOOL_MIN_PAGES 32
    69	static struct kmem_cache *metapage_cache;
    70	static mempool_t *metapage_mempool;
    71	
    72	#define MPS_PER_PAGE (PAGE_SIZE >> L2PSIZE)
    73	
    74	#if MPS_PER_PAGE > 1
    75	
    76	struct meta_anchor {
    77		int mp_count;
    78		atomic_t io_count;
    79		struct metapage *mp[MPS_PER_PAGE];
    80	};
    81	#define mp_anchor(folio) (folio->private)
    82	
    83	static inline struct metapage *folio_to_mp(struct folio *folio, int offset)
    84	{
    85		struct meta_anchor *anchor = folio->private;
    86	
    87		if (!anchor)
    88			return NULL;
    89		return anchor->mp[offset >> L2PSIZE];
    90	}
    91	
    92	static inline int insert_metapage(struct folio *folio, struct metapage *mp)
    93	{
    94		struct meta_anchor *a;
    95		int index;
    96		int l2mp_blocks;	/* log2 blocks per metapage */
    97	
    98		a = folio->private;
    99		if (!a) {
   100			a = kzalloc(sizeof(struct meta_anchor), GFP_NOFS);
   101			if (!a)
   102				return -ENOMEM;
   103			folio_attach_private(folio, a);
   104			kmap(&folio->page);
   105		}
   106	
   107		if (mp) {
   108			l2mp_blocks = L2PSIZE - folio->mapping->host->i_blkbits;
   109			index = (mp->index >> l2mp_blocks) & (MPS_PER_PAGE - 1);
   110			a->mp_count++;
   111			a->mp[index] = mp;
   112		}
   113	
   114		return 0;
   115	}
   116	
   117	static inline void remove_metapage(struct folio *folio, struct metapage *mp)
   118	{
   119		struct meta_anchor *a = mp_anchor(folio);
   120		int l2mp_blocks = L2PSIZE - folio->mapping->host->i_blkbits;
   121		int index;
   122	
   123		index = (mp->index >> l2mp_blocks) & (MPS_PER_PAGE - 1);
   124	
   125		BUG_ON(a->mp[index] != mp);
   126	
   127		a->mp[index] = NULL;
   128		if (--a->mp_count == 0) {
   129			kfree(a);
   130			folio_detach_private(&folio->page);
   131			kunmap(&folio->page);
   132		}
   133	}
   134	
   135	static inline void inc_io(struct folio *folio)
   136	{
 > 137		atomic_inc(&mp_anchor(folio)->io_count);
   138	}
   139
diff mbox series

Patch

diff --git a/fs/jfs/jfs_metapage.c b/fs/jfs/jfs_metapage.c
index 59729b9dd76f..bc62d4bb4712 100644
--- a/fs/jfs/jfs_metapage.c
+++ b/fs/jfs/jfs_metapage.c
@@ -78,7 +78,7 @@  struct meta_anchor {
 	atomic_t io_count;
 	struct metapage *mp[MPS_PER_PAGE];
 };
-#define mp_anchor(page) ((struct meta_anchor *)page_private(page))
+#define mp_anchor(folio) (folio->private)
 
 static inline struct metapage *folio_to_mp(struct folio *folio, int offset)
 {
@@ -116,7 +116,7 @@  static inline int insert_metapage(struct folio *folio, struct metapage *mp)
 
 static inline void remove_metapage(struct folio *folio, struct metapage *mp)
 {
-	struct meta_anchor *a = mp_anchor(&folio->page);
+	struct meta_anchor *a = mp_anchor(folio);
 	int l2mp_blocks = L2PSIZE - folio->mapping->host->i_blkbits;
 	int index;
 
@@ -132,9 +132,9 @@  static inline void remove_metapage(struct folio *folio, struct metapage *mp)
 	}
 }
 
-static inline void inc_io(struct page *page)
+static inline void inc_io(struct folio *folio)
 {
-	atomic_inc(&mp_anchor(page)->io_count);
+	atomic_inc(&mp_anchor(folio)->io_count);
 }
 
 static inline void dec_io(struct folio *folio, void (*handler) (struct folio *))
@@ -166,7 +166,7 @@  static inline void remove_metapage(struct folio *folio, struct metapage *mp)
 	kunmap(&folio->page);
 }
 
-#define inc_io(page) do {} while(0)
+#define inc_io(folio) do {} while(0)
 #define dec_io(folio, handler) handler(folio)
 
 #endif
@@ -395,14 +395,14 @@  static int metapage_write_folio(struct folio *folio,
 			 * Increment counter before submitting i/o to keep
 			 * count from hitting zero before we're through
 			 */
-			inc_io(&folio->page);
+			inc_io(folio);
 			if (!bio->bi_iter.bi_size)
 				goto dump_bio;
 			submit_bio(bio);
 			nr_underway++;
 			bio = NULL;
 		} else
-			inc_io(&folio->page);
+			inc_io(folio);
 		xlen = (folio_size(folio) - offset) >> inode->i_blkbits;
 		pblock = metapage_get_blocks(inode, lblock, &xlen);
 		if (!pblock) {
@@ -496,7 +496,7 @@  static int metapage_read_folio(struct file *fp, struct folio *folio)
 		if (pblock) {
 			if (!folio->private)
 				insert_metapage(folio, NULL);
-			inc_io(&folio->page);
+			inc_io(folio);
 			if (bio)
 				submit_bio(bio);