All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christian Brauner <brauner@kernel.org>
To: linux-fsdevel@vger.kernel.org, Jan Kara <jack@suse.cz>
Cc: Josef Bacik <josef@toxicpanda.com>,
	Chris Mason <mason@kernel.org>,
	 linux-ext4@vger.kernel.org,
	OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>,
	 Andreas Dilger <adilger.kernel@dilger.ca>,
	 Baokun Li <libaokun@linux.alibaba.com>,
	 Ojaswin Mujoo <ojaswin@linux.ibm.com>,
	 "Ritesh Harjani (IBM)" <ritesh.list@gmail.com>,
	 Namjae Jeon <namjae.jeon@samsung.com>,
	 "Christian Brauner (Amutable)" <brauner@kernel.org>,
	stable@vger.kernel.org
Subject: [PATCH RFC v2 04/13] ext4: use sb_find_get_block_nonatomic() in ext4_get_inode_loc_noio()
Date: Thu, 05 Nov 2026 13:41:33 +0100	[thread overview]
Message-ID: <20261105-work-inode-metadata_writeback-v2-4-48628c60c336@kernel.org> (raw)
In-Reply-To: <20261105-work-inode-metadata_writeback-v2-0-48628c60c336@kernel.org>

ext4_get_inode_loc_noio() looks the inode table block up with
sb_find_get_block(). That's the atomic lookup. It serializes against
try_to_free_buffers() with i_private_lock instead of the folio lock and
gives up if the folio is being migrated. So it can report the block as
not cached while it is.

For ext4_fc_snapshot_inode() that only means falling back to a full
commit. But ext4_sync_inode_metadata() is going to use
ext4_get_inode_loc_noio() to find the inode block that fsync() has to
write out and there a dirty block must not be skipped.

ext4_fc_snapshot_inode() is the only caller and it can sleep. It runs
under jbd2_journal_lock_updates() and allocates the snapshot with
GFP_NOFS. So use sb_find_get_block_nonatomic() which takes the folio
lock and waits for the migration instead.

Suggested-by: Jan Kara <jack@suse.cz>
Cc: stable@vger.kernel.org # v7.3
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
---
 fs/ext4/inode.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index b4d581aa5ee1..4484c2383eaf 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -5876,7 +5876,8 @@ int ext4_get_inode_loc(struct inode *inode, struct ext4_iloc *iloc)
 /*
  * ext4_get_inode_loc_noio() is a best-effort variant of ext4_get_inode_loc().
  * It looks up the inode table block in the buffer cache and returns -EAGAIN if
- * the block is not present or not uptodate, without starting any I/O.
+ * the block is not present or not uptodate, without starting any I/O. It may
+ * sleep on the folio lock of the block.
  */
 int ext4_get_inode_loc_noio(struct inode *inode, struct ext4_iloc *iloc)
 {
@@ -5912,7 +5913,7 @@ int ext4_get_inode_loc_noio(struct inode *inode, struct ext4_iloc *iloc)
 	}
 	block += inode_offset / inodes_per_block;
 
-	bh = sb_find_get_block(sb, block);
+	bh = sb_find_get_block_nonatomic(sb, block);
 	if (!bh)
 		return -EAGAIN;
 	if (!ext4_buffer_uptodate(bh)) {

-- 
2.53.0


  parent reply	other threads:[~2026-11-05 12:42 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-05 12:41 [PATCH RFC v2 00/13] fs: reclaim inodes with I_METADATA_WRITEBACK Christian Brauner
2026-11-05 12:41 ` [PATCH RFC v2 01/13] ext2: add ext2_inode_block() helper Christian Brauner
2026-11-05 12:52   ` sashiko-bot
2026-11-05 12:41 ` [PATCH RFC v2 02/13] ext2: don't read the inode block in ext2_sync_inode_metadata() Christian Brauner
2026-11-05 12:47   ` sashiko-bot
2026-11-05 12:41 ` [PATCH RFC v2 03/13] ext2: sync inode metadata in ext2_evict_inode() Christian Brauner
2026-11-05 12:49   ` sashiko-bot
2026-11-06 15:50   ` Jan Kara
2026-11-05 12:41 ` Christian Brauner [this message]
2026-11-05 12:46   ` [PATCH RFC v2 04/13] ext4: use sb_find_get_block_nonatomic() in ext4_get_inode_loc_noio() sashiko-bot
2026-11-06 15:20   ` Jan Kara
2026-11-05 12:41 ` [PATCH RFC v2 05/13] ext4: don't read the inode block in ext4_sync_inode_metadata() Christian Brauner
2026-11-05 12:48   ` sashiko-bot
2026-11-06 15:20   ` Jan Kara
2026-11-05 12:41 ` [PATCH RFC v2 06/13] ext4: sync inode metadata in ext4_evict_inode() Christian Brauner
2026-11-05 12:54   ` sashiko-bot
2026-11-05 12:41 ` [PATCH RFC v2 07/13] minix: add minix_inode_block() helper Christian Brauner
2026-11-05 12:45   ` sashiko-bot
2026-11-05 12:41 ` [PATCH RFC v2 08/13] minix: don't read the inode block in minix_sync_inode_metadata() Christian Brauner
2026-11-05 12:46   ` sashiko-bot
2026-11-05 12:41 ` [PATCH RFC v2 09/13] minix: sync inode metadata in minix_evict_inode() Christian Brauner
2026-11-05 12:46   ` sashiko-bot
2026-11-05 12:41 ` [PATCH RFC v2 10/13] udf: don't allocate the inode block in udf_sync_inode_metadata() Christian Brauner
2026-11-05 12:49   ` sashiko-bot
2026-11-05 12:41 ` [PATCH RFC v2 11/13] udf: sync inode metadata in udf_evict_inode() Christian Brauner
2026-11-05 12:54   ` sashiko-bot
2026-11-05 12:41 ` [PATCH RFC v2 12/13] fat: sync inode metadata in fat_evict_inode() Christian Brauner
2026-11-05 13:06   ` sashiko-bot
2026-11-05 12:41 ` [PATCH RFC v2 13/13] fs: don't strand I_METADATA_WRITEBACK inodes outside the LRU Christian Brauner
2026-11-05 12:55   ` sashiko-bot
2026-11-06 15:22   ` Jan Kara

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=20261105-work-inode-metadata_writeback-v2-4-48628c60c336@kernel.org \
    --to=brauner@kernel.org \
    --cc=adilger.kernel@dilger.ca \
    --cc=hirofumi@mail.parknet.co.jp \
    --cc=jack@suse.cz \
    --cc=josef@toxicpanda.com \
    --cc=libaokun@linux.alibaba.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=mason@kernel.org \
    --cc=namjae.jeon@samsung.com \
    --cc=ojaswin@linux.ibm.com \
    --cc=ritesh.list@gmail.com \
    --cc=stable@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.