mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2 1/2] f2fs: fix to fetch ino via ino_of_node() under cache lock
@ 2026-10-26  0:23 Chao Yu
  2026-10-26  0:23 ` [PATCH v2 2/2] f2fs: fix to update superblock crc in sanity_check_area_boundary() Chao Yu
  2026-10-26 15:40 ` [f2fs-dev] [PATCH v2 1/2] f2fs: fix to fetch ino via ino_of_node() under cache lock patchwork-bot+f2fs
  0 siblings, 2 replies; 3+ messages in thread
From: Chao Yu @ 2026-10-26  0:23 UTC (permalink / raw)
  To: jaegeuk; +Cc: linux-f2fs-devel, linux-kernel, Chao Yu, stable

From: Chao Yu <chao@kernel.org>

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 <chao@kernel.org>
---
v2:
- no changes
 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;
 			}
 
-- 
2.49.0


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

* [PATCH v2 2/2] f2fs: fix to update superblock crc in sanity_check_area_boundary()
  2026-10-26  0:23 [PATCH v2 1/2] f2fs: fix to fetch ino via ino_of_node() under cache lock Chao Yu
@ 2026-10-26  0:23 ` Chao Yu
  2026-10-26 15:40 ` [f2fs-dev] [PATCH v2 1/2] f2fs: fix to fetch ino via ino_of_node() under cache lock patchwork-bot+f2fs
  1 sibling, 0 replies; 3+ messages in thread
From: Chao Yu @ 2026-10-26  0:23 UTC (permalink / raw)
  To: jaegeuk; +Cc: linux-f2fs-devel, linux-kernel, Chao Yu, stable

From: Chao Yu <chao@kernel.org>

This patch fixes the bug reported by Sashiko:

We should update superblock crc along w/ raw_super->segment_count in
sanity_check_area_boundary() if sb_checksum feature is enabled.

Cc: stable@kernel.org
Fixes: d440c52d3151 ("f2fs: support superblock checksum")
Signed-off-by: Chao Yu <chao@kernel.org>
---
v2:
- update crc directly in sanity_check_area_boundary rather than calling
f2fs_commit_super() which will access NULL sbi->raw_super.
 fs/f2fs/super.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index b321b9cff351..37d208c6bb53 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -4084,6 +4084,12 @@ static inline bool sanity_check_area_boundary(struct f2fs_sb_info *sbi,
 		/* fix in-memory information all the time */
 		raw_super->segment_count = cpu_to_le32((main_end_blkaddr -
 				segment0_blkaddr) >> log_blocks_per_seg);
+		if (__F2FS_HAS_FEATURE(raw_super, F2FS_FEATURE_SB_CHKSUM)) {
+			__u32 crc = f2fs_crc32(raw_super,
+					offsetof(struct f2fs_super_block, crc));
+
+			raw_super->crc = cpu_to_le32(crc);
+		}
 
 		if (f2fs_readonly(sb) || f2fs_hw_is_readonly(sbi)) {
 			set_sbi_flag(sbi, SBI_NEED_SB_WRITE);
-- 
2.49.0


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

* Re: [f2fs-dev] [PATCH v2 1/2] f2fs: fix to fetch ino via ino_of_node() under cache lock
  2026-10-26  0:23 [PATCH v2 1/2] f2fs: fix to fetch ino via ino_of_node() under cache lock Chao Yu
  2026-10-26  0:23 ` [PATCH v2 2/2] f2fs: fix to update superblock crc in sanity_check_area_boundary() Chao Yu
@ 2026-10-26 15:40 ` patchwork-bot+f2fs
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+f2fs @ 2026-10-26 15:40 UTC (permalink / raw)
  To: Chao Yu; +Cc: jaegeuk, stable, linux-kernel, linux-f2fs-devel

Hello:

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

On Mon, 26 Oct 2026 08:23:49 +0800 you wrote:
> From: Chao Yu <chao@kernel.org>
> 
> 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").
> 
> [...]

Here is the summary with links:
  - [f2fs-dev,v2,1/2] f2fs: fix to fetch ino via ino_of_node() under cache lock
    https://git.kernel.org/jaegeuk/f2fs/c/cd6d8b189139
  - [f2fs-dev,v2,2/2] f2fs: fix to update superblock crc in sanity_check_area_boundary()
    https://git.kernel.org/jaegeuk/f2fs/c/f8f956c7ec8c

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] 3+ messages in thread

end of thread, other threads:[~2026-10-26 15:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-26  0:23 [PATCH v2 1/2] f2fs: fix to fetch ino via ino_of_node() under cache lock Chao Yu
2026-10-26  0:23 ` [PATCH v2 2/2] f2fs: fix to update superblock crc in sanity_check_area_boundary() Chao Yu
2026-10-26 15:40 ` [f2fs-dev] [PATCH v2 1/2] f2fs: fix to fetch ino via ino_of_node() under cache lock 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

all inboxes | Powered by JetHome®