linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/27] f2fs folio conversions for v6.15
@ 2025-02-18  5:51 Matthew Wilcox (Oracle)
  2025-02-18  5:51 ` [PATCH 01/27] f2fs: Add f2fs_folio_wait_writeback() Matthew Wilcox (Oracle)
                   ` (29 more replies)
  0 siblings, 30 replies; 41+ messages in thread
From: Matthew Wilcox (Oracle) @ 2025-02-18  5:51 UTC (permalink / raw)
  To: Jaegeuk Kim, Chao Yu
  Cc: Matthew Wilcox (Oracle), linux-f2fs-devel, linux-fsdevel

More f2fs folio conversions.  This time I'm focusing on removing
accesses to page->mapping as well as getting rid of accesses to
old APIs.  f2fs was the last user of wait_for_stable_page(),
grab_cache_page_write_begin() and wait_on_page_locked(), so
I've included those removals in this series too.

Matthew Wilcox (Oracle) (27):
  f2fs: Add f2fs_folio_wait_writeback()
  mm: Remove wait_for_stable_page()
  f2fs: Add f2fs_folio_put()
  f2fs: Convert f2fs_flush_inline_data() to use a folio
  f2fs: Convert f2fs_sync_node_pages() to use a folio
  f2fs: Pass a folio to flush_dirty_inode()
  f2fs: Convert f2fs_fsync_node_pages() to use a folio
  f2fs: Convert last_fsync_dnode() to use a folio
  f2fs: Return a folio from last_fsync_dnode()
  f2fs: Add f2fs_grab_cache_folio()
  mm: Remove grab_cache_page_write_begin()
  f2fs: Use a folio in __get_node_page()
  f2fs: Use a folio in do_write_page()
  f2fs: Convert f2fs_write_end_io() to use a folio_iter
  f2fs: Mark some functions as taking a const page pointer
  f2fs: Convert f2fs_in_warm_node_list() to take a folio
  f2fs: Add f2fs_get_node_folio()
  f2fs: Use a folio throughout f2fs_truncate_inode_blocks()
  f2fs: Use a folio throughout __get_meta_page()
  f2fs: Hoist the page_folio() call to the start of
    f2fs_merge_page_bio()
  f2fs: Add f2fs_get_read_data_folio()
  f2fs: Add f2fs_get_lock_data_folio()
  f2fs: Convert move_data_page() to use a folio
  f2fs: Convert truncate_partial_data_page() to use a folio
  f2fs: Convert gc_data_segment() to use a folio
  f2fs: Add f2fs_find_data_folio()
  mm: Remove wait_on_page_locked()

 fs/f2fs/checkpoint.c    |  26 ++--
 fs/f2fs/data.c          | 130 ++++++++++---------
 fs/f2fs/f2fs.h          |  90 +++++++++----
 fs/f2fs/file.c          |  24 ++--
 fs/f2fs/gc.c            |  42 +++---
 fs/f2fs/node.c          | 279 ++++++++++++++++++++--------------------
 fs/f2fs/node.h          |   6 +-
 fs/f2fs/segment.c       |  26 ++--
 include/linux/pagemap.h |   9 --
 mm/filemap.c            |   2 +-
 mm/folio-compat.c       |  14 --
 11 files changed, 338 insertions(+), 310 deletions(-)

-- 
2.47.2


^ permalink raw reply	[flat|nested] 41+ messages in thread

* [PATCH 01/27] f2fs: Add f2fs_folio_wait_writeback()
  2025-02-18  5:51 [PATCH 00/27] f2fs folio conversions for v6.15 Matthew Wilcox (Oracle)
@ 2025-02-18  5:51 ` Matthew Wilcox (Oracle)
  2025-02-18  5:51 ` [PATCH 02/27] mm: Remove wait_for_stable_page() Matthew Wilcox (Oracle)
                   ` (28 subsequent siblings)
  29 siblings, 0 replies; 41+ messages in thread
From: Matthew Wilcox (Oracle) @ 2025-02-18  5:51 UTC (permalink / raw)
  To: Jaegeuk Kim, Chao Yu
  Cc: Matthew Wilcox (Oracle), linux-f2fs-devel, linux-fsdevel

Convert f2fs_wait_on_page_writeback() to f2fs_folio_wait_writeback()
and add a compatibiility wrapper.  Replaces five calls to
compound_head() with one.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/f2fs/f2fs.h    |  6 ++++--
 fs/f2fs/segment.c | 19 +++++++++----------
 2 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 395f9d37449c..b05653f196dd 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -3760,8 +3760,10 @@ int f2fs_allocate_data_block(struct f2fs_sb_info *sbi, struct page *page,
 			struct f2fs_io_info *fio);
 void f2fs_update_device_state(struct f2fs_sb_info *sbi, nid_t ino,
 					block_t blkaddr, unsigned int blkcnt);
-void f2fs_wait_on_page_writeback(struct page *page,
-			enum page_type type, bool ordered, bool locked);
+void f2fs_folio_wait_writeback(struct folio *folio, enum page_type type,
+		bool ordered, bool locked);
+#define f2fs_wait_on_page_writeback(page, type, ordered, locked)	\
+		f2fs_folio_wait_writeback(page_folio(page), type, ordered, locked)
 void f2fs_wait_on_block_writeback(struct inode *inode, block_t blkaddr);
 void f2fs_wait_on_block_writeback_range(struct inode *inode, block_t blkaddr,
 								block_t len);
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 6ebe25eafafa..a29da14c5f19 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -4154,22 +4154,21 @@ void f2fs_replace_block(struct f2fs_sb_info *sbi, struct dnode_of_data *dn,
 	f2fs_update_data_blkaddr(dn, new_addr);
 }
 
-void f2fs_wait_on_page_writeback(struct page *page,
-				enum page_type type, bool ordered, bool locked)
+void f2fs_folio_wait_writeback(struct folio *folio, enum page_type type,
+		bool ordered, bool locked)
 {
-	if (folio_test_writeback(page_folio(page))) {
-		struct f2fs_sb_info *sbi = F2FS_P_SB(page);
+	if (folio_test_writeback(folio)) {
+		struct f2fs_sb_info *sbi = F2FS_F_SB(folio);
 
 		/* submit cached LFS IO */
-		f2fs_submit_merged_write_cond(sbi, NULL, page, 0, type);
+		f2fs_submit_merged_write_cond(sbi, NULL, &folio->page, 0, type);
 		/* submit cached IPU IO */
-		f2fs_submit_merged_ipu_write(sbi, NULL, page);
+		f2fs_submit_merged_ipu_write(sbi, NULL, &folio->page);
 		if (ordered) {
-			wait_on_page_writeback(page);
-			f2fs_bug_on(sbi, locked &&
-				folio_test_writeback(page_folio(page)));
+			folio_wait_writeback(folio);
+			f2fs_bug_on(sbi, locked && folio_test_writeback(folio));
 		} else {
-			wait_for_stable_page(page);
+			folio_wait_stable(folio);
 		}
 	}
 }
-- 
2.47.2


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH 02/27] mm: Remove wait_for_stable_page()
  2025-02-18  5:51 [PATCH 00/27] f2fs folio conversions for v6.15 Matthew Wilcox (Oracle)
  2025-02-18  5:51 ` [PATCH 01/27] f2fs: Add f2fs_folio_wait_writeback() Matthew Wilcox (Oracle)
@ 2025-02-18  5:51 ` Matthew Wilcox (Oracle)
  2025-02-18  5:51 ` [PATCH 03/27] f2fs: Add f2fs_folio_put() Matthew Wilcox (Oracle)
                   ` (27 subsequent siblings)
  29 siblings, 0 replies; 41+ messages in thread
From: Matthew Wilcox (Oracle) @ 2025-02-18  5:51 UTC (permalink / raw)
  To: Jaegeuk Kim, Chao Yu
  Cc: Matthew Wilcox (Oracle), linux-f2fs-devel, linux-fsdevel

The last caller has been converted to call folio_wait_stable(), so
we can remove this wrapper.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 include/linux/pagemap.h | 1 -
 mm/folio-compat.c       | 6 ------
 2 files changed, 7 deletions(-)

diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
index 47bfc6b1b632..a19d8e334194 100644
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -1256,7 +1256,6 @@ void folio_wait_writeback(struct folio *folio);
 int folio_wait_writeback_killable(struct folio *folio);
 void end_page_writeback(struct page *page);
 void folio_end_writeback(struct folio *folio);
-void wait_for_stable_page(struct page *page);
 void folio_wait_stable(struct folio *folio);
 void __folio_mark_dirty(struct folio *folio, struct address_space *, int warn);
 void folio_account_cleaned(struct folio *folio, struct bdi_writeback *wb);
diff --git a/mm/folio-compat.c b/mm/folio-compat.c
index 1d1832e2a599..5766d135af1e 100644
--- a/mm/folio-compat.c
+++ b/mm/folio-compat.c
@@ -28,12 +28,6 @@ void wait_on_page_writeback(struct page *page)
 }
 EXPORT_SYMBOL_GPL(wait_on_page_writeback);
 
-void wait_for_stable_page(struct page *page)
-{
-	return folio_wait_stable(page_folio(page));
-}
-EXPORT_SYMBOL_GPL(wait_for_stable_page);
-
 void mark_page_accessed(struct page *page)
 {
 	folio_mark_accessed(page_folio(page));
-- 
2.47.2


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH 03/27] f2fs: Add f2fs_folio_put()
  2025-02-18  5:51 [PATCH 00/27] f2fs folio conversions for v6.15 Matthew Wilcox (Oracle)
  2025-02-18  5:51 ` [PATCH 01/27] f2fs: Add f2fs_folio_wait_writeback() Matthew Wilcox (Oracle)
  2025-02-18  5:51 ` [PATCH 02/27] mm: Remove wait_for_stable_page() Matthew Wilcox (Oracle)
@ 2025-02-18  5:51 ` Matthew Wilcox (Oracle)
  2025-02-21  4:55   ` Jaegeuk Kim
  2025-02-18  5:51 ` [PATCH 04/27] f2fs: Convert f2fs_flush_inline_data() to use a folio Matthew Wilcox (Oracle)
                   ` (26 subsequent siblings)
  29 siblings, 1 reply; 41+ messages in thread
From: Matthew Wilcox (Oracle) @ 2025-02-18  5:51 UTC (permalink / raw)
  To: Jaegeuk Kim, Chao Yu
  Cc: Matthew Wilcox (Oracle), linux-f2fs-devel, linux-fsdevel

Convert f2fs_put_page() to f2fs_folio_put() and add a wrapper.
Replaces three calls to compound_head() with one.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/f2fs/f2fs.h | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index b05653f196dd..5e01a08afbd7 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -2806,16 +2806,21 @@ static inline struct page *f2fs_pagecache_get_page(
 	return pagecache_get_page(mapping, index, fgp_flags, gfp_mask);
 }
 
-static inline void f2fs_put_page(struct page *page, int unlock)
+static inline void f2fs_folio_put(struct folio *folio, bool unlock)
 {
-	if (!page)
+	if (!folio)
 		return;
 
 	if (unlock) {
-		f2fs_bug_on(F2FS_P_SB(page), !PageLocked(page));
-		unlock_page(page);
+		f2fs_bug_on(F2FS_F_SB(folio), !folio_test_locked(folio));
+		folio_unlock(folio);
 	}
-	put_page(page);
+	folio_put(folio);
+}
+
+static inline void f2fs_put_page(struct page *page, int unlock)
+{
+	f2fs_folio_put(page_folio(page), unlock);
 }
 
 static inline void f2fs_put_dnode(struct dnode_of_data *dn)
-- 
2.47.2


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH 04/27] f2fs: Convert f2fs_flush_inline_data() to use a folio
  2025-02-18  5:51 [PATCH 00/27] f2fs folio conversions for v6.15 Matthew Wilcox (Oracle)
                   ` (2 preceding siblings ...)
  2025-02-18  5:51 ` [PATCH 03/27] f2fs: Add f2fs_folio_put() Matthew Wilcox (Oracle)
@ 2025-02-18  5:51 ` Matthew Wilcox (Oracle)
  2025-02-18  5:51 ` [PATCH 05/27] f2fs: Convert f2fs_sync_node_pages() " Matthew Wilcox (Oracle)
                   ` (25 subsequent siblings)
  29 siblings, 0 replies; 41+ messages in thread
From: Matthew Wilcox (Oracle) @ 2025-02-18  5:51 UTC (permalink / raw)
  To: Jaegeuk Kim, Chao Yu
  Cc: Matthew Wilcox (Oracle), linux-f2fs-devel, linux-fsdevel

Use the folio APIs where they exist.  Saves several hidden calls to
compound_head().  Also removes a reference to page->mapping.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/f2fs/node.c | 31 +++++++++++++------------------
 1 file changed, 13 insertions(+), 18 deletions(-)

diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index f88392fc4ba9..522bf84c0209 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -1951,32 +1951,27 @@ void f2fs_flush_inline_data(struct f2fs_sb_info *sbi)
 		int i;
 
 		for (i = 0; i < nr_folios; i++) {
-			struct page *page = &fbatch.folios[i]->page;
+			struct folio *folio = fbatch.folios[i];
 
-			if (!IS_INODE(page))
+			if (!IS_INODE(&folio->page))
 				continue;
 
-			lock_page(page);
+			folio_lock(folio);
 
-			if (unlikely(page->mapping != NODE_MAPPING(sbi))) {
-continue_unlock:
-				unlock_page(page);
-				continue;
-			}
-
-			if (!PageDirty(page)) {
-				/* someone wrote it for us */
-				goto continue_unlock;
-			}
+			if (unlikely(folio->mapping != NODE_MAPPING(sbi)))
+				goto unlock;
+			if (!folio_test_dirty(folio))
+				goto unlock;
 
 			/* flush inline_data, if it's async context. */
-			if (page_private_inline(page)) {
-				clear_page_private_inline(page);
-				unlock_page(page);
-				flush_inline_data(sbi, ino_of_node(page));
+			if (page_private_inline(&folio->page)) {
+				clear_page_private_inline(&folio->page);
+				folio_unlock(folio);
+				flush_inline_data(sbi, ino_of_node(&folio->page));
 				continue;
 			}
-			unlock_page(page);
+unlock:
+			folio_unlock(folio);
 		}
 		folio_batch_release(&fbatch);
 		cond_resched();
-- 
2.47.2


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH 05/27] f2fs: Convert f2fs_sync_node_pages() to use a folio
  2025-02-18  5:51 [PATCH 00/27] f2fs folio conversions for v6.15 Matthew Wilcox (Oracle)
                   ` (3 preceding siblings ...)
  2025-02-18  5:51 ` [PATCH 04/27] f2fs: Convert f2fs_flush_inline_data() to use a folio Matthew Wilcox (Oracle)
@ 2025-02-18  5:51 ` Matthew Wilcox (Oracle)
  2025-02-18  5:51 ` [PATCH 06/27] f2fs: Pass a folio to flush_dirty_inode() Matthew Wilcox (Oracle)
                   ` (24 subsequent siblings)
  29 siblings, 0 replies; 41+ messages in thread
From: Matthew Wilcox (Oracle) @ 2025-02-18  5:51 UTC (permalink / raw)
  To: Jaegeuk Kim, Chao Yu
  Cc: Matthew Wilcox (Oracle), linux-f2fs-devel, linux-fsdevel

Use the folio APIs where they exist.  Saves several hidden calls to
compound_head().  Also removes a reference to page->mapping.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/f2fs/node.c | 44 ++++++++++++++++++++++----------------------
 1 file changed, 22 insertions(+), 22 deletions(-)

diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index 522bf84c0209..6022f9200f4c 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -2000,7 +2000,7 @@ int f2fs_sync_node_pages(struct f2fs_sb_info *sbi,
 		int i;
 
 		for (i = 0; i < nr_folios; i++) {
-			struct page *page = &fbatch.folios[i]->page;
+			struct folio *folio = fbatch.folios[i];
 			bool submitted = false;
 
 			/* give a priority to WB_SYNC threads */
@@ -2016,27 +2016,27 @@ int f2fs_sync_node_pages(struct f2fs_sb_info *sbi,
 			 * 1. dentry dnodes
 			 * 2. file dnodes
 			 */
-			if (step == 0 && IS_DNODE(page))
+			if (step == 0 && IS_DNODE(&folio->page))
 				continue;
-			if (step == 1 && (!IS_DNODE(page) ||
-						is_cold_node(page)))
+			if (step == 1 && (!IS_DNODE(&folio->page) ||
+						is_cold_node(&folio->page)))
 				continue;
-			if (step == 2 && (!IS_DNODE(page) ||
-						!is_cold_node(page)))
+			if (step == 2 && (!IS_DNODE(&folio->page) ||
+						!is_cold_node(&folio->page)))
 				continue;
 lock_node:
 			if (wbc->sync_mode == WB_SYNC_ALL)
-				lock_page(page);
-			else if (!trylock_page(page))
+				folio_lock(folio);
+			else if (!folio_trylock(folio))
 				continue;
 
-			if (unlikely(page->mapping != NODE_MAPPING(sbi))) {
+			if (unlikely(folio->mapping != NODE_MAPPING(sbi))) {
 continue_unlock:
-				unlock_page(page);
+				folio_unlock(folio);
 				continue;
 			}
 
-			if (!PageDirty(page)) {
+			if (!folio_test_dirty(folio)) {
 				/* someone wrote it for us */
 				goto continue_unlock;
 			}
@@ -2046,29 +2046,29 @@ int f2fs_sync_node_pages(struct f2fs_sb_info *sbi,
 				goto write_node;
 
 			/* flush inline_data */
-			if (page_private_inline(page)) {
-				clear_page_private_inline(page);
-				unlock_page(page);
-				flush_inline_data(sbi, ino_of_node(page));
+			if (page_private_inline(&folio->page)) {
+				clear_page_private_inline(&folio->page);
+				folio_unlock(folio);
+				flush_inline_data(sbi, ino_of_node(&folio->page));
 				goto lock_node;
 			}
 
 			/* flush dirty inode */
-			if (IS_INODE(page) && flush_dirty_inode(page))
+			if (IS_INODE(&folio->page) && flush_dirty_inode(&folio->page))
 				goto lock_node;
 write_node:
-			f2fs_wait_on_page_writeback(page, NODE, true, true);
+			f2fs_folio_wait_writeback(folio, NODE, true, true);
 
-			if (!clear_page_dirty_for_io(page))
+			if (!folio_clear_dirty_for_io(folio))
 				goto continue_unlock;
 
-			set_fsync_mark(page, 0);
-			set_dentry_mark(page, 0);
+			set_fsync_mark(&folio->page, 0);
+			set_dentry_mark(&folio->page, 0);
 
-			ret = __write_node_page(page, false, &submitted,
+			ret = __write_node_page(&folio->page, false, &submitted,
 						wbc, do_balance, io_type, NULL);
 			if (ret)
-				unlock_page(page);
+				folio_unlock(folio);
 			else if (submitted)
 				nwritten++;
 
-- 
2.47.2


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH 06/27] f2fs: Pass a folio to flush_dirty_inode()
  2025-02-18  5:51 [PATCH 00/27] f2fs folio conversions for v6.15 Matthew Wilcox (Oracle)
                   ` (4 preceding siblings ...)
  2025-02-18  5:51 ` [PATCH 05/27] f2fs: Convert f2fs_sync_node_pages() " Matthew Wilcox (Oracle)
@ 2025-02-18  5:51 ` Matthew Wilcox (Oracle)
  2025-02-18  5:51 ` [PATCH 07/27] f2fs: Convert f2fs_fsync_node_pages() to use a folio Matthew Wilcox (Oracle)
                   ` (23 subsequent siblings)
  29 siblings, 0 replies; 41+ messages in thread
