linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
To: Jaegeuk Kim <jaegeuk@kernel.org>, Chao Yu <chao@kernel.org>
Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>,
	linux-f2fs-devel@lists.sourceforge.net,
	linux-fsdevel@vger.kernel.org
Subject: [PATCH 09/27] f2fs: Return a folio from last_fsync_dnode()
Date: Tue, 18 Feb 2025 05:51:43 +0000	[thread overview]
Message-ID: <20250218055203.591403-10-willy@infradead.org> (raw)
In-Reply-To: <20250218055203.591403-1-willy@infradead.org>

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


  parent reply	other threads:[~2025-02-18  5:52 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` Matthew Wilcox (Oracle) [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250218055203.591403-10-willy@infradead.org \
    --to=willy@infradead.org \
    --cc=chao@kernel.org \
    --cc=jaegeuk@kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-fsdevel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).