From: sashiko-bot@kernel.org
To: "Xing Ma" <maxing.lan@bytedance.com>, linux-ext4@vger.kernel.org
Cc: tytso@mit.edu
Subject: Re: [PATCH 2/3] ext4: splice stranded fast commit staging queues before starting commit
Date: Mon, 30 Nov 2026 16:54:56 +0000 [thread overview]
Message-ID: <sashiko-outbox-241629@kernel.org> (raw)
In-Reply-To: <20261130163819.13819-3-maxing.lan@bytedance.com>
Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [High] ext4: dentry update reordering in ext4_fc_perform_commit()
staging splice
- [High] ext4: concurrent handle updates split by splice in
ext4_fc_perform_commit()
- [Low] ext4: inaccurate Fixes trailer in commit message for staging
queue race
--
commit 7490b868c8b70faeca81dcb7b1cdc8721e4fd438
Author: Xing Ma <maxing.lan@bytedance.com>
> ext4: splice stranded fast commit staging queues before starting commit
>
> In both __jbd2_fc_end_commit() and jbd2_journal_commit_transaction(),
> j_fc_cleanup_callback (ext4_fc_cleanup()) splices FC_Q_STAGING into
> FC_Q_MAIN and releases s_fc_lock BEFORE JBD2_FAST_COMMIT_ONGOING /
> JBD2_FULL_COMMIT_ONGOING is cleared under j_state_lock.
>
> If a concurrent writer calls ext4_fc_track_template() or
> __track_dentry_update() in that window, it still observes the ONGOING
> flag set and inserts its inode or dentry update onto FC_Q_STAGING after
> ext4_fc_cleanup() has already drained it. When that writer then calls
> fsync() after the flag clears, ext4_fc_perform_commit() only processes
> FC_Q_MAIN and writes an empty fast commit while the update remains
> stranded on FC_Q_STAGING.
>
> Splice s_fc_dentry_q[FC_Q_STAGING] and s_fc_q[FC_Q_STAGING] onto the
> tail of FC_Q_MAIN under s_fc_lock at Step 1 of ext4_fc_perform_commit()
> so any stranded updates are included in chronological order.
>
> Fixes: aa75f4d3daae ("ext4: main fast-commit commit path")
> Cc: stable@vger.kernel.org
> Signed-off-by: Xing Ma <maxing.lan@bytedance.com>
[Severity: Low]
In aa75f4d3daae ("ext4: main fast-commit commit path"),
ext4_fc_track_template() and __track_dentry_update() checked
EXT4_FC_COMMITTING under s_fc_lock, and ext4_fc_cleanup() cleared
EXT4_FC_COMMITTING inside the same s_fc_lock critical section right after
splicing FC_Q_STAGING into FC_Q_MAIN. The post-cleanup window only
appeared when queue selection was switched to JBD2_FULL_COMMIT_ONGOING and
JBD2_FAST_COMMIT_ONGOING. Should the Fixes: tag instead be:
Fixes: bdc8a53a6f2f ("ext4: fast commit may miss file actions")
> diff --git a/fs/ext4/fast_commit.c b/fs/ext4/fast_commit.c
> index 03ab9b8a2d983..e03a829e2a10a 100644
> --- a/fs/ext4/fast_commit.c
> +++ b/fs/ext4/fast_commit.c
> @@ -1353,11 +1353,17 @@ static int ext4_fc_perform_commit(journal_t *journal, tid_t commit_tid)
> u64 locked_ns;
>
> /*
> - * Step 1: Mark all inodes on s_fc_q[MAIN] with
> - * EXT4_STATE_FC_FLUSHING_DATA. This prevents these inodes from being
> - * freed until the data flush is over.
> + * Step 1: Splice any entries that landed on STAGING while the
> + * previous commit was clearing its ONGOING flag, then mark all
> + * inodes on s_fc_q[MAIN] with EXT4_STATE_FC_FLUSHING_DATA. This
> + * prevents these inodes from being freed until the data flush is
> + * over.
> */
> alloc_ctx = ext4_fc_lock(sb);
> + list_splice_tail_init(&sbi->s_fc_dentry_q[FC_Q_STAGING],
> + &sbi->s_fc_dentry_q[FC_Q_MAIN]);
[Severity: High]
Does list_splice_tail_init() on s_fc_dentry_q[FC_Q_STAGING] invert the
order of stranded dentry updates relative to updates queued after the
ONGOING flag clears?
CPU0 (previous commit) CPU1 (writer)
ext4_fc_cleanup()
splice STAGING -> MAIN
ext4_fc_unlock()
unlink("foo")
__track_dentry_update()
/* ONGOING still set */
list_add_tail(D1, STAGING)
clear JBD2_FAST_COMMIT_ONGOING
creat("foo")
__track_dentry_update()
/* ONGOING now clear */
list_add_tail(D2, MAIN)
fsync()
ext4_fc_perform_commit()
list_splice_tail_init(STAGING, MAIN)
/* MAIN is now [D2, D1] */
The same inversion can also happen within a single overwriting
ext4_rename(), which acquires and releases s_fc_lock separately for
ext4_fc_track_unlink(), __ext4_fc_track_link() and
__ext4_fc_track_unlink().
Because ext4_fc_commit_dentry_updates() writes TLVs in
s_fc_dentry_q[FC_Q_MAIN] order, crash recovery replays the newer link or
creat (D2) before the older unlink (D1). In
ext4_fc_replay_link_internal(), __ext4_link() returns -EEXIST and is
ignored, and the subsequent unlink replay deletes the newly created or
renamed directory entry.
> + list_splice_tail_init(&sbi->s_fc_q[FC_Q_STAGING],
> + &sbi->s_fc_q[FC_Q_MAIN]);
[Severity: High]
Can splicing FC_Q_STAGING into FC_Q_MAIN here split a concurrent journal
handle's updates across two fast commits?
ext4_fc_commit() calls jbd2_fc_begin_commit(), which sets
JBD2_FAST_COMMIT_ONGOING before calling ext4_fc_perform_commit(), while
active handles are not drained until jbd2_journal_lock_updates() in
Step 4:
CPU0 (fsync) CPU1 (ext4_create)
jbd2_fc_begin_commit()
set JBD2_FAST_COMMIT_ONGOING
ext4_new_inode_start_handle()
ext4_fc_track_inode()
/* ONGOING set -> STAGING */
list_add_tail(inode,
s_fc_q[STAGING])
ext4_fc_perform_commit()
/* Step 1 */
list_splice_tail_init(STAGING,
MAIN)
/* inode moved to MAIN */
ext4_fc_track_create()
/* queued after Step 1 splice */
list_add_tail(CREAT,
s_fc_dentry_q[STAGING])
/* Step 4 */
jbd2_journal_lock_updates()
ext4_fc_snapshot_inodes()
/* snapshots inode on MAIN,
* resets i_fc_lblk_len = 0 */
/* Step 6 */
/* writes inode without CREAT;
* ext4_fc_cleanup() drops inode
* from MAIN and moves CREAT to
* MAIN for the next commit */
Any extent updates tracked on the new inode before Step 4 sets
EXT4_STATE_FC_COMMITTING do not set EXT4_STATE_FC_REQUEUE, so the current
fast commit logs the inode and its extents without EXT4_FC_TAG_CREAT and
removes the inode from s_fc_q[FC_Q_MAIN], leaving EXT4_FC_TAG_CREAT for a
later fast commit where i_fc_lblk_len has already been cleared. Multi-step
dentry operations under one handle (such as ext4_rename() or
__ext4_unlink()) can likewise have their earlier tracking calls spliced
into the current fast commit while their remaining calls stay in
FC_Q_STAGING.
Would splicing FC_Q_STAGING into FC_Q_MAIN in jbd2_fc_begin_commit() (or
in ext4_fc_cleanup() after the ONGOING flag is cleared) while holding
s_fc_lock avoid racing with handles that observe the new commit's
JBD2_FAST_COMMIT_ONGOING flag?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261130163819.13819-1-maxing.lan@bytedance.com?part=2
next prev parent reply other threads:[~2026-11-30 16:55 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-30 16:38 [PATCH 0/3] ext4: fix concurrent fast commit durability and tracking races Xing Ma
2026-11-30 16:38 ` [PATCH 1/3] ext4: do not skip fast commit for updates queued during ongoing commit Xing Ma
2026-11-30 16:57 ` sashiko-bot
2026-11-30 16:38 ` [PATCH 2/3] ext4: splice stranded fast commit staging queues before starting commit Xing Ma
2026-11-30 16:54 ` sashiko-bot [this message]
2026-11-30 16:38 ` [PATCH 3/3] ext4: keep tracking newer transactions while older tid is fc-ineligible Xing Ma
2026-11-30 16:58 ` sashiko-bot
2026-12-01 6:13 ` kernel test robot
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=sashiko-outbox-241629@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-ext4@vger.kernel.org \
--cc=maxing.lan@bytedance.com \
--cc=sashiko-reviews@lists.linux.dev \
--cc=tytso@mit.edu \
/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 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.