From: Matthew Wilcox (Oracle) @ 2025-02-18  5:51 UTC (permalink / raw)
  To: Jaegeuk Kim, Chao Yu
  Cc: Matthew Wilcox (Oracle), linux-f2fs-devel, linux-fsdevel

Its one caller now has a folio; pass it in and do page conversions where
necessary inside flush_dirty_inode().  Saves two hidden calls to
compound_head().

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/f2fs/node.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index 6022f9200f4c..1ff6f5888950 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -1920,18 +1920,18 @@ static int f2fs_match_ino(struct inode *inode, unsigned long ino, void *data)
 	return 1;
 }
 
-static bool flush_dirty_inode(struct page *page)
+static bool flush_dirty_inode(struct folio *folio)
 {
-	struct f2fs_sb_info *sbi = F2FS_P_SB(page);
+	struct f2fs_sb_info *sbi = F2FS_F_SB(folio);
 	struct inode *inode;
-	nid_t ino = ino_of_node(page);
+	nid_t ino = ino_of_node(&folio->page);
 
 	inode = find_inode_nowait(sbi->sb, ino, f2fs_match_ino, NULL);
 	if (!inode)
 		return false;
 
-	f2fs_update_inode(inode, page);
-	unlock_page(page);
+	f2fs_update_inode(inode, &folio->page);
+	folio_unlock(folio);
 
 	iput(inode);
 	return true;
@@ -2054,7 +2054,7 @@ int f2fs_sync_node_pages(struct f2fs_sb_info *sbi,
 			}
 
 			/* flush dirty inode */
-			if (IS_INODE(&folio->page) && flush_dirty_inode(&folio->page))
+			if (IS_INODE(&folio->page) && flush_dirty_inode(folio))
 				goto lock_node;
 write_node:
 			f2fs_folio_wait_writeback(folio, NODE, true, true);
-- 
2.47.2


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH 07/27] f2fs: Convert f2fs_fsync_node_pages() to use a folio
  2025-02-18  5:51 [PATCH 00/27] f2fs folio conversions for v6.15 Matthew Wilcox (Oracle)
                   ` (5 preceding siblings ...)
  2025-02-18  5:51 ` [PATCH 06/27] f2fs: Pass a folio to flush_dirty_inode() Matthew Wilcox (Oracle)
@ 2025-02-18  5:51 ` Matthew Wilcox (Oracle)
  2025-02-18  5:51 ` [PATCH 08/27] f2fs: Convert last_fsync_dnode() " Matthew Wilcox (Oracle)
                   ` (22 subsequent siblings)
  29 siblings, 0 replies; 41+ messages in thread
From: Matthew Wilcox (Oracle) @ 2025-02-18  5:51 UTC (permalink / raw)
  To: Jaegeuk Kim, Chao Yu
  Cc: Matthew Wilcox (Oracle), linux-f2fs-devel, linux-fsdevel

Use the folio APIs where they exist.  Saves several hidden calls to
compound_head().  Also removes a reference to page->mapping.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/f2fs/node.c | 48 ++++++++++++++++++++++++------------------------
 1 file changed, 24 insertions(+), 24 deletions(-)

diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index 1ff6f5888950..415bda9acd0e 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -1804,7 +1804,7 @@ int f2fs_fsync_node_pages(struct f2fs_sb_info *sbi, struct inode *inode,
 		int i;
 
 		for (i = 0; i < nr_folios; i++) {
-			struct page *page = &fbatch.folios[i]->page;
+			struct folio *folio = fbatch.folios[i];
 			bool submitted = false;
 
 			if (unlikely(f2fs_cp_error(sbi))) {
@@ -1814,63 +1814,63 @@ int f2fs_fsync_node_pages(struct f2fs_sb_info *sbi, struct inode *inode,
 				goto out;
 			}
 
-			if (!IS_DNODE(page) || !is_cold_node(page))
+			if (!IS_DNODE(&folio->page) || !is_cold_node(&folio->page))
 				continue;
-			if (ino_of_node(page) != ino)
+			if (ino_of_node(&folio->page) != ino)
 				continue;
 
-			lock_page(page);
+			folio_lock(folio);
 
-			if (unlikely(page->mapping != NODE_MAPPING(sbi))) {
+			if (unlikely(folio->mapping != NODE_MAPPING(sbi))) {
 continue_unlock:
-				unlock_page(page);
+				folio_unlock(folio);
 				continue;
 			}
-			if (ino_of_node(page) != ino)
+			if (ino_of_node(&folio->page) != ino)
 				goto continue_unlock;
 
-			if (!PageDirty(page) && page != last_page) {
+			if (!folio_test_dirty(folio) && &folio->page != last_page) {
 				/* someone wrote it for us */
 				goto continue_unlock;
 			}
 
-			f2fs_wait_on_page_writeback(page, NODE, true, true);
+			f2fs_folio_wait_writeback(folio, NODE, true, true);
 
-			set_fsync_mark(page, 0);
-			set_dentry_mark(page, 0);
+			set_fsync_mark(&folio->page, 0);
+			set_dentry_mark(&folio->page, 0);
 
-			if (!atomic || page == last_page) {
-				set_fsync_mark(page, 1);
+			if (!atomic || &folio->page == last_page) {
+				set_fsync_mark(&folio->page, 1);
 				percpu_counter_inc(&sbi->rf_node_block_count);
-				if (IS_INODE(page)) {
+				if (IS_INODE(&folio->page)) {
 					if (is_inode_flag_set(inode,
 								FI_DIRTY_INODE))
-						f2fs_update_inode(inode, page);
-					set_dentry_mark(page,
+						f2fs_update_inode(inode, &folio->page);
+					set_dentry_mark(&folio->page,
 						f2fs_need_dentry_mark(sbi, ino));
 				}
 				/* may be written by other thread */
-				if (!PageDirty(page))
-					set_page_dirty(page);
+				if (!folio_test_dirty(folio))
+					folio_mark_dirty(folio);
 			}
 
-			if (!clear_page_dirty_for_io(page))
+			if (!folio_clear_dirty_for_io(folio))
 				goto continue_unlock;
 
-			ret = __write_node_page(page, atomic &&
-						page == last_page,
+			ret = __write_node_page(&folio->page, atomic &&
+						&folio->page == last_page,
 						&submitted, wbc, true,
 						FS_NODE_IO, seq_id);
 			if (ret) {
-				unlock_page(page);
+				folio_unlock(folio);
 				f2fs_put_page(last_page, 0);
 				break;
 			} else if (submitted) {
 				nwritten++;
 			}
 
-			if (page == last_page) {
-				f2fs_put_page(page, 0);
+			if (&folio->page == last_page) {
+				f2fs_folio_put(folio, false);
 				marked = true;
 				break;
 			}
-- 
2.47.2


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH 08/27] f2fs: Convert last_fsync_dnode() to use a folio
  2025-02-18  5:51 [PATCH 00/27] f2fs folio conversions for v6.15 Matthew Wilcox (Oracle)
                   ` (6 preceding siblings ...)
  2025-02-18  5:51 ` [PATCH 07/27] f2fs: Convert f2fs_fsync_node_pages() to use a folio Matthew Wilcox (Oracle)
@ 2025-02-18  5:51 ` Matthew Wilcox (Oracle)
  2025-02-18  5:51 ` [PATCH 09/27] f2fs: Return a folio from last_fsync_dnode() Matthew Wilcox (Oracle)
                   ` (21 subsequent siblings)
  29 siblings, 0 replies; 41+ messages in thread
From: Matthew Wilcox (Oracle) @ 2025-02-18  5:51 UTC (permalink / raw)
  To: Jaegeuk Kim, Chao Yu
  Cc: Matthew Wilcox (Oracle), linux-f2fs-devel, linux-fsdevel

Use the folio APIs where they exist.  Saves several hidden calls to
compound_head().  Also removes a reference to page->mapping.

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

diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index 415bda9acd0e..66260fae3cc8 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -1565,7 +1565,7 @@ static struct page *last_fsync_dnode(struct f2fs_sb_info *sbi, nid_t ino)
 {
 	pgoff_t index;
 	struct folio_batch fbatch;
-	struct page *last_page = NULL;
+	struct folio *last_folio = NULL;
 	int nr_folios;
 
 	folio_batch_init(&fbatch);
@@ -1577,45 +1577,45 @@ static struct page *last_fsync_dnode(struct f2fs_sb_info *sbi, nid_t ino)
 		int i;
 
 		for (i = 0; i < nr_folios; i++) {
-			struct page *page = &fbatch.folios[i]->page;
+			struct folio *folio = fbatch.folios[i];
 
 			if (unlikely(f2fs_cp_error(sbi))) {
-				f2fs_put_page(last_page, 0);
+				f2fs_folio_put(last_folio, false);
 				folio_batch_release(&fbatch);
 				return ERR_PTR(-EIO);
 			}
 
-			if (!IS_DNODE(page) || !is_cold_node(page))
+			if (!IS_DNODE(&folio->page) || !is_cold_node(&folio->page))
 				continue;
-			if (ino_of_node(page) != ino)
+			if (ino_of_node(&folio->page) != ino)
 				continue;
 
-			lock_page(page);
+			folio_lock(folio);
 
-			if (unlikely(page->mapping != NODE_MAPPING(sbi))) {
+			if (unlikely(folio->mapping != NODE_MAPPING(sbi))) {
 continue_unlock:
-				unlock_page(page);
+				folio_unlock(folio);
 				continue;
 			}
-			if (ino_of_node(page) != ino)
+			if (ino_of_node(&folio->page) != ino)
 				goto continue_unlock;
 
-			if (!PageDirty(page)) {
+			if (!folio_test_dirty(folio)) {
 				/* someone wrote it for us */
 				goto continue_unlock;
 			}
 
-			if (last_page)
-				f2fs_put_page(last_page, 0);
+			if (last_folio)
+				f2fs_folio_put(last_folio, false);
 
-			get_page(page);
-			last_page = page;
-			unlock_page(page);
+			folio_get(folio);
+			last_folio = folio;
+			folio_unlock(folio);
 		}
 		folio_batch_release(&fbatch);
 		cond_resched();
 	}
-	return last_page;
+	return &last_folio->page;
 }
 
 static int __write_node_page(struct page *page, bool atomic, bool *submitted,
-- 
2.47.2


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH 09/27] f2fs: Return a folio from last_fsync_dnode()
  2025-02-18  5:51 [PATCH 00/27] f2fs folio conversions for v6.15 Matthew Wilcox (Oracle)
                   ` (7 preceding siblings ...)
  2025-02-18  5:51 ` [PATCH 08/27] f2fs: Convert last_fsync_dnode() " Matthew Wilcox (Oracle)
@ 2025-02-18  5:51 ` Matthew Wilcox (Oracle)
  2025-02-18  5:51 ` [PATCH 10/27] f2fs: Add f2fs_grab_cache_folio() Matthew Wilcox (Oracle)
                   ` (20 subsequent siblings)
  29 siblings, 0 replies; 41+ messages in thread
From: Matthew Wilcox (Oracle) @ 2025-02-18  5:51 UTC (permalink / raw)
  To: Jaegeuk Kim, Chao Yu
  Cc: Matthew Wilcox (Oracle), linux-f2fs-devel, linux-fsdevel

Convert last_page to last_folio in f2fs_fsync_node_pages() and
use folio APIs where they exist.  Saves a few hidden calls to
compound_head().

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/f2fs/node.c | 34 +++++++++++++++++-----------------
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index 66260fae3cc8..1bd151d71b6b 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -1561,7 +1561,7 @@ static void flush_inline_data(struct f2fs_sb_info *sbi, nid_t ino)
 	iput(inode);
 }
 
-static struct page *last_fsync_dnode(struct f2fs_sb_info *sbi, nid_t ino)
+static struct folio *last_fsync_dnode(struct f2fs_sb_info *sbi, nid_t ino)
 {
 	pgoff_t index;
 	struct folio_batch fbatch;
@@ -1615,7 +1615,7 @@ static struct page *last_fsync_dnode(struct f2fs_sb_info *sbi, nid_t ino)
 		folio_batch_release(&fbatch);
 		cond_resched();
 	}
-	return &last_folio->page;
+	return last_folio;
 }
 
 static int __write_node_page(struct page *page, bool atomic, bool *submitted,
@@ -1783,16 +1783,16 @@ int f2fs_fsync_node_pages(struct f2fs_sb_info *sbi, struct inode *inode,
 	pgoff_t index;
 	struct folio_batch fbatch;
 	int ret = 0;
-	struct page *last_page = NULL;
+	struct folio *last_folio = NULL;
 	bool marked = false;
 	nid_t ino = inode->i_ino;
 	int nr_folios;
 	int nwritten = 0;
 
 	if (atomic) {
-		last_page = last_fsync_dnode(sbi, ino);
-		if (IS_ERR_OR_NULL(last_page))
-			return PTR_ERR_OR_ZERO(last_page);
+		last_folio = last_fsync_dnode(sbi, ino);
+		if (IS_ERR_OR_NULL(last_folio))
+			return PTR_ERR_OR_ZERO(last_folio);
 	}
 retry:
 	folio_batch_init(&fbatch);
@@ -1808,7 +1808,7 @@ int f2fs_fsync_node_pages(struct f2fs_sb_info *sbi, struct inode *inode,
 			bool submitted = false;
 
 			if (unlikely(f2fs_cp_error(sbi))) {
-				f2fs_put_page(last_page, 0);
+				f2fs_folio_put(last_folio, false);
 				folio_batch_release(&fbatch);
 				ret = -EIO;
 				goto out;
@@ -1829,7 +1829,7 @@ int f2fs_fsync_node_pages(struct f2fs_sb_info *sbi, struct inode *inode,
 			if (ino_of_node(&folio->page) != ino)
 				goto continue_unlock;
 
-			if (!folio_test_dirty(folio) && &folio->page != last_page) {
+			if (!folio_test_dirty(folio) && folio != last_folio) {
 				/* someone wrote it for us */
 				goto continue_unlock;
 			}
@@ -1839,7 +1839,7 @@ int f2fs_fsync_node_pages(struct f2fs_sb_info *sbi, struct inode *inode,
 			set_fsync_mark(&folio->page, 0);
 			set_dentry_mark(&folio->page, 0);
 
-			if (!atomic || &folio->page == last_page) {
+			if (!atomic || folio == last_folio) {
 				set_fsync_mark(&folio->page, 1);
 				percpu_counter_inc(&sbi->rf_node_block_count);
 				if (IS_INODE(&folio->page)) {
@@ -1858,18 +1858,18 @@ int f2fs_fsync_node_pages(struct f2fs_sb_info *sbi, struct inode *inode,
 				goto continue_unlock;
 
 			ret = __write_node_page(&folio->page, atomic &&
-						&folio->page == last_page,
+						folio == last_folio,
 						&submitted, wbc, true,
 						FS_NODE_IO, seq_id);
 			if (ret) {
 				folio_unlock(folio);
-				f2fs_put_page(last_page, 0);
+				f2fs_folio_put(last_folio, false);
 				break;
 			} else if (submitted) {
 				nwritten++;
 			}
 
-			if (&folio->page == last_page) {
+			if (folio == last_folio) {
 				f2fs_folio_put(folio, false);
 				marked = true;
 				break;
@@ -1883,11 +1883,11 @@ int f2fs_fsync_node_pages(struct f2fs_sb_info *sbi, struct inode *inode,
 	}
 	if (!ret && atomic && !marked) {
 		f2fs_debug(sbi, "Retry to write fsync mark: ino=%u, idx=%lx",
-			   ino, page_folio(last_page)->index);
-		lock_page(last_page);
-		f2fs_wait_on_page_writeback(last_page, NODE, true, true);
-		set_page_dirty(last_page);
-		unlock_page(last_page);
+			   ino, last_folio->index);
+		folio_lock(last_folio);
+		f2fs_folio_wait_writeback(last_folio, NODE, true, true);
+		folio_mark_dirty(last_folio);
+		folio_unlock(last_folio);
 		goto retry;
 	}
 out:
-- 
2.47.2


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH 10/27] f2fs: Add f2fs_grab_cache_folio()
  2025-02-18  5:51 [PATCH 00/27] f2fs folio conversions for v6.15 Matthew Wilcox (Oracle)
                   ` (8 preceding siblings ...)
  2025-02-18  5:51 ` [PATCH 09/27] f2fs: Return a folio from last_fsync_dnode() Matthew Wilcox (Oracle)
@ 2025-02-18  5:51 ` Matthew Wilcox (Oracle)
  2025-02-18  5:51 ` [PATCH 11/27] mm: Remove grab_cache_page_write_begin() Matthew Wilcox (Oracle)
                   ` (19 subsequent siblings)
  29 siblings, 0 replies; 41+ messages in thread
From: Matthew Wilcox (Oracle) @ 2025-02-18  5:51 UTC (permalink / raw)
  To: Jaegeuk Kim, Chao Yu
  Cc: Matthew Wilcox (Oracle), linux-f2fs-devel, linux-fsdevel

Convert f2fs_grab_cache_page() into f2fs_grab_cache_folio()
and add a wrapper.  Removes several calls to deprecated functions.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/f2fs/f2fs.h | 37 +++++++++++++++++++++++++------------
 1 file changed, 25 insertions(+), 12 deletions(-)

diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 5e01a08afbd7..cf664ca38905 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -2767,33 +2767,46 @@ static inline s64 valid_inode_count(struct f2fs_sb_info *sbi)
 	return percpu_counter_sum_positive(&sbi->total_valid_inode_count);
 }
 
