From: sashiko-bot@kernel.org
To: "Xing Ma" <maxing.lan@bytedance.com>, linux-ext4@vger.kernel.org
Cc: tytso@mit.edu
Subject: Re: [PATCH 1/3] ext4: do not skip fast commit for updates queued during ongoing commit
Date: Mon, 30 Nov 2026 16:57:56 +0000 [thread overview]
Message-ID: <sashiko-outbox-241645@kernel.org> (raw)
In-Reply-To: <20261130163819.13819-2-maxing.lan@bytedance.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] ext4: double-counted target_subtid in ext4_fc_commit() during
cleanup
--
commit b8e5dbb706be86ee24d82de27b0c55791a280c70
Author: Xing Ma <maxing.lan@bytedance.com>
ext4: do not skip fast commit for updates queued during ongoing commit
This commit samples s_fc_subtid and JBD2_FAST_COMMIT_ONGOING under
j_state_lock at entry to ext4_fc_commit() so callers wait for an
additional fast commit when one is already in progress.
> diff --git a/fs/ext4/fast_commit.c b/fs/ext4/fast_commit.c
> index 9beb423b208f8..03ab9b8a2d983 100644
> --- a/fs/ext4/fast_commit.c
> +++ b/fs/ext4/fast_commit.c
> @@ -1588,7 +1588,7 @@ int ext4_fc_commit(journal_t *journal, tid_t commit_tid)
> struct super_block *sb = journal->j_private;
> struct ext4_sb_info *sbi = EXT4_SB(sb);
> int nblks = 0, ret, bsize = journal->j_blocksize;
> - int subtid = atomic_read(&sbi->s_fc_subtid);
> + int target_subtid;
> int status = EXT4_FC_STATUS_OK, fc_bufs_before = 0;
> ktime_t start_time, commit_time;
> int old_ioprio, journal_ioprio;
> @@ -1601,11 +1601,24 @@ int ext4_fc_commit(journal_t *journal, tid_t commit_tid)
> start_time = ktime_get();
> old_ioprio = get_current_ioprio();
>
> + /*
> + * If a fast commit is already ongoing when we enter ext4_fc_commit(),
> + * updates made by this caller may have been queued on FC_Q_STAGING or
> + * marked EXT4_STATE_FC_REQUEUE and will not be included in that
> + * ongoing fast commit. Require a subsequent fast commit (or a full
> + * commit of commit_tid) before skipping.
> + */
> + read_lock(&journal->j_state_lock);
> + target_subtid = atomic_read(&sbi->s_fc_subtid) + 1;
> + if (journal->j_flags & JBD2_FAST_COMMIT_ONGOING)
> + target_subtid++;
> + read_unlock(&journal->j_state_lock);
[Severity: Medium]
Can target_subtid be incremented twice for the same ongoing fast commit
when ext4_fc_commit() enters while another commit is in cleanup?
ext4_fc_commit() increments sbi->s_fc_subtid before calling
jbd2_fc_end_commit(), whereas __jbd2_fc_end_commit() clears
JBD2_FAST_COMMIT_ONGOING only after j_fc_cleanup_callback()
(ext4_fc_cleanup()) returns:
CPU0 (s_fc_subtid == N) CPU1
ext4_fc_commit()
...
atomic_inc(&sbi->s_fc_subtid)
-> N + 1
jbd2_fc_end_commit()
__jbd2_fc_end_commit()
ext4_fc_cleanup()
ext4_fc_commit()
read_lock(&journal->j_state_lock)
target_subtid = (N + 1) + 1
JBD2_FAST_COMMIT_ONGOING is set
-> target_subtid = N + 3
read_unlock(&journal->j_state_lock)
write_lock(&journal->j_state_lock)
j_flags &= ~JBD2_FAST_COMMIT_ONGOING
write_unlock(&journal->j_state_lock)
After the next fast commit (N + 2) commits the updates spliced onto
FC_Q_MAIN during CPU0's cleanup, CPU1 wakes from jbd2_fc_begin_commit()
with s_fc_subtid == N + 2 < target_subtid (N + 3) and restarts to run an
extra fast commit.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261130163819.13819-1-maxing.lan@bytedance.com?part=1
next prev parent reply other threads:[~2026-11-30 16:57 UTC|newest]
Thread overview: 7+ 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 [this message]
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
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-241645@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox