Re: [PATCH] f2fs: wait for node writeback on the first fsync after a checkpoint

From: Chao Yu

Date: Wed Nov 11 2026 - 03:23:48 EST


On 11/3/26 18:12, Seungbum Ju wrote:
> f2fs_add_fsync_node_entry() numbers each fsync'd warm node page with
> sbi->fsync_seg_id++, and f2fs_reset_fsync_node_info() sets the counter back
> to 0 at every checkpoint. The first node page fsync'd after a checkpoint
> therefore gets seq_id 0, which f2fs_do_sync_file() passes to
> f2fs_wait_on_node_pages_writeback(). That function treats 0 as "nothing to
> wait for":
>
> while (seq_id && cur_seq_id < seq_id) {
>
> so the fsync issues its cache flush without waiting for its own node page.
> If the flush completes before the node write, the inode's fsync-marked
> node block (needed by roll-forward recovery) is not covered by the flush,
> and a power loss can lose data that fsync reported as durable. In our
> traces the first fsync after a checkpoint returned before its node write
> completed in many trials.
>
> Start the numbering at 1, so that 0 keeps meaning "no node page written".
>
> Testing (kernel 7.0.0-42, f2fs built as a module from the same source,
> QEMU/KVM, block-layer FLUSH/FUA model with dm-log-writes replay):
> - block traces, append+fsync after sync: FLUSH issued before the node
> write completed in 29/30 first fsyncs unpatched, 0/30 patched; never
> for later fsyncs;
> - crash-state replay (28 cells x 3 recordings per module): SQLite
> WAL/TRUNCATE/PERSIST, LevelDB, RocksDB, LMDB and an append log lose
> acknowledged commits or become unopenable in 24 cells unpatched, and
> are clean in all of them patched.
>
> The same code is present in Android GKI android12-5.10 through
> android15-6.6 and in the f2fs dev tree as of 2026-11-02.
>
> Fixes: 50fa53eccf9f ("f2fs: fix to avoid broken of dnode block list")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Seungbum Ju <seungbum.ju@xxxxxxxxx>
Reviewed-by: Chao Yu <chao@xxxxxxxxxx>

Thanks,