-static inline struct page *f2fs_grab_cache_page(struct address_space *mapping,
-						pgoff_t index, bool for_write)
+static inline struct folio *f2fs_grab_cache_folio(struct address_space *mapping,
+		pgoff_t index, bool for_write)
 {
-	struct page *page;
+	struct folio *folio;
 	unsigned int flags;
 
 	if (IS_ENABLED(CONFIG_F2FS_FAULT_INJECTION)) {
+		fgf_t fgf_flags;
+
 		if (!for_write)
-			page = find_get_page_flags(mapping, index,
-							FGP_LOCK | FGP_ACCESSED);
+			fgf_flags = FGP_LOCK | FGP_ACCESSED;
 		else
-			page = find_lock_page(mapping, index);
-		if (page)
-			return page;
+			fgf_flags = FGP_LOCK;
+		folio = __filemap_get_folio(mapping, index, fgf_flags, 0);
+		if (!IS_ERR(folio))
+			return folio;
 
 		if (time_to_inject(F2FS_M_SB(mapping), FAULT_PAGE_ALLOC))
-			return NULL;
+			return ERR_PTR(-ENOMEM);
 	}
 
 	if (!for_write)
-		return grab_cache_page(mapping, index);
+		return filemap_grab_folio(mapping, index);
 
 	flags = memalloc_nofs_save();
-	page = grab_cache_page_write_begin(mapping, index);
+	folio = __filemap_get_folio(mapping, index, FGP_WRITEBEGIN,
+			mapping_gfp_mask(mapping));
 	memalloc_nofs_restore(flags);
 
-	return page;
+	return folio;
+}
+
+static inline struct page *f2fs_grab_cache_page(struct address_space *mapping,
+						pgoff_t index, bool for_write)
+{
+	struct folio *folio = f2fs_grab_cache_folio(mapping, index, for_write);
+
+	if (IS_ERR(folio))
+		return NULL;
+	return &folio->page;
 }
 
 static inline struct page *f2fs_pagecache_get_page(
-- 
2.47.2


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH 11/27] mm: Remove grab_cache_page_write_begin()
  2025-02-18  5:51 [PATCH 00/27] f2fs folio conversions for v6.15 Matthew Wilcox (Oracle)
                   ` (9 preceding siblings ...)
  2025-02-18  5:51 ` [PATCH 10/27] f2fs: Add f2fs_grab_cache_folio() Matthew Wilcox (Oracle)
@ 2025-02-18  5:51 ` Matthew Wilcox (Oracle)
  2025-02-18  5:51 ` [PATCH 12/27] f2fs: Use a folio in __get_node_page() Matthew Wilcox (Oracle)
                   ` (18 subsequent siblings)
  29 siblings, 0 replies; 41+ messages in thread
From: Matthew Wilcox (Oracle) @ 2025-02-18  5:51 UTC (permalink / raw)
  To: Jaegeuk Kim, Chao Yu
  Cc: Matthew Wilcox (Oracle), linux-f2fs-devel, linux-fsdevel

All callers have now been converted to use folios, so remove this
compatibility wrapper.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 include/linux/pagemap.h | 3 ---
 mm/folio-compat.c       | 8 --------
 2 files changed, 11 deletions(-)

diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
index a19d8e334194..45817e2106ee 100644
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -990,9 +990,6 @@ unsigned filemap_get_folios_contig(struct address_space *mapping,
 unsigned filemap_get_folios_tag(struct address_space *mapping, pgoff_t *start,
 		pgoff_t end, xa_mark_t tag, struct folio_batch *fbatch);
 
-struct page *grab_cache_page_write_begin(struct address_space *mapping,
-			pgoff_t index);
-
 /*
  * Returns locked page at given index in given cache, creating it if needed.
  */
diff --git a/mm/folio-compat.c b/mm/folio-compat.c
index 5766d135af1e..45540942d148 100644
--- a/mm/folio-compat.c
+++ b/mm/folio-compat.c
@@ -84,11 +84,3 @@ struct page *pagecache_get_page(struct address_space *mapping, pgoff_t index,
 	return folio_file_page(folio, index);
 }
 EXPORT_SYMBOL(pagecache_get_page);
-
-struct page *grab_cache_page_write_begin(struct address_space *mapping,
-					pgoff_t index)
-{
-	return pagecache_get_page(mapping, index, FGP_WRITEBEGIN,
-			mapping_gfp_mask(mapping));
-}
-EXPORT_SYMBOL(grab_cache_page_write_begin);
-- 
2.47.2


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH 12/27] f2fs: Use a folio in __get_node_page()
  2025-02-18  5:51 [PATCH 00/27] f2fs folio conversions for v6.15 Matthew Wilcox (Oracle)
                   ` (10 preceding siblings ...)
  2025-02-18  5:51 ` [PATCH 11/27] mm: Remove grab_cache_page_write_begin() Matthew Wilcox (Oracle)
@ 2025-02-18  5:51 ` Matthew Wilcox (Oracle)
  2025-02-18  5:51 ` [PATCH 13/27] f2fs: Use a folio in do_write_page() Matthew Wilcox (Oracle)
                   ` (17 subsequent siblings)
  29 siblings, 0 replies; 41+ messages in thread
From: Matthew Wilcox (Oracle) @ 2025-02-18  5:51 UTC (permalink / raw)
  To: Jaegeuk Kim, Chao Yu
  Cc: Matthew Wilcox (Oracle), linux-f2fs-devel, linux-fsdevel

Retrieve a folio from the page cache and use it throughout.  Saves six
hidden calls to compound_head() and removes a reference to page->mapping.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/f2fs/node.c | 36 ++++++++++++++++++------------------
 1 file changed, 18 insertions(+), 18 deletions(-)

diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index 1bd151d71b6b..db97624e30b3 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -1452,7 +1452,7 @@ void f2fs_ra_node_page(struct f2fs_sb_info *sbi, nid_t nid)
 static struct page *__get_node_page(struct f2fs_sb_info *sbi, pgoff_t nid,
 					struct page *parent, int start)
 {
-	struct page *page;
+	struct folio *folio;
 	int err;
 
 	if (!nid)
@@ -1460,11 +1460,11 @@ static struct page *__get_node_page(struct f2fs_sb_info *sbi, pgoff_t nid,
 	if (f2fs_check_nid_range(sbi, nid))
 		return ERR_PTR(-EINVAL);
 repeat:
-	page = f2fs_grab_cache_page(NODE_MAPPING(sbi), nid, false);
-	if (!page)
-		return ERR_PTR(-ENOMEM);
+	folio = f2fs_grab_cache_folio(NODE_MAPPING(sbi), nid, false);
+	if (IS_ERR(folio))
+		return ERR_CAST(folio);
 
-	err = read_node_page(page, 0);
+	err = read_node_page(&folio->page, 0);
 	if (err < 0) {
 		goto out_put_err;
 	} else if (err == LOCKED_PAGE) {
@@ -1475,40 +1475,40 @@ static struct page *__get_node_page(struct f2fs_sb_info *sbi, pgoff_t nid,
 	if (parent)
 		f2fs_ra_node_pages(parent, start + 1, MAX_RA_NODE);
 
-	lock_page(page);
+	folio_lock(folio);
 
-	if (unlikely(page->mapping != NODE_MAPPING(sbi))) {
-		f2fs_put_page(page, 1);
+	if (unlikely(folio->mapping != NODE_MAPPING(sbi))) {
+		f2fs_folio_put(folio, true);
 		goto repeat;
 	}
 
-	if (unlikely(!PageUptodate(page))) {
+	if (unlikely(!folio_test_uptodate(folio))) {
 		err = -EIO;
 		goto out_err;
 	}
 
-	if (!f2fs_inode_chksum_verify(sbi, page)) {
+	if (!f2fs_inode_chksum_verify(sbi, &folio->page)) {
 		err = -EFSBADCRC;
 		goto out_err;
 	}
 page_hit:
-	if (likely(nid == nid_of_node(page)))
-		return page;
+	if (likely(nid == nid_of_node(&folio->page)))
+		return &folio->page;
 
 	f2fs_warn(sbi, "inconsistent node block, nid:%lu, node_footer[nid:%u,ino:%u,ofs:%u,cpver:%llu,blkaddr:%u]",
-			  nid, nid_of_node(page), ino_of_node(page),
-			  ofs_of_node(page), cpver_of_node(page),
-			  next_blkaddr_of_node(page));
+			  nid, nid_of_node(&folio->page), ino_of_node(&folio->page),
+			  ofs_of_node(&folio->page), cpver_of_node(&folio->page),
+			  next_blkaddr_of_node(&folio->page));
 	set_sbi_flag(sbi, SBI_NEED_FSCK);
 	f2fs_handle_error(sbi, ERROR_INCONSISTENT_FOOTER);
 	err = -EFSCORRUPTED;
 out_err:
-	ClearPageUptodate(page);
+	folio_clear_uptodate(folio);
 out_put_err:
 	/* ENOENT comes from read_node_page which is not an error. */
 	if (err != -ENOENT)
-		f2fs_handle_page_eio(sbi, page_folio(page), NODE);
-	f2fs_put_page(page, 1);
+		f2fs_handle_page_eio(sbi, folio, NODE);
+	f2fs_folio_put(folio, true);
 	return ERR_PTR(err);
 }
 
-- 
2.47.2


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH 13/27] f2fs: Use a folio in do_write_page()
  2025-02-18  5:51 [PATCH 00/27] f2fs folio conversions for v6.15 Matthew Wilcox (Oracle)
                   ` (11 preceding siblings ...)
  2025-02-18  5:51 ` [PATCH 12/27] f2fs: Use a folio in __get_node_page() Matthew Wilcox (Oracle)
@ 2025-02-18  5:51 ` Matthew Wilcox (Oracle)
  2025-02-18  5:51 ` [PATCH 14/27] f2fs: Convert f2fs_write_end_io() to use a folio_iter Matthew Wilcox (Oracle)
                   ` (16 subsequent siblings)
  29 siblings, 0 replies; 41+ messages in thread
From: Matthew Wilcox (Oracle) @ 2025-02-18  5:51 UTC (permalink / raw)
  To: Jaegeuk Kim, Chao Yu
  Cc: Matthew Wilcox (Oracle), linux-f2fs-devel, linux-fsdevel

Convert fio->page to a folio then use it where folio APIs exist.
Removes a reference to page->mapping and a hidden call to
compound_head().

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/f2fs/segment.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index a29da14c5f19..088b4ad81771 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -3902,6 +3902,7 @@ static int log_type_to_seg_type(enum log_type type)
 
 static void do_write_page(struct f2fs_summary *sum, struct f2fs_io_info *fio)
 {
+	struct folio *folio = page_folio(fio->page);
 	enum log_type type = __get_segment_type(fio);
 	int seg_type = log_type_to_seg_type(type);
 	bool keep_order = (f2fs_lfs_mode(fio->sbi) &&
@@ -3912,9 +3913,9 @@ static void do_write_page(struct f2fs_summary *sum, struct f2fs_io_info *fio)
 
 	if (f2fs_allocate_data_block(fio->sbi, fio->page, fio->old_blkaddr,
 			&fio->new_blkaddr, sum, type, fio)) {
-		if (fscrypt_inode_uses_fs_layer_crypto(fio->page->mapping->host))
+		if (fscrypt_inode_uses_fs_layer_crypto(folio->mapping->host))
 			fscrypt_finalize_bounce_page(&fio->encrypted_page);
-		end_page_writeback(fio->page);
+		folio_end_writeback(folio);
 		if (f2fs_in_warm_node_list(fio->sbi, fio->page))
 			f2fs_del_fsync_node_entry(fio->sbi, fio->page);
 		goto out;
-- 
2.47.2


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH 14/27] f2fs: Convert f2fs_write_end_io() to use a folio_iter
  2025-02-18  5:51 [PATCH 00/27] f2fs folio conversions for v6.15 Matthew Wilcox (Oracle)
                   ` (12 preceding siblings ...)
  2025-02-18  5:51 ` [PATCH 13/27] f2fs: Use a folio in do_write_page() Matthew Wilcox (Oracle)
@ 2025-02-18  5:51 ` Matthew Wilcox (Oracle)
  2025-02-18  5:51 ` [PATCH 15/27] f2fs: Mark some functions as taking a const page pointer Matthew Wilcox (Oracle)
                   ` (15 subsequent siblings)
  29 siblings, 0 replies; 41+ messages in thread
From: Matthew Wilcox (Oracle) @ 2025-02-18  5:51 UTC (permalink / raw)
  To: Jaegeuk Kim, Chao Yu
  Cc: Matthew Wilcox (Oracle), linux-f2fs-devel, linux-fsdevel

Iterate over each folio in the bio instead of each page.
Follow the pattern in ext4 for handling bounce folios.  Removes
a few calls to compound_head() and references to page->mapping.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/f2fs/data.c | 36 +++++++++++++++++++++---------------
 1 file changed, 21 insertions(+), 15 deletions(-)

diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 24c5cb1f5ada..5ec4395ef06d 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -319,8 +319,7 @@ static void f2fs_read_end_io(struct bio *bio)
 static void f2fs_write_end_io(struct bio *bio)
 {
 	struct f2fs_sb_info *sbi;
-	struct bio_vec *bvec;
-	struct bvec_iter_all iter_all;
+	struct folio_iter fi;
 
 	iostat_update_and_unbind_ctx(bio);
 	sbi = bio->bi_private;
@@ -328,34 +327,41 @@ static void f2fs_write_end_io(struct bio *bio)
 	if (time_to_inject(sbi, FAULT_WRITE_IO))
 		bio->bi_status = BLK_STS_IOERR;
 
-	bio_for_each_segment_all(bvec, bio, iter_all) {
-		struct page *page = bvec->bv_page;
-		enum count_type type = WB_DATA_TYPE(page, false);
+	bio_for_each_folio_all(fi, bio) {
+		struct folio *folio = fi.folio;
+		enum count_type type;
 
-		fscrypt_finalize_bounce_page(&page);
+		if (fscrypt_is_bounce_folio(folio)) {
+			struct folio *io_folio = folio;
+
+			folio = fscrypt_pagecache_folio(io_folio);
+			fscrypt_free_bounce_page(&io_folio->page);
+		}
 
 #ifdef CONFIG_F2FS_FS_COMPRESSION
-		if (f2fs_is_compressed_page(page)) {
-			f2fs_compress_write_end_io(bio, page);
+		if (f2fs_is_compressed_page(&folio->page)) {
+			f2fs_compress_write_end_io(bio, &folio->page);
 			continue;
 		}
 #endif
 
+		type = WB_DATA_TYPE(&folio->page, false);
+
 		if (unlikely(bio->bi_status)) {
-			mapping_set_error(page->mapping, -EIO);
+			mapping_set_error(folio->mapping, -EIO);
 			if (type == F2FS_WB_CP_DATA)
 				f2fs_stop_checkpoint(sbi, true,
 						STOP_CP_REASON_WRITE_FAIL);
 		}
 
-		f2fs_bug_on(sbi, page->mapping == NODE_MAPPING(sbi) &&
-				page_folio(page)->index != nid_of_node(page));
+		f2fs_bug_on(sbi, folio->mapping == NODE_MAPPING(sbi) &&
+				folio->index != nid_of_node(&folio->page));
 
 		dec_page_count(sbi, type);
-		if (f2fs_in_warm_node_list(sbi, page))
-			f2fs_del_fsync_node_entry(sbi, page);
-		clear_page_private_gcing(page);
-		end_page_writeback(page);
+		if (f2fs_in_warm_node_list(sbi, &folio->page))
+			f2fs_del_fsync_node_entry(sbi, &folio->page);
+		clear_page_private_gcing(&folio->page);
+		folio_end_writeback(folio);
 	}
 	if (!get_pages(sbi, F2FS_WB_CP_DATA) &&
 				wq_has_sleeper(&sbi->cp_wait))
-- 
2.47.2


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH 15/27] f2fs: Mark some functions as taking a const page pointer
  2025-02-18  5:51 [PATCH 00/27] f2fs folio conversions for v6.15 Matthew Wilcox (Oracle)
                   ` (13 preceding siblings ...)
  2025-02-18  5:51 ` [PATCH 14/27] f2fs: Convert f2fs_write_end_io() to use a folio_iter Matthew Wilcox (Oracle)
@ 2025-02-18  5:51 ` Matthew Wilcox (Oracle)
  2025-02-18  5:51 ` [PATCH 16/27] f2fs: Convert f2fs_in_warm_node_list() to take a folio Matthew Wilcox (Oracle)
                   ` (14 subsequent siblings)
  29 siblings, 0 replies; 41+ messages in thread
From: Matthew Wilcox (Oracle) @ 2025-02-18  5:51 UTC (permalink / raw)
  To: Jaegeuk Kim, Chao Yu
  Cc: Matthew Wilcox (Oracle), linux-f2fs-devel, linux-fsdevel

The compiler can make some optimisations if we tell it that a function
call doesn't change this memory.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/f2fs/f2fs.h | 2 +-
 fs/f2fs/node.h | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index cf664ca38905..a941a0750712 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -2017,7 +2017,7 @@ static inline struct f2fs_checkpoint *F2FS_CKPT(struct f2fs_sb_info *sbi)
 	return (struct f2fs_checkpoint *)(sbi->ckpt);
 }
 
-static inline struct f2fs_node *F2FS_NODE(struct page *page)
+static inline struct f2fs_node *F2FS_NODE(const struct page *page)
 {
 	return (struct f2fs_node *)page_address(page);
 }
diff --git a/fs/f2fs/node.h b/fs/f2fs/node.h
index 6aea13024ac1..281d53c95c9a 100644
--- a/fs/f2fs/node.h
+++ b/fs/f2fs/node.h
@@ -248,7 +248,7 @@ static inline nid_t nid_of_node(struct page *node_page)
 	return le32_to_cpu(rn->footer.nid);
 }
 
-static inline unsigned int ofs_of_node(struct page *node_page)
+static inline unsigned int ofs_of_node(const struct page *node_page)
 {
 	struct f2fs_node *rn = F2FS_NODE(node_page);
 	unsigned flag = le32_to_cpu(rn->footer.flag);
@@ -342,7 +342,7 @@ static inline bool is_recoverable_dnode(struct page *page)
  *                 `- indirect node ((6 + 2N) + (N - 1)(N + 1))
  *                       `- direct node
  */
-static inline bool IS_DNODE(struct page *node_page)
+static inline bool IS_DNODE(const struct page *node_page)
 {
 	unsigned int ofs = ofs_of_node(node_page);
 
@@ -389,7 +389,7 @@ static inline nid_t get_nid(struct page *p, int off, bool i)
  *  - Mark cold data pages in page cache
  */
 
-static inline int is_node(struct page *page, int type)
+static inline int is_node(const struct page *page, int type)
 {
 	struct f2fs_node *rn = F2FS_NODE(page);
 	return le32_to_cpu(rn->footer.flag) & BIT(type);
-- 
2.47.2


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH 16/27] f2fs: Convert f2fs_in_warm_node_list() to take a folio
  2025-02-18  5:51 [PATCH 00/27] f2fs folio conversions for v6.15 Matthew Wilcox (Oracle)
                   ` (14 preceding siblings ...)
  2025-02-18  5:51 ` [PATCH 15/27] f2fs: Mark some functions as taking a const page pointer Matthew Wilcox (Oracle)
@ 2025-02-18  5:51 ` Matthew Wilcox (Oracle)
  2025-02-18  5:51 ` [PATCH 17/27] f2fs: Add f2fs_get_node_folio() Matthew Wilcox (Oracle)
                   ` (13 subsequent siblings)
  29 siblings, 0 replies; 41+ messages in thread
From: Matthew Wilcox (Oracle) @ 2025-02-18  5:51 UTC (permalink / raw)
  To: Jaegeuk Kim, Chao Yu
  Cc: Matthew Wilcox (Oracle), linux-f2fs-devel, linux-fsdevel

All its callers now have access to a folio, so pass it in.  Removes
an access to page->mapping.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/f2fs/data.c    | 2 +-
 fs/f2fs/f2fs.h    | 3 ++-
 fs/f2fs/node.c    | 8 ++++----
 fs/f2fs/segment.c | 2 +-
 4 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 5ec4395ef06d..d297e9ae6391 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -358,7 +358,7 @@ static void f2fs_write_end_io(struct bio *bio)
 				folio->index != nid_of_node(&folio->page));
 
 		dec_page_count(sbi, type);
-		if (f2fs_in_warm_node_list(sbi, &folio->page))
+		if (f2fs_in_warm_node_list(sbi, folio))
 			f2fs_del_fsync_node_entry(sbi, &folio->page);
 		clear_page_private_gcing(&folio->page);
 		folio_end_writeback(folio);
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index a941a0750712..bbaa61da83a8 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -3667,7 +3667,8 @@ struct node_info;
 
 int f2fs_check_nid_range(struct f2fs_sb_info *sbi, nid_t nid);
 bool f2fs_available_free_memory(struct f2fs_sb_info *sbi, int type);
-bool f2fs_in_warm_node_list(struct f2fs_sb_info *sbi, struct page *page);
+bool f2fs_in_warm_node_list(struct f2fs_sb_info *sbi,
+		const struct folio *folio);
 void f2fs_init_fsync_node_info(struct f2fs_sb_info *sbi);
 void f2fs_del_fsync_node_entry(struct f2fs_sb_info *sbi, struct page *page);
 void f2fs_reset_fsync_node_info(struct f2fs_sb_info *sbi);
diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index db97624e30b3..da28e295c701 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -310,10 +310,10 @@ static unsigned int __gang_lookup_nat_set(struct f2fs_nm_info *nm_i,
 							start, nr);
 }
 
-bool f2fs_in_warm_node_list(struct f2fs_sb_info *sbi, struct page *page)
+bool f2fs_in_warm_node_list(struct f2fs_sb_info *sbi, const struct folio *folio)
 {
-	return NODE_MAPPING(sbi) == page->mapping &&
-			IS_DNODE(page) && is_cold_node(page);
+	return NODE_MAPPING(sbi) == folio->mapping &&
+			IS_DNODE(&folio->page) && is_cold_node(&folio->page);
 }
 
 void f2fs_init_fsync_node_info(struct f2fs_sb_info *sbi)
@@ -1694,7 +1694,7 @@ static int __write_node_page(struct page *page, bool atomic, bool *submitted,
 		fio.op_flags |= REQ_PREFLUSH | REQ_FUA;
 
 	/* should add to global list before clearing PAGECACHE status */
-	if (f2fs_in_warm_node_list(sbi, page)) {
+	if (f2fs_in_warm_node_list(sbi, folio)) {
 		seq = f2fs_add_fsync_node_entry(sbi, page);
 		if (seq_id)
 			*seq_id = seq;
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 088b4ad81771..0c5fdb58ade3 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -3916,7 +3916,7 @@ static void do_write_page(struct f2fs_summary *sum, struct f2fs_io_info *fio)
 		if (fscrypt_inode_uses_fs_layer_crypto(folio->mapping->host))
 			fscrypt_finalize_bounce_page(&fio->encrypted_page);
 		folio_end_writeback(folio);
-		if (f2fs_in_warm_node_list(fio->sbi, fio->page))
+		if (f2fs_in_warm_node_list(fio->sbi, folio))
 			f2fs_del_fsync_node_entry(fio->sbi, fio->page);
 		goto out;
 	}
-- 
2.47.2


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH 17/27] f2fs: Add f2fs_get_node_folio()
  2025-02-18  5:51 [PATCH 00/27] f2fs folio conversions for v6.15 Matthew Wilcox (Oracle)
                   ` (15 preceding siblings ...)
  2025-02-18  5:51 ` [PATCH 16/27] f2fs: Convert f2fs_in_warm_node_list() to take a folio Matthew Wilcox (Oracle)
@ 2025-02-18  5:51 ` Matthew Wilcox (Oracle)
  2025-03-01  1:15   ` Chao Yu
  2025-02-18  5:51 ` [PATCH 18/27] f2fs: Use a folio throughout f2fs_truncate_inode_blocks() Matthew Wilcox (Oracle)
                   ` (12 subsequent siblings)
  29 siblings, 1 reply; 41+ messages in thread
From: Matthew Wilcox (Oracle) @ 2025-02-18  5:51 UTC (permalink / raw)
  To: Jaegeuk Kim, Chao Yu
  Cc: Matthew Wilcox (Oracle), linux-f2fs-devel, linux-fsdevel

Change __get_node_page() to return a folio and convert back to a page in
f2fs_get_node_page() and f2fs_get_node_page_ra().

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/f2fs/f2fs.h |  1 +
 fs/f2fs/node.c | 18 +++++++++++++-----
 2 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index bbaa61da83a8..8f23bb082c6f 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -3689,6 +3689,7 @@ struct page *f2fs_new_inode_page(struct inode *inode);
 struct page *f2fs_new_node_page(struct dnode_of_data *dn, unsigned int ofs);
 void f2fs_ra_node_page(struct f2fs_sb_info *sbi, nid_t nid);
 struct page *f2fs_get_node_page(struct f2fs_sb_info *sbi, pgoff_t nid);
+struct folio *f2fs_get_node_folio(struct f2fs_sb_info *sbi, pgoff_t nid);
 struct page *f2fs_get_node_page_ra(struct page *parent, int start);
 int f2fs_move_node_page(struct page *node_page, int gc_type);
 void f2fs_flush_inline_data(struct f2fs_sb_info *sbi);
diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index da28e295c701..2d161ddda9c3 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -1449,7 +1449,7 @@ void f2fs_ra_node_page(struct f2fs_sb_info *sbi, nid_t nid)
 	f2fs_put_page(apage, err ? 1 : 0);
 }
 
-static struct page *__get_node_page(struct f2fs_sb_info *sbi, pgoff_t nid,
+static struct folio *__get_node_folio(struct f2fs_sb_info *sbi, pgoff_t nid,
 					struct page *parent, int start)
 {
 	struct folio *folio;
@@ -1462,7 +1462,7 @@ static struct page *__get_node_page(struct f2fs_sb_info *sbi, pgoff_t nid,
 repeat:
 	folio = f2fs_grab_cache_folio(NODE_MAPPING(sbi), nid, false);
 	if (IS_ERR(folio))
-		return ERR_CAST(folio);
+		return folio;
 
 	err = read_node_page(&folio->page, 0);
 	if (err < 0) {
@@ -1493,7 +1493,7 @@ static struct page *__get_node_page(struct f2fs_sb_info *sbi, pgoff_t nid,
 	}
 page_hit:
 	if (likely(nid == nid_of_node(&folio->page)))
-		return &folio->page;
+		return folio;
 
 	f2fs_warn(sbi, "inconsistent node block, nid:%lu, node_footer[nid:%u,ino:%u,ofs:%u,cpver:%llu,blkaddr:%u]",
 			  nid, nid_of_node(&folio->page), ino_of_node(&folio->page),
@@ -1512,17 +1512,25 @@ static struct page *__get_node_page(struct f2fs_sb_info *sbi, pgoff_t nid,
 	return ERR_PTR(err);
 }
 
+struct folio *f2fs_get_node_folio(struct f2fs_sb_info *sbi, pgoff_t nid)
+{
+	return __get_node_folio(sbi, nid, NULL, 0);
+}
+
 struct page *f2fs_get_node_page(struct f2fs_sb_info *sbi, pgoff_t nid)
 {
-	return __get_node_page(sbi, nid, NULL, 0);
+	struct folio *folio = __get_node_folio(sbi, nid, NULL, 0);
+
+	return &folio->page;
 }
 
 struct page *f2fs_get_node_page_ra(struct page *parent, int start)
 {
 	struct f2fs_sb_info *sbi = F2FS_P_SB(parent);
 	nid_t nid = get_nid(parent, start, false);
+	struct folio *folio = __get_node_folio(sbi, nid, parent, start);
 
-	return __get_node_page(sbi, nid, parent, start);
+	return &folio->page;
 }
 
 static void flush_inline_data(struct f2fs_sb_info *sbi, nid_t ino)
-- 
2.47.2


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH 18/27] f2fs: Use a folio throughout f2fs_truncate_inode_blocks()
  2025-02-18  5:51 [PATCH 00/27] f2fs folio conversions for v6.15 Matthew Wilcox (Oracle)
                   ` (16 preceding siblings ...)
  2025-02-18  5:51 ` [PATCH 17/27] f2fs: Add f2fs_get_node_folio() Matthew Wilcox (Oracle)
@ 2025-02-18  5:51 ` Matthew Wilcox (Oracle)
  2025-02-18  5:51 ` [PATCH 19/27] f2fs: Use a folio throughout __get_meta_page() Matthew Wilcox (Oracle)
                   ` (11 subsequent siblings)
  29 siblings, 0 replies; 41+ messages in thread
From: Matthew Wilcox (Oracle) @ 2025-02-18  5:51 UTC (permalink / raw)
  To: Jaegeuk Kim, Chao Yu
  Cc: Matthew Wilcox (Oracle), linux-f2fs-devel, linux-fsdevel

Use f2fs_get_node_folio() to get a folio and use it throughout.  Remove a
few calls to compound_head() and a reference to page->mapping.

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

diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index 2d161ddda9c3..e1ed7ccfb690 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -1130,7 +1130,7 @@ int f2fs_truncate_inode_blocks(struct inode *inode, pgoff_t from)
 	unsigned int nofs = 0;
 	struct f2fs_inode *ri;
 	struct dnode_of_data dn;
-	struct page *page;
+	struct folio *folio;
 
 	trace_f2fs_truncate_inode_blocks_enter(inode, from);
 
@@ -1140,16 +1140,16 @@ int f2fs_truncate_inode_blocks(struct inode *inode, pgoff_t from)
 		return level;
 	}
 
-	page = f2fs_get_node_page(sbi, inode->i_ino);
-	if (IS_ERR(page)) {
-		trace_f2fs_truncate_inode_blocks_exit(inode, PTR_ERR(page));
-		return PTR_ERR(page);
+	folio = f2fs_get_node_folio(sbi, inode->i_ino);
+	if (IS_ERR(folio)) {
+		trace_f2fs_truncate_inode_blocks_exit(inode, PTR_ERR(folio));
+		return PTR_ERR(folio);
 	}
 
-	set_new_dnode(&dn, inode, page, NULL, 0);
-	unlock_page(page);
+	set_new_dnode(&dn, inode, &folio->page, NULL, 0);
+	folio_unlock(folio);
 
-	ri = F2FS_INODE(page);
+	ri = F2FS_INODE(&folio->page);
 	switch (level) {
 	case 0:
 	case 1:
@@ -1178,7 +1178,7 @@ int f2fs_truncate_inode_blocks(struct inode *inode, pgoff_t from)
 
 skip_partial:
 	while (cont) {
-		dn.nid = get_nid(page, offset[0], true);
+		dn.nid = get_nid(&folio->page, offset[0], true);
 		switch (offset[0]) {
 		case NODE_DIR1_BLOCK:
 		case NODE_DIR2_BLOCK:
@@ -1199,7 +1199,7 @@ int f2fs_truncate_inode_blocks(struct inode *inode, pgoff_t from)
 			BUG();
 		}
 		if (err == -ENOENT) {
-			set_sbi_flag(F2FS_P_SB(page), SBI_NEED_FSCK);
+			set_sbi_flag(F2FS_F_SB(folio), SBI_NEED_FSCK);
 			f2fs_handle_error(sbi, ERROR_INVALID_BLKADDR);
 			f2fs_err_ratelimited(sbi,
 				"truncate node fail, ino:%lu, nid:%u, "
@@ -1210,18 +1210,18 @@ int f2fs_truncate_inode_blocks(struct inode *inode, pgoff_t from)
 		}
 		if (err < 0)
 			goto fail;
-		if (offset[1] == 0 && get_nid(page, offset[0], true)) {
-			lock_page(page);
-			BUG_ON(page->mapping != NODE_MAPPING(sbi));
-			set_nid(page, offset[0], 0, true);
-			unlock_page(page);
+		if (offset[1] == 0 && get_nid(&folio->page, offset[0], true)) {
+			folio_lock(folio);
+			BUG_ON(folio->mapping != NODE_MAPPING(sbi));
+			set_nid(&folio->page, offset[0], 0, true);
+			folio_unlock(folio);
 		}
 		offset[1] = 0;
 		offset[0]++;
 		nofs += err;
 	}
 fail:
-	f2fs_put_page(page, 0);
+	f2fs_folio_put(folio, false);
 	trace_f2fs_truncate_inode_blocks_exit(inode, err);
 	return err > 0 ? 0 : err;
 }
-- 
2.47.2


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH 19/27] f2fs: Use a folio throughout __get_meta_page()
  2025-02-18  5:51 [PATCH 00/27] f2fs folio conversions for v6.15 Matthew Wilcox (Oracle)
                   ` (17 preceding siblings ...)
  2025-02-18  5:51 ` [PATCH 18/27] f2fs: Use a folio throughout f2fs_truncate_inode_blocks() Matthew Wilcox (Oracle)
@ 2025-02-18  5:51 ` Matthew Wilcox (Oracle)
  2025-02-18  5:51 ` [PATCH 20/27] f2fs: Hoist the page_folio() call to the start of f2fs_merge_page_bio() Matthew Wilcox (Oracle)
                   ` (10 subsequent siblings)
  29 siblings, 0 replies; 41+ messages in thread
From: Matthew Wilcox (Oracle) @ 2025-02-18  5:51 UTC (permalink / raw)
  To: Jaegeuk Kim, Chao Yu
  Cc: Matthew Wilcox (Oracle), linux-f2fs-devel, linux-fsdevel

Use f2fs_grab_cache_folio() to get a folio and use it throughout,
removing seven calls to compound_head() and a reference to page->mapping.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/f2fs/checkpoint.c | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
index bd890738b94d..75b7196d2c81 100644
--- a/fs/f2fs/checkpoint.c
+++ b/fs/f2fs/checkpoint.c
@@ -58,7 +58,7 @@ static struct page *__get_meta_page(struct f2fs_sb_info *sbi, pgoff_t index,
 							bool is_meta)
 {
 	struct address_space *mapping = META_MAPPING(sbi);
-	struct page *page;
+	struct folio *folio;
 	struct f2fs_io_info fio = {
 		.sbi = sbi,
 		.type = META,
@@ -74,37 +74,37 @@ static struct page *__get_meta_page(struct f2fs_sb_info *sbi, pgoff_t index,
 	if (unlikely(!is_meta))
 		fio.op_flags &= ~REQ_META;
 repeat:
-	page = f2fs_grab_cache_page(mapping, index, false);
-	if (!page) {
+	folio = f2fs_grab_cache_folio(mapping, index, false);
+	if (IS_ERR(folio)) {
 		cond_resched();
 		goto repeat;
 	}
-	if (PageUptodate(page))
+	if (folio_test_uptodate(folio))
 		goto out;
 
-	fio.page = page;
+	fio.page = &folio->page;
 
 	err = f2fs_submit_page_bio(&fio);
 	if (err) {
-		f2fs_put_page(page, 1);
+		f2fs_folio_put(folio, true);
 		return ERR_PTR(err);
 	}
 
 	f2fs_update_iostat(sbi, NULL, FS_META_READ_IO, F2FS_BLKSIZE);
 
-	lock_page(page);
-	if (unlikely(page->mapping != mapping)) {
-		f2fs_put_page(page, 1);
+	folio_lock(folio);
+	if (unlikely(folio->mapping != mapping)) {
+		f2fs_folio_put(folio, true);
 		goto repeat;
 	}
 
-	if (unlikely(!PageUptodate(page))) {
-		f2fs_handle_page_eio(sbi, page_folio(page), META);
-		f2fs_put_page(page, 1);
+	if (unlikely(!folio_test_uptodate(folio))) {
+		f2fs_handle_page_eio(sbi, folio, META);
+		f2fs_folio_put(folio, true);
 		return ERR_PTR(-EIO);
 	}
 out:
-	return page;
+	return &folio->page;
 }
 
 struct page *f2fs_get_meta_page(struct f2fs_sb_info *sbi, pgoff_t index)
-- 
2.47.2


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH 20/27] f2fs: Hoist the page_folio() call to the start of f2fs_merge_page_bio()
  2025-02-18  5:51 [PATCH 00/27] f2fs folio conversions for v6.15 Matthew Wilcox (Oracle)
                   ` (18 preceding siblings ...)
  2025-02-18  5:51 ` [PATCH 19/27] f2fs: Use a folio throughout __get_meta_page() Matthew Wilcox (Oracle)
@ 2025-02-18  5:51 ` Matthew Wilcox (Oracle)
  2025-02-28  7:25   ` Chao Yu
  2025-02-18  5:51 ` [PATCH 21/27] f2fs: Add f2fs_get_read_data_folio() Matthew Wilcox (Oracle)
                   ` (9 subsequent siblings)
  29 siblings, 1 reply; 41+ messages in thread
From: Matthew Wilcox (Oracle) @ 2025-02-18  5:51 UTC (permalink / raw)
  To: Jaegeuk Kim, Chao Yu
  Cc: Matthew Wilcox (Oracle), linux-f2fs-devel, linux-fsdevel

Remove one call to compound_head() and a reference to page->mapping
by calling page_folio() early on.

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

diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index d297e9ae6391..fe7fa08b20c7 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -888,6 +888,7 @@ int f2fs_merge_page_bio(struct f2fs_io_info *fio)
 	struct bio *bio = *fio->bio;
 	struct page *page = fio->encrypted_page ?
 			fio->encrypted_page : fio->page;
+	struct folio *folio = page_folio(fio->page);
 
 	if (!f2fs_is_valid_blkaddr(fio->sbi, fio->new_blkaddr,
 			__is_meta_io(fio) ? META_GENERIC : DATA_GENERIC))
@@ -901,8 +902,8 @@ int f2fs_merge_page_bio(struct f2fs_io_info *fio)
 alloc_new:
 	if (!bio) {
 		bio = __bio_alloc(fio, BIO_MAX_VECS);
-		f2fs_set_bio_crypt_ctx(bio, fio->page->mapping->host,
-				page_folio(fio->page)->index, fio, GFP_NOIO);
+		f2fs_set_bio_crypt_ctx(bio, folio->mapping->host,
+				folio->index, fio, GFP_NOIO);
 
 		add_bio_entry(fio->sbi, bio, page, fio->temp);
 	} else {
@@ -911,8 +912,7 @@ int f2fs_merge_page_bio(struct f2fs_io_info *fio)
 	}
 
 	if (fio->io_wbc)
-		wbc_account_cgroup_owner(fio->io_wbc, page_folio(fio->page),
-					 PAGE_SIZE);
+		wbc_account_cgroup_owner(fio->io_wbc, folio, folio_size(folio));
 
 	inc_page_count(fio->sbi, WB_DATA_TYPE(page, false));
 
-- 
2.47.2


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH 21/27] f2fs: Add f2fs_get_read_data_folio()
  2025-02-18  5:51 [PATCH 00/27] f2fs folio conversions for v6.15 Matthew Wilcox (Oracle)
                   ` (19 preceding siblings ...)
  2025-02-18  5:51 ` [PATCH 20/27] f2fs: Hoist the page_folio() call to the start of f2fs_merge_page_bio() Matthew Wilcox (Oracle)
@ 2025-02-18  5:51 ` Matthew Wilcox (Oracle)
  2025-02-28  7:37   ` Chao Yu
  2025-02-18  5:51 ` [PATCH 22/27] f2fs: Add f2fs_get_lock_data_folio() Matthew Wilcox (Oracle)
                   ` (8 subsequent siblings)
  29 siblings, 1 reply; 41+ messages in thread
From: Matthew Wilcox (Oracle) @ 2025-02-18  5:51 UTC (permalink / raw)
  To: Jaegeuk Kim, Chao Yu
  Cc: Matthew Wilcox (Oracle), linux-f2fs-devel, linux-fsdevel

Convert f2fs_get_read_data_page() into f2fs_get_read_data_folio() and
add a compatibility wrapper.  Saves seven hidden calls to compound_head().

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/f2fs/data.c | 35 +++++++++++++++++------------------
 fs/f2fs/f2fs.h | 14 ++++++++++++--
 2 files changed, 29 insertions(+), 20 deletions(-)

diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index fe7fa08b20c7..f0747c7f669d 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -1203,18 +1203,17 @@ int f2fs_reserve_block(struct dnode_of_data *dn, pgoff_t index)
 	return err;
 }
 
-struct page *f2fs_get_read_data_page(struct inode *inode, pgoff_t index,
-				     blk_opf_t op_flags, bool for_write,
-				     pgoff_t *next_pgofs)
+struct folio *f2fs_get_read_data_folio(struct inode *inode, pgoff_t index,
+		blk_opf_t op_flags, bool for_write, pgoff_t *next_pgofs)
 {
 	struct address_space *mapping = inode->i_mapping;
 	struct dnode_of_data dn;
-	struct page *page;
+	struct folio *folio;
 	int err;
 
-	page = f2fs_grab_cache_page(mapping, index, for_write);
-	if (!page)
-		return ERR_PTR(-ENOMEM);
+	folio = f2fs_grab_cache_folio(mapping, index, for_write);
+	if (IS_ERR(folio))
+		return folio;
 
 	if (f2fs_lookup_read_extent_cache_block(inode, index,
 						&dn.data_blkaddr)) {
@@ -1249,9 +1248,9 @@ struct page *f2fs_get_read_data_page(struct inode *inode, pgoff_t index,
 		goto put_err;
 	}
 got_it:
-	if (PageUptodate(page)) {
-		unlock_page(page);
-		return page;
+	if (folio_test_uptodate(folio)) {
+		folio_unlock(folio);
+		return folio;
 	}
 
 	/*
@@ -1262,21 +1261,21 @@ struct page *f2fs_get_read_data_page(struct inode *inode, pgoff_t index,
 	 * f2fs_init_inode_metadata.
 	 */
 	if (dn.data_blkaddr == NEW_ADDR) {
-		zero_user_segment(page, 0, PAGE_SIZE);
-		if (!PageUptodate(page))
-			SetPageUptodate(page);
-		unlock_page(page);
-		return page;
+		folio_zero_segment(folio, 0, folio_size(folio));
+		if (!folio_test_uptodate(folio))
+			folio_mark_uptodate(folio);
+		folio_unlock(folio);
+		return folio;
 	}
 
-	err = f2fs_submit_page_read(inode, page_folio(page), dn.data_blkaddr,
+	err = f2fs_submit_page_read(inode, folio, dn.data_blkaddr,
 						op_flags, for_write);
 	if (err)
 		goto put_err;
-	return page;
+	return folio;
 
 put_err:
-	f2fs_put_page(page, 1);
+	f2fs_folio_put(folio, true);
 	return ERR_PTR(err);
 }
 
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 8f23bb082c6f..3e02df63499e 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -3895,8 +3895,8 @@ int f2fs_reserve_new_blocks(struct dnode_of_data *dn, blkcnt_t count);
 int f2fs_reserve_new_block(struct dnode_of_data *dn);
 int f2fs_get_block_locked(struct dnode_of_data *dn, pgoff_t index);
 int f2fs_reserve_block(struct dnode_of_data *dn, pgoff_t index);
-struct page *f2fs_get_read_data_page(struct inode *inode, pgoff_t index,
-			blk_opf_t op_flags, bool for_write, pgoff_t *next_pgofs);
+struct folio *f2fs_get_read_data_folio(struct inode *inode, pgoff_t index,
+		blk_opf_t op_flags, bool for_write, pgoff_t *next_pgofs);
 struct page *f2fs_find_data_page(struct inode *inode, pgoff_t index,
 							pgoff_t *next_pgofs);
 struct page *f2fs_get_lock_data_page(struct inode *inode, pgoff_t index,
@@ -3926,6 +3926,16 @@ int f2fs_init_post_read_wq(struct f2fs_sb_info *sbi);
 void f2fs_destroy_post_read_wq(struct f2fs_sb_info *sbi);
 extern const struct iomap_ops f2fs_iomap_ops;
 
+static inline struct page *f2fs_get_read_data_page(struct inode *inode,
+		pgoff_t index, blk_opf_t op_flags, bool for_write,
+		pgoff_t *next_pgofs)
+{
+	struct folio *folio = f2fs_get_read_data_folio(inode, index, op_flags,
+			for_write, next_pgofs);
+
+	return &folio->page;
+}
+
 /*
  * gc.c
  */
-- 
2.47.2


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH 22/27] f2fs: Add f2fs_get_lock_data_folio()
  2025-02-18  5:51 [PATCH 00/27] f2fs folio conversions for v6.15 Matthew Wilcox (Oracle)
                   ` (20 preceding siblings ...)
  2025-02-18  5:51 ` [PATCH 21/27] f2fs: Add f2fs_get_read_data_folio() Matthew Wilcox (Oracle)
@ 2025-02-18  5:51 ` Matthew Wilcox (Oracle)
  2025-02-28  7:37   ` Chao Yu
  2025-02-18  5:51 ` [PATCH 23/27] f2fs: Convert move_data_page() to use a folio Matthew Wilcox (Oracle)
                   ` (7 subsequent siblings)
  29 siblings, 1 reply; 41+ messages in thread
From: Matthew Wilcox (Oracle) @ 2025-02-18  5:51 UTC (permalink / raw)
  To: Jaegeuk Kim, Chao Yu
  Cc: Matthew Wilcox (Oracle), linux-f2fs-devel, linux-fsdevel

Convert f2fs_get_lock_data_page() to f2fs_get_lock_data_folio() and
add a compatibility wrapper.  Removes three hidden calls to
compound_head().

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/f2fs/data.c | 18 +++++++++---------
 fs/f2fs/f2fs.h | 10 +++++++++-
 2 files changed, 18 insertions(+), 10 deletions(-)

diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index f0747c7f669d..e891c95bc525 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -1310,23 +1310,23 @@ struct page *f2fs_find_data_page(struct inode *inode, pgoff_t index,
  * Because, the callers, functions in dir.c and GC, should be able to know
  * whether this page exists or not.
  */
-struct page *f2fs_get_lock_data_page(struct inode *inode, pgoff_t index,
+struct folio *f2fs_get_lock_data_folio(struct inode *inode, pgoff_t index,
 							bool for_write)
 {
 	struct address_space *mapping = inode->i_mapping;
-	struct page *page;
+	struct folio *folio;
 
-	page = f2fs_get_read_data_page(inode, index, 0, for_write, NULL);
-	if (IS_ERR(page))
-		return page;
+	folio = f2fs_get_read_data_folio(inode, index, 0, for_write, NULL);
+	if (IS_ERR(folio))
+		return folio;
 
 	/* wait for read completion */
-	lock_page(page);
-	if (unlikely(page->mapping != mapping || !PageUptodate(page))) {
-		f2fs_put_page(page, 1);
+	folio_lock(folio);
+	if (unlikely(folio->mapping != mapping || !folio_test_uptodate(folio))) {
+		f2fs_folio_put(folio, true);
 		return ERR_PTR(-EIO);
 	}
-	return page;
+	return folio;
 }
 
 /*
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 3e02df63499e..c78ba3c7d642 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -3899,7 +3899,7 @@ struct folio *f2fs_get_read_data_folio(struct inode *inode, pgoff_t index,
 		blk_opf_t op_flags, bool for_write, pgoff_t *next_pgofs);
 struct page *f2fs_find_data_page(struct inode *inode, pgoff_t index,
 							pgoff_t *next_pgofs);
-struct page *f2fs_get_lock_data_page(struct inode *inode, pgoff_t index,
+struct folio *f2fs_get_lock_data_folio(struct inode *inode, pgoff_t index,
 			bool for_write);
 struct page *f2fs_get_new_data_page(struct inode *inode,
 			struct page *ipage, pgoff_t index, bool new_i_size);
@@ -3936,6 +3936,14 @@ static inline struct page *f2fs_get_read_data_page(struct inode *inode,
 	return &folio->page;
 }
 
+static inline struct page *f2fs_get_lock_data_page(struct inode *inode,
+		pgoff_t index, bool for_write)
+{
+	struct folio *folio = f2fs_get_lock_data_folio(inode, index, for_write);
+
+	return &folio->page;
+}
+
 /*
  * gc.c
  */
-- 
2.47.2


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH 23/27] f2fs: Convert move_data_page() to use a folio
  2025-02-18  5:51 [PATCH 00/27] f2fs folio conversions for v6.15 Matthew Wilcox (Oracle)
                   ` (21 preceding siblings ...)
  2025-02-18  5:51 ` [PATCH 22/27] f2fs: Add f2fs_get_lock_data_folio() Matthew Wilcox (Oracle)
@ 2025-02-18  5:51 ` Matthew Wilcox (Oracle)
  2025-02-18  5:51 ` [PATCH 24/27] f2fs: Convert truncate_partial_data_page() " Matthew Wilcox (Oracle)
                   ` (6 subsequent siblings)
  29 siblings, 0 replies; 41+ messages in thread
From: Matthew Wilcox (Oracle) @ 2025-02-18  5:51 UTC (permalink / raw)
  To: Jaegeuk Kim, Chao Yu
  Cc: Matthew Wilcox (Oracle), linux-f2fs-devel, linux-fsdevel

Fetch a folio from the page cache and use it throughout, saving
eight hidden calls to compound_head().

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/f2fs/gc.c | 34 +++++++++++++++++-----------------
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c
index faf9fa1c804d..d0fffa2bd9f0 100644
--- a/fs/f2fs/gc.c
+++ b/fs/f2fs/gc.c
@@ -1449,14 +1449,14 @@ static int move_data_block(struct inode *inode, block_t bidx,
 }
 
 static int move_data_page(struct inode *inode, block_t bidx, int gc_type,
-							unsigned int segno, int off)
+						unsigned int segno, int off)
 {
-	struct page *page;
+	struct folio *folio;
 	int err = 0;
 
-	page = f2fs_get_lock_data_page(inode, bidx, true);
-	if (IS_ERR(page))
-		return PTR_ERR(page);
+	folio = f2fs_get_lock_data_folio(inode, bidx, true);
+	if (IS_ERR(folio))
+		return PTR_ERR(folio);
 
 	if (!check_valid_map(F2FS_I_SB(inode), segno, off)) {
 		err = -ENOENT;
@@ -1468,12 +1468,12 @@ static int move_data_page(struct inode *inode, block_t bidx, int gc_type,
 		goto out;
 
 	if (gc_type == BG_GC) {
-		if (folio_test_writeback(page_folio(page))) {
+		if (folio_test_writeback(folio)) {
 			err = -EAGAIN;
 			goto out;
 		}
-		set_page_dirty(page);
-		set_page_private_gcing(page);
+		folio_mark_dirty(folio);
+		set_page_private_gcing(&folio->page);
 	} else {
 		struct f2fs_io_info fio = {
 			.sbi = F2FS_I_SB(inode),
@@ -1483,37 +1483,37 @@ static int move_data_page(struct inode *inode, block_t bidx, int gc_type,
 			.op = REQ_OP_WRITE,
 			.op_flags = REQ_SYNC,
 			.old_blkaddr = NULL_ADDR,
-			.page = page,
+			.page = &folio->page,
 			.encrypted_page = NULL,
 			.need_lock = LOCK_REQ,
 			.io_type = FS_GC_DATA_IO,
 		};
-		bool is_dirty = PageDirty(page);
+		bool is_dirty = folio_test_dirty(folio);
 
 retry:
-		f2fs_wait_on_page_writeback(page, DATA, true, true);
+		f2fs_folio_wait_writeback(folio, DATA, true, true);
 
-		set_page_dirty(page);
-		if (clear_page_dirty_for_io(page)) {
+		folio_mark_dirty(folio);
+		if (folio_clear_dirty_for_io(folio)) {
 			inode_dec_dirty_pages(inode);
 			f2fs_remove_dirty_inode(inode);
 		}
 
-		set_page_private_gcing(page);
+		set_page_private_gcing(&folio->page);
 
 		err = f2fs_do_write_data_page(&fio);
 		if (err) {
-			clear_page_private_gcing(page);
+			clear_page_private_gcing(&folio->page);
 			if (err == -ENOMEM) {
 				memalloc_retry_wait(GFP_NOFS);
 				goto retry;
 			}
 			if (is_dirty)
-				set_page_dirty(page);
+				folio_mark_dirty(folio);
 		}
 	}
 out:
-	f2fs_put_page(page, 1);
+	f2fs_folio_put(folio, true);
 	return err;
 }
 
-- 
2.47.2


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH 24/27] f2fs: Convert truncate_partial_data_page() to use a folio
  2025-02-18  5:51 [PATCH 00/27] f2fs folio conversions for v6.15 Matthew Wilcox (Oracle)
                   ` (22 preceding siblings ...)
  2025-02-18  5:51 ` [PATCH 23/27] f2fs: Convert move_data_page() to use a folio Matthew Wilcox (Oracle)
@ 2025-02-18  5:51 ` Matthew Wilcox (Oracle)
  2025-02-18  5:51 ` [PATCH 25/27] f2fs: Convert gc_data_segment() " Matthew Wilcox (Oracle)
                   ` (5 subsequent siblings)
  29 siblings, 0 replies; 41+ messages in thread
From: Matthew Wilcox (Oracle) @ 2025-02-18  5:51 UTC (permalink / raw)
  To: Jaegeuk Kim, Chao Yu
  Cc: Matthew Wilcox (Oracle), linux-f2fs-devel, linux-fsdevel

Retrieve a folio from the page cache and use it throughout.
Saves five hidden calls to compound_head().

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/f2fs/file.c | 24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index f2f298c75921..db2778758dda 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -707,31 +707,33 @@ static int truncate_partial_data_page(struct inode *inode, u64 from,
 	loff_t offset = from & (PAGE_SIZE - 1);
 	pgoff_t index = from >> PAGE_SHIFT;
 	struct address_space *mapping = inode->i_mapping;
-	struct page *page;
+	struct folio *folio;
 
 	if (!offset && !cache_only)
 		return 0;
 
 	if (cache_only) {
-		page = find_lock_page(mapping, index);
-		if (page && PageUptodate(page))
+		folio = filemap_lock_folio(mapping, index);
+		if (IS_ERR(folio))
+		       return 0;
+		if (folio_test_uptodate(folio))
 			goto truncate_out;
-		f2fs_put_page(page, 1);
+		f2fs_folio_put(folio, true);
 		return 0;
 	}
 
-	page = f2fs_get_lock_data_page(inode, index, true);
-	if (IS_ERR(page))
-		return PTR_ERR(page) == -ENOENT ? 0 : PTR_ERR(page);
+	folio = f2fs_get_lock_data_folio(inode, index, true);
+	if (IS_ERR(folio))
+		return PTR_ERR(folio) == -ENOENT ? 0 : PTR_ERR(folio);
 truncate_out:
-	f2fs_wait_on_page_writeback(page, DATA, true, true);
-	zero_user(page, offset, PAGE_SIZE - offset);
+	f2fs_folio_wait_writeback(folio, DATA, true, true);
+	folio_zero_segment(folio, offset, folio_size(folio));
 
 	/* An encrypted inode should have a key and truncate the last page. */
 	f2fs_bug_on(F2FS_I_SB(inode), cache_only && IS_ENCRYPTED(inode));
 	if (!cache_only)
-		set_page_dirty(page);
-	f2fs_put_page(page, 1);
+		folio_mark_dirty(folio);
+	f2fs_folio_put(folio, true);
 	return 0;
 }
 
-- 
2.47.2


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH 25/27] f2fs: Convert gc_data_segment() to use a folio
  2025-02-18  5:51 [PATCH 00/27] f2fs folio conversions for v6.15 Matthew Wilcox (Oracle)
                   ` (23 preceding siblings ...)
  2025-02-18  5:51 ` [PATCH 24/27] f2fs: Convert truncate_partial_data_page() " Matthew Wilcox (Oracle)
@ 2025-02-18  5:51 ` Matthew Wilcox (Oracle)
  2025-02-18  5:52 ` [PATCH 26/27] f2fs: Add f2fs_find_data_folio() Matthew Wilcox (Oracle)
                   ` (4 subsequent siblings)
  29 siblings, 0 replies; 41+ messages in thread
From: Matthew Wilcox (Oracle) @ 2025-02-18  5:51 UTC (permalink / raw)
  To: Jaegeuk Kim, Chao Yu
  Cc: Matthew Wilcox (Oracle), linux-f2fs-devel, linux-fsdevel

Use f2fs_get_read_data_folio() instead of f2fs_get_read_data_page().
Saves a hidden call to compound_head() in f2fs_put_page().

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

diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c
index d0fffa2bd9f0..2b8f9239bede 100644
--- a/fs/f2fs/gc.c
+++ b/fs/f2fs/gc.c
@@ -1542,7 +1542,6 @@ static int gc_data_segment(struct f2fs_sb_info *sbi, struct f2fs_summary *sum,
 	entry = sum;
 
 	for (off = 0; off < usable_blks_in_seg; off++, entry++) {
-		struct page *data_page;
 		struct inode *inode;
 		struct node_info dni; /* dnode info for the data */
 		unsigned int ofs_in_node, nofs;
@@ -1585,6 +1584,7 @@ static int gc_data_segment(struct f2fs_sb_info *sbi, struct f2fs_summary *sum,
 		ofs_in_node = le16_to_cpu(entry->ofs_in_node);
 
 		if (phase == 3) {
+			struct folio *data_folio;
 			int err;
 
 			inode = f2fs_iget(sb, dni.ino);
@@ -1635,15 +1635,15 @@ static int gc_data_segment(struct f2fs_sb_info *sbi, struct f2fs_summary *sum,
 				continue;
 			}
 
-			data_page = f2fs_get_read_data_page(inode, start_bidx,
+			data_folio = f2fs_get_read_data_folio(inode, start_bidx,
 							REQ_RAHEAD, true, NULL);
 			f2fs_up_write(&F2FS_I(inode)->i_gc_rwsem[WRITE]);
-			if (IS_ERR(data_page)) {
+			if (IS_ERR(data_folio)) {
 				iput(inode);
 				continue;
 			}
 
-			f2fs_put_page(data_page, 0);
+			f2fs_folio_put(data_folio, false);
 			add_gc_inode(gc_list, inode);
 			continue;
 		}
-- 
2.47.2


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH 26/27] f2fs: Add f2fs_find_data_folio()
  2025-02-18  5:51 [PATCH 00/27] f2fs folio conversions for v6.15 Matthew Wilcox (Oracle)
                   ` (24 preceding siblings ...)
  2025-02-18  5:51 ` [PATCH 25/27] f2fs: Convert gc_data_segment() " Matthew Wilcox (Oracle)
@ 2025-02-18  5:52 ` Matthew Wilcox (Oracle)
  2025-02-18  5:52 ` [PATCH 27/27] mm: Remove wait_on_page_locked() Matthew Wilcox (Oracle)
                   ` (3 subsequent siblings)
  29 siblings, 0 replies; 41+ messages in thread
From: Matthew Wilcox (Oracle) @ 2025-02-18  5:52 UTC (permalink / raw)
  To: Jaegeuk Kim, Chao Yu
  Cc: Matthew Wilcox (Oracle), linux-f2fs-devel, linux-fsdevel

Convert f2fs_find_data_page() to f2fs_find_data_folio() and add a
compatibility wrapper.  Saves six hidden calls to compound_head().
This was the last caller of f2fs_get_read_data_page(), so remove
the compatibility wrapper.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/f2fs/data.c | 33 ++++++++++++++++++---------------
 fs/f2fs/f2fs.h | 12 +++++-------
 2 files changed, 23 insertions(+), 22 deletions(-)

diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index e891c95bc525..f1554a5a3d7a 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -1279,30 +1279,33 @@ struct folio *f2fs_get_read_data_folio(struct inode *inode, pgoff_t index,
 	return ERR_PTR(err);
 }
 
-struct page *f2fs_find_data_page(struct inode *inode, pgoff_t index,
+struct folio *f2fs_find_data_folio(struct inode *inode, pgoff_t index,
 					pgoff_t *next_pgofs)
 {
 	struct address_space *mapping = inode->i_mapping;
-	struct page *page;
+	struct folio *folio;
 
-	page = find_get_page_flags(mapping, index, FGP_ACCESSED);
-	if (page && PageUptodate(page))
-		return page;
-	f2fs_put_page(page, 0);
+	folio = __filemap_get_folio(mapping, index, FGP_ACCESSED, 0);
+	if (IS_ERR(folio))
+		goto read;
+	if (folio_test_uptodate(folio))
+		return folio;
+	f2fs_folio_put(folio, false);
 
-	page = f2fs_get_read_data_page(inode, index, 0, false, next_pgofs);
-	if (IS_ERR(page))
-		return page;
+read:
+	folio = f2fs_get_read_data_folio(inode, index, 0, false, next_pgofs);
+	if (IS_ERR(folio))
+		return folio;
 
-	if (PageUptodate(page))
-		return page;
+	if (folio_test_uptodate(folio))
+		return folio;
 
-	wait_on_page_locked(page);
-	if (unlikely(!PageUptodate(page))) {
-		f2fs_put_page(page, 0);
+	folio_wait_locked(folio);
+	if (unlikely(!folio_test_uptodate(folio))) {
+		f2fs_folio_put(folio, false);
 		return ERR_PTR(-EIO);
 	}
-	return page;
+	return folio;
 }
 
 /*
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index c78ba3c7d642..a2298eca2576 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -3897,8 +3897,8 @@ int f2fs_get_block_locked(struct dnode_of_data *dn, pgoff_t index);
 int f2fs_reserve_block(struct dnode_of_data *dn, pgoff_t index);
 struct folio *f2fs_get_read_data_folio(struct inode *inode, pgoff_t index,
 		blk_opf_t op_flags, bool for_write, pgoff_t *next_pgofs);
-struct page *f2fs_find_data_page(struct inode *inode, pgoff_t index,
-							pgoff_t *next_pgofs);
+struct folio *f2fs_find_data_folio(struct inode *inode, pgoff_t index,
+		pgoff_t *next_pgofs);
 struct folio *f2fs_get_lock_data_folio(struct inode *inode, pgoff_t index,
 			bool for_write);
 struct page *f2fs_get_new_data_page(struct inode *inode,
@@ -3926,12 +3926,10 @@ int f2fs_init_post_read_wq(struct f2fs_sb_info *sbi);
 void f2fs_destroy_post_read_wq(struct f2fs_sb_info *sbi);
 extern const struct iomap_ops f2fs_iomap_ops;
 
-static inline struct page *f2fs_get_read_data_page(struct inode *inode,
-		pgoff_t index, blk_opf_t op_flags, bool for_write,
-		pgoff_t *next_pgofs)
+static inline struct page *f2fs_find_data_page(struct inode *inode,
+		pgoff_t index, pgoff_t *next_pgofs)
 {
-	struct folio *folio = f2fs_get_read_data_folio(inode, index, op_flags,
-			for_write, next_pgofs);
+	struct folio *folio = f2fs_find_data_folio(inode, index, next_pgofs);
 
 	return &folio->page;
 }
-- 
2.47.2


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH 27/27] mm: Remove wait_on_page_locked()
  2025-02-18  5:51 [PATCH 00/27] f2fs folio conversions for v6.15 Matthew Wilcox (Oracle)
                   ` (25 preceding siblings ...)
  2025-02-18  5:52 ` [PATCH 26/27] f2fs: Add f2fs_find_data_folio() Matthew Wilcox (Oracle)
@ 2025-02-18  5:52 ` Matthew Wilcox (Oracle)
  2025-02-21  2:27 ` [PATCH 00/27] f2fs folio conversions for v6.15 Jaegeuk Kim
                   ` (2 subsequent siblings)
  29 siblings, 0 replies; 41+ messages in thread
From: Matthew Wilcox (Oracle) @ 2025-02-18  5:52 UTC (permalink / raw)
  To: Jaegeuk Kim, Chao Yu
  Cc: Matthew Wilcox (Oracle), linux-f2fs-devel, linux-fsdevel

This compatibility wrapper has no callers left, so remove it.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 include/linux/pagemap.h | 5 -----
 mm/filemap.c            | 2 +-
 2 files changed, 1 insertion(+), 6 deletions(-)

diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
index 45817e2106ee..b8c6fa320ee3 100644
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -1242,11 +1242,6 @@ static inline int folio_wait_locked_killable(struct folio *folio)
 	return folio_wait_bit_killable(folio, PG_locked);
 }
 
-static inline void wait_on_page_locked(struct page *page)
-{
-	folio_wait_locked(page_folio(page));
-}
-
 void folio_end_read(struct folio *folio, bool success);
 void wait_on_page_writeback(struct page *page);
 void folio_wait_writeback(struct folio *folio);
diff --git a/mm/filemap.c b/mm/filemap.c
index c8fd285c4287..70d0b579cdad 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -1380,7 +1380,7 @@ static inline int folio_wait_bit_common(struct folio *folio, int bit_nr,
  * @ptl: already locked ptl. This function will drop the lock.
  *
  * Wait for a migration entry referencing the given page to be removed. This is
- * equivalent to put_and_wait_on_page_locked(page, TASK_UNINTERRUPTIBLE) except
+ * equivalent to folio_put_wait_locked(folio, TASK_UNINTERRUPTIBLE) except
  * this can be called without taking a reference on the page. Instead this
  * should be called while holding the ptl for the migration entry referencing
  * the page.
-- 
2.47.2


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* Re: [PATCH 00/27] f2fs folio conversions for v6.15
  2025-02-18  5:51 [PATCH 00/27] f2fs folio conversions for v6.15 Matthew Wilcox (Oracle)
                   ` (26 preceding siblings ...)
  2025-02-18  5:52 ` [PATCH 27/27] mm: Remove wait_on_page_locked() Matthew Wilcox (Oracle)
@ 2025-02-21  2:27 ` Jaegeuk Kim
  2025-03-04  8:04 ` Chao Yu
  2025-03-04 17:10 ` [f2fs-dev] " patchwork-bot+f2fs
  29 siblings, 0 replies; 41+ messages in thread
From: Jaegeuk Kim @ 2025-02-21  2:27 UTC (permalink / raw)
  To: Matthew Wilcox (Oracle); +Cc: Chao Yu, linux-f2fs-devel, linux-fsdevel

Thank you for the patches. I queued them in dev-test and kicked off all my
tests.

Thanks,

On 02/18, Matthew Wilcox (Oracle) wrote:
> More f2fs folio conversions.  This time I'm focusing on removing
> accesses to page->mapping as well as getting rid of accesses to
> old APIs.  f2fs was the last user of wait_for_stable_page(),
> grab_cache_page_write_begin() and wait_on_page_locked(), so
> I've included those removals in this series too.
> 
> Matthew Wilcox (Oracle) (27):
>   f2fs: Add f2fs_folio_wait_writeback()
>   mm: Remove wait_for_stable_page()
>   f2fs: Add f2fs_folio_put()
>   f2fs: Convert f2fs_flush_inline_data() to use a folio
>   f2fs: Convert f2fs_sync_node_pages() to use a folio
>   f2fs: Pass a folio to flush_dirty_inode()
>   f2fs: Convert f2fs_fsync_node_pages() to use a folio
>   f2fs: Convert last_fsync_dnode() to use a folio
>   f2fs: Return a folio from last_fsync_dnode()
>   f2fs: Add f2fs_grab_cache_folio()
>   mm: Remove grab_cache_page_write_begin()
>   f2fs: Use a folio in __get_node_page()
>   f2fs: Use a folio in do_write_page()
>   f2fs: Convert f2fs_write_end_io() to use a folio_iter
>   f2fs: Mark some functions as taking a const page pointer
>   f2fs: Convert f2fs_in_warm_node_list() to take a folio
>   f2fs: Add f2fs_get_node_folio()
>   f2fs: Use a folio throughout f2fs_truncate_inode_blocks()
>   f2fs: Use a folio throughout __get_meta_page()
>   f2fs: Hoist the page_folio() call to the start of
>     f2fs_merge_page_bio()
>   f2fs: Add f2fs_get_read_data_folio()
>   f2fs: Add f2fs_get_lock_data_folio()
>   f2fs: Convert move_data_page() to use a folio
>   f2fs: Convert truncate_partial_data_page() to use a folio
>   f2fs: Convert gc_data_segment() to use a folio
>   f2fs: Add f2fs_find_data_folio()
>   mm: Remove wait_on_page_locked()
> 
>  fs/f2fs/checkpoint.c    |  26 ++--
>  fs/f2fs/data.c          | 130 ++++++++++---------
>  fs/f2fs/f2fs.h          |  90 +++++++++----
>  fs/f2fs/file.c          |  24 ++--
>  fs/f2fs/gc.c            |  42 +++---
>  fs/f2fs/node.c          | 279 ++++++++++++++++++++--------------------
>  fs/f2fs/node.h          |   6 +-
>  fs/f2fs/segment.c       |  26 ++--
>  include/linux/pagemap.h |   9 --
>  mm/filemap.c            |   2 +-
>  mm/folio-compat.c       |  14 --
>  11 files changed, 338 insertions(+), 310 deletions(-)
> 
> -- 
> 2.47.2

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH 03/27] f2fs: Add f2fs_folio_put()
  2025-02-18  5:51 ` [PATCH 03/27] f2fs: Add f2fs_folio_put() Matthew Wilcox (Oracle)
@ 2025-02-21  4:55   ` Jaegeuk Kim
  2025-02-24  7:19     ` Jaegeuk Kim
  0 siblings, 1 reply; 41+ messages in thread
From: Jaegeuk Kim @ 2025-02-21  4:55 UTC (permalink / raw)
  To: Matthew Wilcox (Oracle); +Cc: Chao Yu, linux-f2fs-devel, linux-fsdevel

On 02/18, Matthew Wilcox (Oracle) wrote:
> Convert f2fs_put_page() to f2fs_folio_put() and add a wrapper.
> Replaces three calls to compound_head() with one.
> 
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> ---
>  fs/f2fs/f2fs.h | 15 ++++++++++-----
>  1 file changed, 10 insertions(+), 5 deletions(-)
> 
> diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
> index b05653f196dd..5e01a08afbd7 100644
> --- a/fs/f2fs/f2fs.h
> +++ b/fs/f2fs/f2fs.h
> @@ -2806,16 +2806,21 @@ static inline struct page *f2fs_pagecache_get_page(
>  	return pagecache_get_page(mapping, index, fgp_flags, gfp_mask);
>  }
>  
> -static inline void f2fs_put_page(struct page *page, int unlock)
> +static inline void f2fs_folio_put(struct folio *folio, bool unlock)
>  {
> -	if (!page)
> +	if (!folio)
>  		return;
>  
>  	if (unlock) {
> -		f2fs_bug_on(F2FS_P_SB(page), !PageLocked(page));
> -		unlock_page(page);
> +		f2fs_bug_on(F2FS_F_SB(folio), !folio_test_locked(folio));
> +		folio_unlock(folio);
>  	}
> -	put_page(page);
> +	folio_put(folio);
> +}
> +
> +static inline void f2fs_put_page(struct page *page, int unlock)
> +{

I got a kernel panic, since there are still several places to pass a null
page pointer, which feeds to page_folio() which doesn't expect the null.

Applying this can avoid the panic.

	if (!page)
		return;

> +	f2fs_folio_put(page_folio(page), unlock);
>  }
>  
>  static inline void f2fs_put_dnode(struct dnode_of_data *dn)
> -- 
> 2.47.2
> 

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH 03/27] f2fs: Add f2fs_folio_put()
  2025-02-21  4:55   ` Jaegeuk Kim
@ 2025-02-24  7:19     ` Jaegeuk Kim
  2025-02-27 21:31       ` Jaegeuk Kim
  0 siblings, 1 reply; 41+ messages in thread
From: Jaegeuk Kim @ 2025-02-24  7:19 UTC (permalink / raw)
  To: Matthew Wilcox (Oracle); +Cc: Chao Yu, linux-f2fs-devel, linux-fsdevel

Hi Matthew,

On 02/21, Jaegeuk Kim wrote:
> On 02/18, Matthew Wilcox (Oracle) wrote:
> > Convert f2fs_put_page() to f2fs_folio_put() and add a wrapper.
> > Replaces three calls to compound_head() with one.
> > 
> > Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> > ---
> >  fs/f2fs/f2fs.h | 15 ++++++++++-----
> >  1 file changed, 10 insertions(+), 5 deletions(-)
> > 
> > diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
> > index b05653f196dd..5e01a08afbd7 100644
> > --- a/fs/f2fs/f2fs.h
> > +++ b/fs/f2fs/f2fs.h
> > @@ -2806,16 +2806,21 @@ static inline struct page *f2fs_pagecache_get_page(
> >  	return pagecache_get_page(mapping, index, fgp_flags, gfp_mask);
> >  }
> >  
> > -static inline void f2fs_put_page(struct page *page, int unlock)
> > +static inline void f2fs_folio_put(struct folio *folio, bool unlock)
> >  {
> > -	if (!page)
> > +	if (!folio)
> >  		return;
> >  
> >  	if (unlock) {
> > -		f2fs_bug_on(F2FS_P_SB(page), !PageLocked(page));
> > -		unlock_page(page);
> > +		f2fs_bug_on(F2FS_F_SB(folio), !folio_test_locked(folio));
> > +		folio_unlock(folio);
> >  	}
> > -	put_page(page);
> > +	folio_put(folio);
> > +}
> > +
> > +static inline void f2fs_put_page(struct page *page, int unlock)
> > +{
> 
> I got a kernel panic, since there are still several places to pass a null
> page pointer, which feeds to page_folio() which doesn't expect the null.
> 
> Applying this can avoid the panic.
> 
> 	if (!page)
> 		return;

Please let me know, if you want me to apply this to your patch directly, or post
v2.

Thanks,

> 
> > +	f2fs_folio_put(page_folio(page), unlock);
> >  }
> >  
> >  static inline void f2fs_put_dnode(struct dnode_of_data *dn)
> > -- 
> > 2.47.2
> > 

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH 03/27] f2fs: Add f2fs_folio_put()
  2025-02-24  7:19     ` Jaegeuk Kim
@ 2025-02-27 21:31       ` Jaegeuk Kim
  0 siblings, 0 replies; 41+ messages in thread
From: Jaegeuk Kim @ 2025-02-27 21:31 UTC (permalink / raw)
  To: Matthew Wilcox (Oracle); +Cc: Chao Yu, linux-f2fs-devel, linux-fsdevel

On 02/24, Jaegeuk Kim wrote:
> Hi Matthew,
> 
> On 02/21, Jaegeuk Kim wrote:
> > On 02/18, Matthew Wilcox (Oracle) wrote:
> > > Convert f2fs_put_page() to f2fs_folio_put() and add a wrapper.
> > > Replaces three calls to compound_head() with one.
> > > 
> > > Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> > > ---
> > >  fs/f2fs/f2fs.h | 15 ++++++++++-----
> > >  1 file changed, 10 insertions(+), 5 deletions(-)
> > > 
> > > diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
> > > index b05653f196dd..5e01a08afbd7 100644
> > > --- a/fs/f2fs/f2fs.h
> > > +++ b/fs/f2fs/f2fs.h
> > > @@ -2806,16 +2806,21 @@ static inline struct page *f2fs_pagecache_get_page(
> > >  	return pagecache_get_page(mapping, index, fgp_flags, gfp_mask);
> > >  }
> > >  
> > > -static inline void f2fs_put_page(struct page *page, int unlock)
> > > +static inline void f2fs_folio_put(struct folio *folio, bool unlock)
> > >  {
> > > -	if (!page)
> > > +	if (!folio)
> > >  		return;
> > >  
> > >  	if (unlock) {
> > > -		f2fs_bug_on(F2FS_P_SB(page), !PageLocked(page));
> > > -		unlock_page(page);
> > > +		f2fs_bug_on(F2FS_F_SB(folio), !folio_test_locked(folio));
> > > +		folio_unlock(folio);
> > >  	}
> > > -	put_page(page);
> > > +	folio_put(folio);
> > > +}
> > > +
> > > +static inline void f2fs_put_page(struct page *page, int unlock)
> > > +{
> > 
> > I got a kernel panic, since there are still several places to pass a null
> > page pointer, which feeds to page_folio() which doesn't expect the null.
> > 
> > Applying this can avoid the panic.
> > 
> > 	if (!page)
> > 		return;
> 
> Please let me know, if you want me to apply this to your patch directly, or post
> v2.

I applied the fix into your patch. Thanks.

> 
> Thanks,
> 
> > 
> > > +	f2fs_folio_put(page_folio(page), unlock);
> > >  }
> > >  
> > >  static inline void f2fs_put_dnode(struct dnode_of_data *dn)
> > > -- 
> > > 2.47.2
> > > 

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH 20/27] f2fs: Hoist the page_folio() call to the start of f2fs_merge_page_bio()
  2025-02-18  5:51 ` [PATCH 20/27] f2fs: Hoist the page_folio() call to the start of f2fs_merge_page_bio() Matthew Wilcox (Oracle)
@ 2025-02-28  7:25   ` Chao Yu
  0 siblings, 0 replies; 41+ messages in thread
From: Chao Yu @ 2025-02-28  7:25 UTC (permalink / raw)
  To: Matthew Wilcox (Oracle), Jaegeuk Kim
  Cc: chao, linux-f2fs-devel, linux-fsdevel

On 2025/2/18 13:51, Matthew Wilcox (Oracle) wrote:
> Remove one call to compound_head() and a reference to page->mapping
> by calling page_folio() early on.
> 
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> ---
>   fs/f2fs/data.c | 8 ++++----
>   1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
> index d297e9ae6391..fe7fa08b20c7 100644
> --- a/fs/f2fs/data.c
> +++ b/fs/f2fs/data.c
> @@ -888,6 +888,7 @@ int f2fs_merge_page_bio(struct f2fs_io_info *fio)
>   	struct bio *bio = *fio->bio;
>   	struct page *page = fio->encrypted_page ?
>   			fio->encrypted_page : fio->page;
> +	struct folio *folio = page_folio(fio->page);
>   
>   	if (!f2fs_is_valid_blkaddr(fio->sbi, fio->new_blkaddr,
>   			__is_meta_io(fio) ? META_GENERIC : DATA_GENERIC))

Minor thing, missed to change below line:

	trace_f2fs_submit_folio_bio(page_folio(page), fio);

can be cleaned up to:

	trace_f2fs_submit_folio_bio(folio, fio);

Thanks,

> @@ -901,8 +902,8 @@ int f2fs_merge_page_bio(struct f2fs_io_info *fio)
>   alloc_new:
>   	if (!bio) {
>   		bio = __bio_alloc(fio, BIO_MAX_VECS);
> -		f2fs_set_bio_crypt_ctx(bio, fio->page->mapping->host,
> -				page_folio(fio->page)->index, fio, GFP_NOIO);
> +		f2fs_set_bio_crypt_ctx(bio, folio->mapping->host,
> +				folio->index, fio, GFP_NOIO);
>   
>   		add_bio_entry(fio->sbi, bio, page, fio->temp);
>   	} else {
> @@ -911,8 +912,7 @@ int f2fs_merge_page_bio(struct f2fs_io_info *fio)
>   	}
>   
>   	if (fio->io_wbc)
> -		wbc_account_cgroup_owner(fio->io_wbc, page_folio(fio->page),
> -					 PAGE_SIZE);
> +		wbc_account_cgroup_owner(fio->io_wbc, folio, folio_size(folio));
>   
>   	inc_page_count(fio->sbi, WB_DATA_TYPE(page, false));
>   


^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH 21/27] f2fs: Add f2fs_get_read_data_folio()
  2025-02-18  5:51 ` [PATCH 21/27] f2fs: Add f2fs_get_read_data_folio() Matthew Wilcox (Oracle)
@ 2025-02-28  7:37   ` Chao Yu
  0 siblings, 0 replies; 41+ messages in thread
From: Chao Yu @ 2025-02-28  7:37 UTC (permalink / raw)
  To: Matthew Wilcox (Oracle), Jaegeuk Kim
  Cc: chao, linux-f2fs-devel, linux-fsdevel

On 2025/2/18 13:51, Matthew Wilcox (Oracle) wrote:
> Convert f2fs_get_read_data_page() into f2fs_get_read_data_folio() and
> add a compatibility wrapper.  Saves seven hidden calls to compound_head().
> 
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> ---
>   fs/f2fs/data.c | 35 +++++++++++++++++------------------
>   fs/f2fs/f2fs.h | 14 ++++++++++++--
>   2 files changed, 29 insertions(+), 20 deletions(-)
> 
> diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
> index fe7fa08b20c7..f0747c7f669d 100644
> --- a/fs/f2fs/data.c
> +++ b/fs/f2fs/data.c
> @@ -1203,18 +1203,17 @@ int f2fs_reserve_block(struct dnode_of_data *dn, pgoff_t index)
>   	return err;
>   }
>   
> -struct page *f2fs_get_read_data_page(struct inode *inode, pgoff_t index,
> -				     blk_opf_t op_flags, bool for_write,
> -				     pgoff_t *next_pgofs)
> +struct folio *f2fs_get_read_data_folio(struct inode *inode, pgoff_t index,
> +		blk_opf_t op_flags, bool for_write, pgoff_t *next_pgofs)
>   {
>   	struct address_space *mapping = inode->i_mapping;
>   	struct dnode_of_data dn;
> -	struct page *page;
> +	struct folio *folio;
>   	int err;
>   
> -	page = f2fs_grab_cache_page(mapping, index, for_write);
> -	if (!page)
> -		return ERR_PTR(-ENOMEM);
> +	folio = f2fs_grab_cache_folio(mapping, index, for_write);
> +	if (IS_ERR(folio))
> +		return folio;
>   
>   	if (f2fs_lookup_read_extent_cache_block(inode, index,
>   						&dn.data_blkaddr)) {
> @@ -1249,9 +1248,9 @@ struct page *f2fs_get_read_data_page(struct inode *inode, pgoff_t index,
>   		goto put_err;
>   	}
>   got_it:
> -	if (PageUptodate(page)) {
> -		unlock_page(page);
> -		return page;
> +	if (folio_test_uptodate(folio)) {
> +		folio_unlock(folio);
> +		return folio;
>   	}
>   
>   	/*
> @@ -1262,21 +1261,21 @@ struct page *f2fs_get_read_data_page(struct inode *inode, pgoff_t index,
>   	 * f2fs_init_inode_metadata.
>   	 */
>   	if (dn.data_blkaddr == NEW_ADDR) {
> -		zero_user_segment(page, 0, PAGE_SIZE);
> -		if (!PageUptodate(page))
> -			SetPageUptodate(page);
> -		unlock_page(page);
> -		return page;
> +		folio_zero_segment(folio, 0, folio_size(folio));
> +		if (!folio_test_uptodate(folio))
> +			folio_mark_uptodate(folio);
> +		folio_unlock(folio);
> +		return folio;
>   	}
>   
> -	err = f2fs_submit_page_read(inode, page_folio(page), dn.data_blkaddr,
> +	err = f2fs_submit_page_read(inode, folio, dn.data_blkaddr,
>   						op_flags, for_write);
>   	if (err)
>   		goto put_err;
> -	return page;
> +	return folio;
>   
>   put_err:
> -	f2fs_put_page(page, 1);
> +	f2fs_folio_put(folio, true);
>   	return ERR_PTR(err);
>   }
>   
> diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
> index 8f23bb082c6f..3e02df63499e 100644
> --- a/fs/f2fs/f2fs.h
> +++ b/fs/f2fs/f2fs.h
> @@ -3895,8 +3895,8 @@ int f2fs_reserve_new_blocks(struct dnode_of_data *dn, blkcnt_t count);
>   int f2fs_reserve_new_block(struct dnode_of_data *dn);
>   int f2fs_get_block_locked(struct dnode_of_data *dn, pgoff_t index);
>   int f2fs_reserve_block(struct dnode_of_data *dn, pgoff_t index);
> -struct page *f2fs_get_read_data_page(struct inode *inode, pgoff_t index,
> -			blk_opf_t op_flags, bool for_write, pgoff_t *next_pgofs);
> +struct folio *f2fs_get_read_data_folio(struct inode *inode, pgoff_t index,
> +		blk_opf_t op_flags, bool for_write, pgoff_t *next_pgofs);
>   struct page *f2fs_find_data_page(struct inode *inode, pgoff_t index,
>   							pgoff_t *next_pgofs);
>   struct page *f2fs_get_lock_data_page(struct inode *inode, pgoff_t index,
> @@ -3926,6 +3926,16 @@ int f2fs_init_post_read_wq(struct f2fs_sb_info *sbi);
>   void f2fs_destroy_post_read_wq(struct f2fs_sb_info *sbi);
>   extern const struct iomap_ops f2fs_iomap_ops;
>   
> +static inline struct page *f2fs_get_read_data_page(struct inode *inode,
> +		pgoff_t index, blk_opf_t op_flags, bool for_write,
> +		pgoff_t *next_pgofs)
> +{
> +	struct folio *folio = f2fs_get_read_data_folio(inode, index, op_flags,
> +			for_write, next_pgofs);
> +
	if (IS_ERR(folio))
		return ERR_CAST(folio));

> +	return &folio->page;
> +}
> +
>   /*
>    * gc.c
>    */


^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH 22/27] f2fs: Add f2fs_get_lock_data_folio()
  2025-02-18  5:51 ` [PATCH 22/27] f2fs: Add f2fs_get_lock_data_folio() Matthew Wilcox (Oracle)
@ 2025-02-28  7:37   ` Chao Yu
  0 siblings, 0 replies; 41+ messages in thread
From: Chao Yu @ 2025-02-28  7:37 UTC (permalink / raw)
  To: Matthew Wilcox (Oracle), Jaegeuk Kim
  Cc: chao, linux-f2fs-devel, linux-fsdevel

On 2025/2/18 13:51, Matthew Wilcox (Oracle) wrote:
> Convert f2fs_get_lock_data_page() to f2fs_get_lock_data_folio() and
> add a compatibility wrapper.  Removes three hidden calls to
> compound_head().
> 
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> ---
>   fs/f2fs/data.c | 18 +++++++++---------
>   fs/f2fs/f2fs.h | 10 +++++++++-
>   2 files changed, 18 insertions(+), 10 deletions(-)
> 
> diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
> index f0747c7f669d..e891c95bc525 100644
> --- a/fs/f2fs/data.c
> +++ b/fs/f2fs/data.c
> @@ -1310,23 +1310,23 @@ struct page *f2fs_find_data_page(struct inode *inode, pgoff_t index,
>    * Because, the callers, functions in dir.c and GC, should be able to know
>    * whether this page exists or not.
>    */
> -struct page *f2fs_get_lock_data_page(struct inode *inode, pgoff_t index,
> +struct folio *f2fs_get_lock_data_folio(struct inode *inode, pgoff_t index,
>   							bool for_write)
>   {
>   	struct address_space *mapping = inode->i_mapping;
> -	struct page *page;
> +	struct folio *folio;
>   
> -	page = f2fs_get_read_data_page(inode, index, 0, for_write, NULL);
> -	if (IS_ERR(page))
> -		return page;
> +	folio = f2fs_get_read_data_folio(inode, index, 0, for_write, NULL);
> +	if (IS_ERR(folio))
> +		return folio;
>   
>   	/* wait for read completion */
> -	lock_page(page);
> -	if (unlikely(page->mapping != mapping || !PageUptodate(page))) {
> -		f2fs_put_page(page, 1);
> +	folio_lock(folio);
> +	if (unlikely(folio->mapping != mapping || !folio_test_uptodate(folio))) {
> +		f2fs_folio_put(folio, true);
>   		return ERR_PTR(-EIO);
>   	}
> -	return page;
> +	return folio;
>   }
>   
>   /*
> diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
> index 3e02df63499e..c78ba3c7d642 100644
> --- a/fs/f2fs/f2fs.h
> +++ b/fs/f2fs/f2fs.h
> @@ -3899,7 +3899,7 @@ struct folio *f2fs_get_read_data_folio(struct inode *inode, pgoff_t index,
>   		blk_opf_t op_flags, bool for_write, pgoff_t *next_pgofs);
>   struct page *f2fs_find_data_page(struct inode *inode, pgoff_t index,
>   							pgoff_t *next_pgofs);
> -struct page *f2fs_get_lock_data_page(struct inode *inode, pgoff_t index,
> +struct folio *f2fs_get_lock_data_folio(struct inode *inode, pgoff_t index,
>   			bool for_write);
>   struct page *f2fs_get_new_data_page(struct inode *inode,
>   			struct page *ipage, pgoff_t index, bool new_i_size);
> @@ -3936,6 +3936,14 @@ static inline struct page *f2fs_get_read_data_page(struct inode *inode,
>   	return &folio->page;
>   }
>   
> +static inline struct page *f2fs_get_lock_data_page(struct inode *inode,
> +		pgoff_t index, bool for_write)
> +{
> +	struct folio *folio = f2fs_get_lock_data_folio(inode, index, for_write);

	if (IS_ERR(folio))
		return ERR_CAST(folio));

> +
> +	return &folio->page;
> +}
> +
>   /*
>    * gc.c
>    */


^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH 17/27] f2fs: Add f2fs_get_node_folio()
  2025-02-18  5:51 ` [PATCH 17/27] f2fs: Add f2fs_get_node_folio() Matthew Wilcox (Oracle)
@ 2025-03-01  1:15   ` Chao Yu
  2025-03-01  1:59     ` Matthew Wilcox
  2025-03-01  2:03     ` Matthew Wilcox
  0 siblings, 2 replies; 41+ messages in thread
From: Chao Yu @ 2025-03-01  1:15 UTC (permalink / raw)
  To: Matthew Wilcox (Oracle), Jaegeuk Kim
  Cc: chao, linux-f2fs-devel, linux-fsdevel

On 2025/2/18 13:51, Matthew Wilcox (Oracle) wrote:
> Change __get_node_page() to return a folio and convert back to a page in
> f2fs_get_node_page() and f2fs_get_node_page_ra().
> 
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> ---
>   fs/f2fs/f2fs.h |  1 +
>   fs/f2fs/node.c | 18 +++++++++++++-----
>   2 files changed, 14 insertions(+), 5 deletions(-)
> 
> diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
> index bbaa61da83a8..8f23bb082c6f 100644
> --- a/fs/f2fs/f2fs.h
> +++ b/fs/f2fs/f2fs.h
> @@ -3689,6 +3689,7 @@ struct page *f2fs_new_inode_page(struct inode *inode);
>   struct page *f2fs_new_node_page(struct dnode_of_data *dn, unsigned int ofs);
>   void f2fs_ra_node_page(struct f2fs_sb_info *sbi, nid_t nid);
>   struct page *f2fs_get_node_page(struct f2fs_sb_info *sbi, pgoff_t nid);
> +struct folio *f2fs_get_node_folio(struct f2fs_sb_info *sbi, pgoff_t nid);
>   struct page *f2fs_get_node_page_ra(struct page *parent, int start);
>   int f2fs_move_node_page(struct page *node_page, int gc_type);
>   void f2fs_flush_inline_data(struct f2fs_sb_info *sbi);
> diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
> index da28e295c701..2d161ddda9c3 100644
> --- a/fs/f2fs/node.c
> +++ b/fs/f2fs/node.c
> @@ -1449,7 +1449,7 @@ void f2fs_ra_node_page(struct f2fs_sb_info *sbi, nid_t nid)
>   	f2fs_put_page(apage, err ? 1 : 0);
>   }
>   
> -static struct page *__get_node_page(struct f2fs_sb_info *sbi, pgoff_t nid,
> +static struct folio *__get_node_folio(struct f2fs_sb_info *sbi, pgoff_t nid,
>   					struct page *parent, int start)
>   {
>   	struct folio *folio;
> @@ -1462,7 +1462,7 @@ static struct page *__get_node_page(struct f2fs_sb_info *sbi, pgoff_t nid,
>   repeat:
>   	folio = f2fs_grab_cache_folio(NODE_MAPPING(sbi), nid, false);
>   	if (IS_ERR(folio))
> -		return ERR_CAST(folio);
> +		return folio;
>   
>   	err = read_node_page(&folio->page, 0);
>   	if (err < 0) {
> @@ -1493,7 +1493,7 @@ static struct page *__get_node_page(struct f2fs_sb_info *sbi, pgoff_t nid,
>   	}
>   page_hit:
>   	if (likely(nid == nid_of_node(&folio->page)))
> -		return &folio->page;
> +		return folio;
>   
>   	f2fs_warn(sbi, "inconsistent node block, nid:%lu, node_footer[nid:%u,ino:%u,ofs:%u,cpver:%llu,blkaddr:%u]",
>   			  nid, nid_of_node(&folio->page), ino_of_node(&folio->page),
> @@ -1512,17 +1512,25 @@ static struct page *__get_node_page(struct f2fs_sb_info *sbi, pgoff_t nid,
>   	return ERR_PTR(err);
>   }
>   
> +struct folio *f2fs_get_node_folio(struct f2fs_sb_info *sbi, pgoff_t nid)
> +{
> +	return __get_node_folio(sbi, nid, NULL, 0);
> +}
> +
>   struct page *f2fs_get_node_page(struct f2fs_sb_info *sbi, pgoff_t nid)
>   {
> -	return __get_node_page(sbi, nid, NULL, 0);
> +	struct folio *folio = __get_node_folio(sbi, nid, NULL, 0);
> +

	if (IS_ERR(folio))
		return ERR_CAST(folio));

> +	return &folio->page;
>   }
>   
>   struct page *f2fs_get_node_page_ra(struct page *parent, int start)
>   {
>   	struct f2fs_sb_info *sbi = F2FS_P_SB(parent);
>   	nid_t nid = get_nid(parent, start, false);
> +	struct folio *folio = __get_node_folio(sbi, nid, parent, start);
>   

	if (IS_ERR(folio))
		return ERR_CAST(folio));

> -	return __get_node_page(sbi, nid, parent, start);
> +	return &folio->page;
>   }
>   
>   static void flush_inline_data(struct f2fs_sb_info *sbi, nid_t ino)


^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH 17/27] f2fs: Add f2fs_get_node_folio()
  2025-03-01  1:15   ` Chao Yu
@ 2025-03-01  1:59     ` Matthew Wilcox
  2025-03-01  2:03     ` Matthew Wilcox
  1 sibling, 0 replies; 41+ messages in thread
From: Matthew Wilcox @ 2025-03-01  1:59 UTC (permalink / raw)
  To: Chao Yu; +Cc: Jaegeuk Kim, linux-f2fs-devel, linux-fsdevel

On Sat, Mar 01, 2025 at 09:15:53AM +0800, Chao Yu wrote:
> >   struct page *f2fs_get_node_page(struct f2fs_sb_info *sbi, pgoff_t nid)
> >   {
> > -	return __get_node_page(sbi, nid, NULL, 0);
> > +	struct folio *folio = __get_node_folio(sbi, nid, NULL, 0);
> > +
> 
> 	if (IS_ERR(folio))
> 		return ERR_CAST(folio));

No need.  It's the same result, we use this pattern extensively, and
this is a temporary wrapper that has to go away in the next six to nine
months anyway.


^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH 17/27] f2fs: Add f2fs_get_node_folio()
  2025-03-01  1:15   ` Chao Yu
  2025-03-01  1:59     ` Matthew Wilcox
@ 2025-03-01  2:03     ` Matthew Wilcox
  2025-03-03  3:15       ` Chao Yu
  1 sibling, 1 reply; 41+ messages in thread
From: Matthew Wilcox @ 2025-03-01  2:03 UTC (permalink / raw)
  To: Chao Yu; +Cc: Jaegeuk Kim, linux-f2fs-devel, linux-fsdevel

On Sat, Mar 01, 2025 at 09:15:53AM +0800, Chao Yu wrote:
> >   struct page *f2fs_get_node_page(struct f2fs_sb_info *sbi, pgoff_t nid)
> >   {
> > -	return __get_node_page(sbi, nid, NULL, 0);
> > +	struct folio *folio = __get_node_folio(sbi, nid, NULL, 0);
> > +
> 
> 	if (IS_ERR(folio))
> 		return ERR_CAST(folio));
> 
> > +	return &folio->page;

No need.  It'll probably generate the saame code (or if not, it'll
generate worse code) and this wrapper function has to be deleted in
the next six to nine months anyway.  We use this idiom extensively.

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH 17/27] f2fs: Add f2fs_get_node_folio()
  2025-03-01  2:03     ` Matthew Wilcox
@ 2025-03-03  3:15       ` Chao Yu
  0 siblings, 0 replies; 41+ messages in thread
From: Chao Yu @ 2025-03-03  3:15 UTC (permalink / raw)
  To: Matthew Wilcox; +Cc: chao, Jaegeuk Kim, linux-f2fs-devel, linux-fsdevel

On 3/1/25 10:03, Matthew Wilcox wrote:
> On Sat, Mar 01, 2025 at 09:15:53AM +0800, Chao Yu wrote:
>>>   struct page *f2fs_get_node_page(struct f2fs_sb_info *sbi, pgoff_t nid)
>>>   {
>>> -	return __get_node_page(sbi, nid, NULL, 0);
>>> +	struct folio *folio = __get_node_folio(sbi, nid, NULL, 0);
>>> +
>>
>> 	if (IS_ERR(folio))
>> 		return ERR_CAST(folio));
>>
>>> +	return &folio->page;
> 
> No need.  It'll probably generate the saame code (or if not, it'll
> generate worse code) and this wrapper function has to be deleted in
> the next six to nine months anyway.  We use this idiom extensively.

Oh, correct, seems return value '&folio->page' is equal to value of folio
as I checked.

Thanks,


^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH 00/27] f2fs folio conversions for v6.15
  2025-02-18  5:51 [PATCH 00/27] f2fs folio conversions for v6.15 Matthew Wilcox (Oracle)
                   ` (27 preceding siblings ...)
  2025-02-21  2:27 ` [PATCH 00/27] f2fs folio conversions for v6.15 Jaegeuk Kim
@ 2025-03-04  8:04 ` Chao Yu
  2025-03-04 17:10 ` [f2fs-dev] " patchwork-bot+f2fs
  29 siblings, 0 replies; 41+ messages in thread
From: Chao Yu @ 2025-03-04  8:04 UTC (permalink / raw)
  To: Matthew Wilcox (Oracle), Jaegeuk Kim
  Cc: chao, linux-f2fs-devel, linux-fsdevel

On 2/18/25 13:51, Matthew Wilcox (Oracle) wrote:
> More f2fs folio conversions.  This time I'm focusing on removing
> accesses to page->mapping as well as getting rid of accesses to
> old APIs.  f2fs was the last user of wait_for_stable_page(),
> grab_cache_page_write_begin() and wait_on_page_locked(), so
> I've included those removals in this series too.

After fixing f2fs_put_page(), whole patchset looks good to me.

Jaegeuk, feel free to add:

Reviewed-by: Chao Yu <chao@kernel.org>

Thanks,

> 
> Matthew Wilcox (Oracle) (27):
>   f2fs: Add f2fs_folio_wait_writeback()
>   mm: Remove wait_for_stable_page()
>   f2fs: Add f2fs_folio_put()
>   f2fs: Convert f2fs_flush_inline_data() to use a folio
>   f2fs: Convert f2fs_sync_node_pages() to use a folio
>   f2fs: Pass a folio to flush_dirty_inode()
>   f2fs: Convert f2fs_fsync_node_pages() to use a folio
>   f2fs: Convert last_fsync_dnode() to use a folio
>   f2fs: Return a folio from last_fsync_dnode()
>   f2fs: Add f2fs_grab_cache_folio()
>   mm: Remove grab_cache_page_write_begin()
>   f2fs: Use a folio in __get_node_page()
>   f2fs: Use a folio in do_write_page()
>   f2fs: Convert f2fs_write_end_io() to use a folio_iter
>   f2fs: Mark some functions as taking a const page pointer
>   f2fs: Convert f2fs_in_warm_node_list() to take a folio
>   f2fs: Add f2fs_get_node_folio()
>   f2fs: Use a folio throughout f2fs_truncate_inode_blocks()
>   f2fs: Use a folio throughout __get_meta_page()
>   f2fs: Hoist the page_folio() call to the start of
>     f2fs_merge_page_bio()
>   f2fs: Add f2fs_get_read_data_folio()
>   f2fs: Add f2fs_get_lock_data_folio()
>   f2fs: Convert move_data_page() to use a folio
>   f2fs: Convert truncate_partial_data_page() to use a folio
>   f2fs: Convert gc_data_segment() to use a folio
>   f2fs: Add f2fs_find_data_folio()
>   mm: Remove wait_on_page_locked()
> 
>  fs/f2fs/checkpoint.c    |  26 ++--
>  fs/f2fs/data.c          | 130 ++++++++++---------
>  fs/f2fs/f2fs.h          |  90 +++++++++----
>  fs/f2fs/file.c          |  24 ++--
>  fs/f2fs/gc.c            |  42 +++---
>  fs/f2fs/node.c          | 279 ++++++++++++++++++++--------------------
>  fs/f2fs/node.h          |   6 +-
>  fs/f2fs/segment.c       |  26 ++--
>  include/linux/pagemap.h |   9 --
>  mm/filemap.c            |   2 +-
>  mm/folio-compat.c       |  14 --
>  11 files changed, 338 insertions(+), 310 deletions(-)
> 


^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [f2fs-dev] [PATCH 00/27] f2fs folio conversions for v6.15
  2025-02-18  5:51 [PATCH 00/27] f2fs folio conversions for v6.15 Matthew Wilcox (Oracle)
                   ` (28 preceding siblings ...)
  2025-03-04  8:04 ` Chao Yu
@ 2025-03-04 17:10 ` patchwork-bot+f2fs
  29 siblings, 0 replies; 41+ messages in thread
From: patchwork-bot+f2fs @ 2025-03-04 17:10 UTC (permalink / raw)
  To: Matthew Wilcox; +Cc: jaegeuk, chao, linux-fsdevel, linux-f2fs-devel

Hello:

This series was applied to jaegeuk/f2fs.git (dev)
by Jaegeuk Kim <jaegeuk@kernel.org>:

On Tue, 18 Feb 2025 05:51:34 +0000 you wrote:
> More f2fs folio conversions.  This time I'm focusing on removing
> accesses to page->mapping as well as getting rid of accesses to
> old APIs.  f2fs was the last user of wait_for_stable_page(),
> grab_cache_page_write_begin() and wait_on_page_locked(), so
> I've included those removals in this series too.
> 
> Matthew Wilcox (Oracle) (27):
>   f2fs: Add f2fs_folio_wait_writeback()
>   mm: Remove wait_for_stable_page()
>   f2fs: Add f2fs_folio_put()
>   f2fs: Convert f2fs_flush_inline_data() to use a folio
>   f2fs: Convert f2fs_sync_node_pages() to use a folio
>   f2fs: Pass a folio to flush_dirty_inode()
>   f2fs: Convert f2fs_fsync_node_pages() to use a folio
>   f2fs: Convert last_fsync_dnode() to use a folio
>   f2fs: Return a folio from last_fsync_dnode()
>   f2fs: Add f2fs_grab_cache_folio()
>   mm: Remove grab_cache_page_write_begin()
>   f2fs: Use a folio in __get_node_page()
>   f2fs: Use a folio in do_write_page()
>   f2fs: Convert f2fs_write_end_io() to use a folio_iter
>   f2fs: Mark some functions as taking a const page pointer
>   f2fs: Convert f2fs_in_warm_node_list() to take a folio
>   f2fs: Add f2fs_get_node_folio()
>   f2fs: Use a folio throughout f2fs_truncate_inode_blocks()
>   f2fs: Use a folio throughout __get_meta_page()
>   f2fs: Hoist the page_folio() call to the start of
>     f2fs_merge_page_bio()
>   f2fs: Add f2fs_get_read_data_folio()
>   f2fs: Add f2fs_get_lock_data_folio()
>   f2fs: Convert move_data_page() to use a folio
>   f2fs: Convert truncate_partial_data_page() to use a folio
>   f2fs: Convert gc_data_segment() to use a folio
>   f2fs: Add f2fs_find_data_folio()
>   mm: Remove wait_on_page_locked()
> 
> [...]

Here is the summary with links:
  - [f2fs-dev,01/27] f2fs: Add f2fs_folio_wait_writeback()
    https://git.kernel.org/jaegeuk/f2fs/c/17683927d078
  - [f2fs-dev,02/27] mm: Remove wait_for_stable_page()
    https://git.kernel.org/jaegeuk/f2fs/c/36e1d6344aca
  - [f2fs-dev,03/27] f2fs: Add f2fs_folio_put()
    (no matching commit)
  - [f2fs-dev,04/27] f2fs: Convert f2fs_flush_inline_data() to use a folio
    https://git.kernel.org/jaegeuk/f2fs/c/015d9c56bd5e
  - [f2fs-dev,05/27] f2fs: Convert f2fs_sync_node_pages() to use a folio
    https://git.kernel.org/jaegeuk/f2fs/c/5d0a91284853
  - [f2fs-dev,06/27] f2fs: Pass a folio to flush_dirty_inode()
    https://git.kernel.org/jaegeuk/f2fs/c/de90f7614424
  - [f2fs-dev,07/27] f2fs: Convert f2fs_fsync_node_pages() to use a folio
    https://git.kernel.org/jaegeuk/f2fs/c/e23bebc3c0d2
  - [f2fs-dev,08/27] f2fs: Convert last_fsync_dnode() to use a folio
    https://git.kernel.org/jaegeuk/f2fs/c/18f3814fa6a8
  - [f2fs-dev,09/27] f2fs: Return a folio from last_fsync_dnode()
    https://git.kernel.org/jaegeuk/f2fs/c/e11a31139517
  - [f2fs-dev,10/27] f2fs: Add f2fs_grab_cache_folio()
    https://git.kernel.org/jaegeuk/f2fs/c/8d77f68daeb1
  - [f2fs-dev,11/27] mm: Remove grab_cache_page_write_begin()
    https://git.kernel.org/jaegeuk/f2fs/c/e33ce6bd4ea2
  - [f2fs-dev,12/27] f2fs: Use a folio in __get_node_page()
    https://git.kernel.org/jaegeuk/f2fs/c/48a34c598103
  - [f2fs-dev,13/27] f2fs: Use a folio in do_write_page()
    https://git.kernel.org/jaegeuk/f2fs/c/cd8f95718c89
  - [f2fs-dev,14/27] f2fs: Convert f2fs_write_end_io() to use a folio_iter
    https://git.kernel.org/jaegeuk/f2fs/c/fb9660481e3c
  - [f2fs-dev,15/27] f2fs: Mark some functions as taking a const page pointer
    https://git.kernel.org/jaegeuk/f2fs/c/521a46848690
  - [f2fs-dev,16/27] f2fs: Convert f2fs_in_warm_node_list() to take a folio
    https://git.kernel.org/jaegeuk/f2fs/c/1a58a41ccce6
  - [f2fs-dev,17/27] f2fs: Add f2fs_get_node_folio()
    https://git.kernel.org/jaegeuk/f2fs/c/4d417ae2bfce
  - [f2fs-dev,18/27] f2fs: Use a folio throughout f2fs_truncate_inode_blocks()
    https://git.kernel.org/jaegeuk/f2fs/c/520b17e093f4
  - [f2fs-dev,19/27] f2fs: Use a folio throughout __get_meta_page()
    https://git.kernel.org/jaegeuk/f2fs/c/922e24acb49e
  - [f2fs-dev,20/27] f2fs: Hoist the page_folio() call to the start of f2fs_merge_page_bio()
    https://git.kernel.org/jaegeuk/f2fs/c/b8fcb8423053
  - [f2fs-dev,21/27] f2fs: Add f2fs_get_read_data_folio()
    https://git.kernel.org/jaegeuk/f2fs/c/4ae71b1996ef
  - [f2fs-dev,22/27] f2fs: Add f2fs_get_lock_data_folio()
    https://git.kernel.org/jaegeuk/f2fs/c/20f974cd2124
  - [f2fs-dev,23/27] f2fs: Convert move_data_page() to use a folio
    https://git.kernel.org/jaegeuk/f2fs/c/6d1ba45c8db0
  - [f2fs-dev,24/27] f2fs: Convert truncate_partial_data_page() to use a folio
    https://git.kernel.org/jaegeuk/f2fs/c/ab907aa2a2f3
  - [f2fs-dev,25/27] f2fs: Convert gc_data_segment() to use a folio
    https://git.kernel.org/jaegeuk/f2fs/c/a86e109ee2c6
  - [f2fs-dev,26/27] f2fs: Add f2fs_find_data_folio()
    https://git.kernel.org/jaegeuk/f2fs/c/0cd402baa03b
  - [f2fs-dev,27/27] mm: Remove wait_on_page_locked()
    https://git.kernel.org/jaegeuk/f2fs/c/d96e2802a802

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 41+ messages in thread

end of thread, other threads:[~2025-03-04 17:10 UTC | newest]

Thread overview: 41+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-18  5:51 [PATCH 00/27] f2fs folio conversions for v6.15 Matthew Wilcox (Oracle)
2025-02-18  5:51 ` [PATCH 01/27] f2fs: Add f2fs_folio_wait_writeback() Matthew Wilcox (Oracle)
2025-02-18  5:51 ` [PATCH 02/27] mm: Remove wait_for_stable_page() Matthew Wilcox (Oracle)
2025-02-18  5:51 ` [PATCH 03/27] f2fs: Add f2fs_folio_put() Matthew Wilcox (Oracle)
2025-02-21  4:55   ` Jaegeuk Kim
2025-02-24  7:19     ` Jaegeuk Kim
2025-02-27 21:31       ` Jaegeuk Kim
2025-02-18  5:51 ` [PATCH 04/27] f2fs: Convert f2fs_flush_inline_data() to use a folio Matthew Wilcox (Oracle)
2025-02-18  5:51 ` [PATCH 05/27] f2fs: Convert f2fs_sync_node_pages() " Matthew Wilcox (Oracle)
2025-02-18  5:51 ` [PATCH 06/27] f2fs: Pass a folio to flush_dirty_inode() Matthew Wilcox (Oracle)
2025-02-18  5:51 ` [PATCH 07/27] f2fs: Convert f2fs_fsync_node_pages() to use a folio Matthew Wilcox (Oracle)
2025-02-18  5:51 ` [PATCH 08/27] f2fs: Convert last_fsync_dnode() " Matthew Wilcox (Oracle)
2025-02-18  5:51 ` [PATCH 09/27] f2fs: Return a folio from last_fsync_dnode() Matthew Wilcox (Oracle)
2025-02-18  5:51 ` [PATCH 10/27] f2fs: Add f2fs_grab_cache_folio() Matthew Wilcox (Oracle)
2025-02-18  5:51 ` [PATCH 11/27] mm: Remove grab_cache_page_write_begin() Matthew Wilcox (Oracle)
2025-02-18  5:51 ` [PATCH 12/27] f2fs: Use a folio in __get_node_page() Matthew Wilcox (Oracle)
2025-02-18  5:51 ` [PATCH 13/27] f2fs: Use a folio in do_write_page() Matthew Wilcox (Oracle)
2025-02-18  5:51 ` [PATCH 14/27] f2fs: Convert f2fs_write_end_io() to use a folio_iter Matthew Wilcox (Oracle)
2025-02-18  5:51 ` [PATCH 15/27] f2fs: Mark some functions as taking a const page pointer Matthew Wilcox (Oracle)
2025-02-18  5:51 ` [PATCH 16/27] f2fs: Convert f2fs_in_warm_node_list() to take a folio Matthew Wilcox (Oracle)
2025-02-18  5:51 ` [PATCH 17/27] f2fs: Add f2fs_get_node_folio() Matthew Wilcox (Oracle)
2025-03-01  1:15   ` Chao Yu
2025-03-01  1:59     ` Matthew Wilcox
2025-03-01  2:03     ` Matthew Wilcox
2025-03-03  3:15       ` Chao Yu
2025-02-18  5:51 ` [PATCH 18/27] f2fs: Use a folio throughout f2fs_truncate_inode_blocks() Matthew Wilcox (Oracle)
2025-02-18  5:51 ` [PATCH 19/27] f2fs: Use a folio throughout __get_meta_page() Matthew Wilcox (Oracle)
2025-02-18  5:51 ` [PATCH 20/27] f2fs: Hoist the page_folio() call to the start of f2fs_merge_page_bio() Matthew Wilcox (Oracle)
2025-02-28  7:25   ` Chao Yu
2025-02-18  5:51 ` [PATCH 21/27] f2fs: Add f2fs_get_read_data_folio() Matthew Wilcox (Oracle)
2025-02-28  7:37   ` Chao Yu
2025-02-18  5:51 ` [PATCH 22/27] f2fs: Add f2fs_get_lock_data_folio() Matthew Wilcox (Oracle)
2025-02-28  7:37   ` Chao Yu
2025-02-18  5:51 ` [PATCH 23/27] f2fs: Convert move_data_page() to use a folio Matthew Wilcox (Oracle)
2025-02-18  5:51 ` [PATCH 24/27] f2fs: Convert truncate_partial_data_page() " Matthew Wilcox (Oracle)
2025-02-18  5:51 ` [PATCH 25/27] f2fs: Convert gc_data_segment() " Matthew Wilcox (Oracle)
2025-02-18  5:52 ` [PATCH 26/27] f2fs: Add f2fs_find_data_folio() Matthew Wilcox (Oracle)
2025-02-18  5:52 ` [PATCH 27/27] mm: Remove wait_on_page_locked() Matthew Wilcox (Oracle)
2025-02-21  2:27 ` [PATCH 00/27] f2fs folio conversions for v6.15 Jaegeuk Kim
2025-03-04  8:04 ` Chao Yu
2025-03-04 17:10 ` [f2fs-dev] " patchwork-bot+f2fs

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).