From: sashiko-bot@kernel.org
To: "Xing Ma" <maxing.lan@bytedance.com>, linux-ext4@vger.kernel.org
Cc: tytso@mit.edu
Subject: Re: [PATCH 3/3] ext4: keep tracking newer transactions while older tid is fc-ineligible
Date: Mon, 30 Nov 2026 16:58:33 +0000 [thread overview]
Message-ID: <sashiko-outbox-241648@kernel.org> (raw)
In-Reply-To: <20261130163819.13819-4-maxing.lan@bytedance.com>
Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [High] ext4: ext4_rename() checks EXT4_MF_FC_INELIGIBLE causing torn
fc tracking
- [Medium] ext4: ordering race in ext4_fc_cleanup() passes
s_fc_ineligible_tid=0 to tid_gt()
- [Low] ext4: unused static ext4_fc_eligible() when
CONFIG_EXT4_KUNIT_TESTS=n
--
commit ab665c709db8ebc5f4e6685eece8b5ca94164b47
Author: Xing Ma <maxing.lan@bytedance.com>
ext4: keep tracking newer transactions while older tid is fc-ineligible
This commit introduces ext4_fc_handle_eligible() so that handles in a
newer transaction continue tracking fast-commit updates while an older
ineligible transaction is still committing, and only clears
EXT4_MF_FC_INELIGIBLE in ext4_fc_cleanup() on a full commit.
> diff --git a/fs/ext4/fast_commit.c b/fs/ext4/fast_commit.c
> index e03a829e2a10a..27e54ffa4ae5e 100644
> --- a/fs/ext4/fast_commit.c
> +++ b/fs/ext4/fast_commit.c
> @@ -235,6 +235,31 @@ static bool ext4_fc_eligible(struct super_block *sb)
> !(ext4_test_mount_flag(sb, EXT4_MF_FC_INELIGIBLE));
> }
>
> +static bool ext4_fc_handle_eligible(struct super_block *sb, handle_t *handle)
> +{
> + struct ext4_sb_info *sbi = EXT4_SB(sb);
> +
> + if (ext4_fc_disabled(sb))
> + return false;
> + if (!ext4_test_mount_flag(sb, EXT4_MF_FC_INELIGIBLE))
> + return true;
> + if (!handle || !handle->h_transaction)
> + return false;
> + /*
> + * EXT4_MF_FC_INELIGIBLE may still be set for an older committing
> + * transaction while new handles are already modifying the next running
> + * transaction. Continue tracking handles whose TID is newer than
> + * s_fc_ineligible_tid so the next transaction is completely tracked
> + * once the older full commit clears EXT4_MF_FC_INELIGIBLE.
> + *
> + * Pairs with smp_wmb() in ext4_fc_mark_ineligible() and
> + * ext4_fc_cleanup().
> + */
> + smp_rmb();
> + return tid_gt(handle->h_transaction->t_tid,
> + READ_ONCE(sbi->s_fc_ineligible_tid));
> +}
[Severity: Low]
Does leaving ext4_fc_eligible() unconditionally defined trigger a
-Wunused-function warning when CONFIG_EXT4_KUNIT_TESTS is disabled?
All non-test callers of ext4_fc_eligible() are replaced with
ext4_fc_handle_eligible(), leaving ext4_fc_eligible_test() under
#if IS_ENABLED(CONFIG_EXT4_KUNIT_TESTS) as the only caller.
[ ... ]
> @@ -513,7 +540,7 @@ void ext4_fc_track_unlink(handle_t *handle, struct dentry *dentry)
> {
> struct inode *inode = d_inode(dentry);
>
> - if (ext4_fc_eligible(inode->i_sb))
> + if (ext4_fc_handle_eligible(inode->i_sb, handle))
> __ext4_fc_track_unlink(handle, inode, dentry);
> }
[Severity: High]
Can a rename in transaction T + 1 still suffer torn fast-commit tracking
while transaction T is committing?
ext4_rename() calls ext4_fc_track_unlink(handle, new.dentry), which now
uses ext4_fc_handle_eligible(), but then checks EXT4_MF_FC_INELIGIBLE
directly before tracking the link and unlink of the renamed file:
fs/ext4/namei.c:ext4_rename() {
...
if (new.inode)
ext4_fc_track_unlink(handle, new.dentry);
if (test_opt2(sb, JOURNAL_FAST_COMMIT) &&
!(EXT4_SB(sb)->s_mount_state & EXT4_FC_REPLAY) &&
!(ext4_test_mount_flag(sb, EXT4_MF_FC_INELIGIBLE))) {
__ext4_fc_track_link(handle, old.inode, new.dentry);
__ext4_fc_track_unlink(handle, old.inode, old.dentry);
if (whiteout)
__ext4_fc_track_create(handle, whiteout,
old.dentry);
}
...
}
For an overwriting rename in T + 1 while T is performing a full commit,
fast commit tracks EXT4_FC_TAG_UNLINK for new.dentry (and the inode
updates via ext4_mark_inode_dirty()) without tracking EXT4_FC_TAG_LINK for
new.dentry or EXT4_FC_TAG_UNLINK for old.dentry. Once T finishes and a
subsequent fsync() commits T + 1, crash recovery replays the destination
unlink without linking the replacement file.
[ ... ]
> @@ -1782,9 +1809,11 @@ static void ext4_fc_cleanup(journal_t *journal, int full, tid_t tid)
> list_splice_init(&sbi->s_fc_q[FC_Q_STAGING],
> &sbi->s_fc_q[FC_Q_MAIN]);
>
> - if (tid_geq(tid, sbi->s_fc_ineligible_tid)) {
> - sbi->s_fc_ineligible_tid = 0;
> + if (full && tid_geq(tid, sbi->s_fc_ineligible_tid)) {
> ext4_clear_mount_flag(sb, EXT4_MF_FC_INELIGIBLE);
> + /* Pairs with smp_rmb() in ext4_fc_handle_eligible(). */
> + smp_wmb();
> + WRITE_ONCE(sbi->s_fc_ineligible_tid, 0);
> }
[Severity: Medium]
Can ext4_fc_handle_eligible() race with ext4_fc_cleanup() and pass
s_fc_ineligible_tid == 0 to tid_gt()?
Because both functions access EXT4_MF_FC_INELIGIBLE before
s_fc_ineligible_tid, a reader can see the flag set and then read the
zeroed TID:
CPU0 CPU1
ext4_fc_handle_eligible() ext4_fc_cleanup()
ext4_test_mount_flag(
..., EXT4_MF_FC_INELIGIBLE) == 1
ext4_clear_mount_flag(
..., EXT4_MF_FC_INELIGIBLE)
smp_wmb()
WRITE_ONCE(
sbi->s_fc_ineligible_tid, 0)
smp_rmb()
tid_gt(t_tid, 0) <-- false when t_tid >= 0x80000000
As noted in ebc4b2c1ac92 ("ext4: fix incorrect tid assumption in
ext4_fc_mark_ineligible()"), tid_gt() uses signed 32-bit subtraction
((int)(x - y) > 0), so tid_gt(t_tid, 0) returns false whenever t_tid has
bit 31 set, causing ext4_fc_handle_eligible() to skip tracking for
transaction T + 1.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261130163819.13819-1-maxing.lan@bytedance.com?part=3
next prev parent reply other threads:[~2026-11-30 16:58 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
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 [this message]
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-241648@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.