From: Seungbum Ju <seungbum.ju@gmail.com>
To: Jaegeuk Kim <jaegeuk@kernel.org>, Chao Yu <chao@kernel.org>
Cc: linux-f2fs-devel@lists.sourceforge.net,
linux-kernel@vger.kernel.org, stable@vger.kernel.org,
Seungbum Ju <seungbum.ju@gmail.com>
Subject: [PATCH] f2fs: wait for node writeback on the first fsync after a checkpoint
Date: Tue, 3 Nov 2026 19:12:08 +0900 [thread overview]
Message-ID: <20261103101208.4550-1-seungbum.ju@gmail.com> (raw)
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@vger.kernel.org
Signed-off-by: Seungbum Ju <seungbum.ju@gmail.com>
---
fs/f2fs/node.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index 1234567..89abcdef 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -361,7 +361,7 @@ static unsigned int f2fs_add_fsync_node_entry(struct f2fs_sb_info *sbi,
spin_lock_irqsave(&sbi->fsync_node_lock, flags);
list_add_tail(&fn->list, &sbi->fsync_node_list);
- fn->seq_id = sbi->fsync_seg_id++;
+ fn->seq_id = ++sbi->fsync_seg_id;
seq_id = fn->seq_id;
sbi->fsync_node_num++;
spin_unlock_irqrestore(&sbi->fsync_node_lock, flags);
--
2.45.0
reply other threads:[~2026-11-03 10:12 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261103101208.4550-1-seungbum.ju@gmail.com \
--to=seungbum.ju@gmail.com \
--cc=chao@kernel.org \
--cc=jaegeuk@kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--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 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®