From cd6d8b1891395b681f2060916a4b83880b765698 Mon Sep 17 00:00:00 2001 From: Chao Yu Date: Mon, 26 Oct 2026 08:23:49 +0800 Subject: [PATCH] f2fs: fix to fetch ino via ino_of_node() under cache lock In f2fs_writeback_node_caches(), it's better to fetch ino via ino_of_node() under cache lock, otherwise, node cache content may become stale after cache is unlocked due to racing w/ truncation. Commit 493b9dc8b52c ("f2fs: cache: use node cache") fixes similar issue in f2fs_flush_inline_data() introduced in commit 34c061ad85a2 ("f2fs: Avoid double lock for cp_rwsem during checkpoint"). Cc: stable@kernel.org Fixes: 2049d4fcb057 ("f2fs: avoid multiple node page writes due to inline_data") Signed-off-by: Chao Yu Signed-off-by: Jaegeuk Kim --- fs/f2fs/node.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c index 424e95ca5878..44f94000d452 100644 --- a/fs/f2fs/node.c +++ b/fs/f2fs/node.c @@ -2195,9 +2195,11 @@ int f2fs_writeback_node_caches(struct f2fs_sb_info *sbi, long nr_to_write, /* flush inline_data */ if (f2fs_cache_test_inline(entry)) { + nid_t ino = ino_of_node(sbi, entry); + f2fs_cache_clear_inline(entry); f2fs_unlock_cache(entry); - flush_inline_data(sbi, ino_of_node(sbi, entry)); + flush_inline_data(sbi, ino); goto lock_node; }