All of lore.kernel.org
 help / color / mirror / Atom feed
* [f2fs-dev] [PATCH 0/2] f2fs: fix data consistency issue caused by nat_entry flag
@ 2026-03-10  9:36 Yongpeng Yang
  2026-03-10  9:36 ` [f2fs-dev] [PATCH 1/2] f2fs: fix fsck inconsistency caused by incorrect nat_entry flag usage Yongpeng Yang
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Yongpeng Yang @ 2026-03-10  9:36 UTC (permalink / raw)
  To: Chao Yu, Jaegeuk Kim; +Cc: Yongpeng Yang, Yongpeng Yang, linux-f2fs-devel

From: Yongpeng Yang <yangyongpeng@xiaomi.com>

This patchset addresses a data consistency issue caused by the lack of
mutual exclusion between checks of the HAS_FSYNCED_INODE,
IS_CHECKPOINTED, and HAS_LAST_FSYNC flags and the checkpoint write path.

In f2fs_flush_nat_entries(), after writing back the NAT block, the code
sets HAS_LAST_FSYNC and IS_CHECKPOINTED, and clears HAS_FSYNCED_INODE.
Although accesses and updates to these flags are protected by
nm_i->nat_tree_lock, observing this state in the fsync context does not
guarantee that the corresponding nat_entry state has already been
persisted to the device.

The root cause is that the semantics of these three flags are only
guaranteed after the checkpoint write completes, while the fsync path
does not follow this constraint.

This patchset ensures that accesses and updates to nat_entry flags in
the fsync path are protected by sbi->node_write.

There are still call paths not protected by sbi->node_write:
need_do_checkpoint()->f2fs_is_checkpointed_node() and
need_do_checkpoint()->f2fs_need_dentry_mark().

The flags obtained in these paths may be imprecise, but they only affect
whether a checkpoint is triggered and do not impact consistency. Adding
lock protection here would increase lock contention, so these paths are
left unchanged.

Yongpeng Yang (2):
  f2fs: fix fsck inconsistency caused by incorrect nat_entry flag usage
  f2fs: fix data loss caused by incorrect use of nat_entry flags

 fs/f2fs/node.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

-- 
2.43.0



_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

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

end of thread, other threads:[~2026-03-24 17:32 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-10  9:36 [f2fs-dev] [PATCH 0/2] f2fs: fix data consistency issue caused by nat_entry flag Yongpeng Yang
2026-03-10  9:36 ` [f2fs-dev] [PATCH 1/2] f2fs: fix fsck inconsistency caused by incorrect nat_entry flag usage Yongpeng Yang
2026-03-11  8:39   ` Chao Yu via Linux-f2fs-devel
2026-03-11 18:16   ` Jaegeuk Kim via Linux-f2fs-devel
2026-03-12  1:13     ` Chao Yu via Linux-f2fs-devel
2026-03-12  4:01     ` Yongpeng Yang
2026-03-10  9:36 ` [f2fs-dev] [PATCH 2/2] f2fs: fix data loss caused by incorrect use of nat_entry flag Yongpeng Yang
2026-03-11  8:48   ` Chao Yu via Linux-f2fs-devel
2026-03-24 17:32 ` [f2fs-dev] [PATCH 0/2] f2fs: fix data consistency issue caused by " patchwork-bot+f2fs--- via Linux-f2fs-devel

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.