From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796057700; b=gbG04AytMGn5yTjnE+QT6kX9jzIiGcLigCgUKsxTegcWtQ6UzyMLSI9YBm2SCLASrpjf +fNUimCmgUBAWRaEwhnzlhMzhw5t+9RHWtKPVMIK7KmcJPs+gffIzdfvb9PeUvx5YGc1f znNjpr7KpsVsgajJ9Rt1kAfQBLryv7PavNiiaUEGTS8YwmxWMxw8boSiHo9ASIT47C2gn zIkHnq28RBfevTqJ2VqkazLOVr/flmGAxAzgnf5z5AjtGzd3/5rOzm+5W9vuYpbwBhKfX YmWbTt8pzkSaY+gsJEUDhjZbxJjtOv0Xl/D1/FrUzZoI++nebZi3PkbEx31cLJ+BY2w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796057700; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=ldliq1D/Upona/iWQ6stkHoLpvc6UngyKMDEe64DEVc=; b=NIIWZdlilmAy8o7+hGxYkGDrM1iHD53Xcqq+8Q3UIA7bmf5V8i5dtf8SHnlUKrKSP6kk YSaAj2J7orb+Hdrge/F2eHzqO5aNkccn3lFe1UbCs1gyjts9y8HbK6Z5uCnLZLTNAKMnT YYQqhSmeBmqeykDlrT1bFsNWAtc7iCy7Cqd8utf+2UXLTjZfuDWbTio/HI296iaqVacGw 1R16oHNbwUQSpCGCISfBDpfX3RzpubKlDVKU7ZnF71r+R+DS73FWMArPWXP3wlll2g2M2 cApEmjJ36UStak5hfa87cbbTyAt7BhOek6zZnXodDq0uWwjBvgWgCOt/6pMlmJjjHMw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=lVY+y+TK; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3FA47606A31C for ; Mon, 30 Nov 2026 16:55:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=lVY+y+TK Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8507E1F008A0; Mon, 30 Nov 2026 16:54:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796057699; bh=ldliq1D/Upona/iWQ6stkHoLpvc6UngyKMDEe64DEVc=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=lVY+y+TKQX+QMXKB+2in9lKBwc8QNnmAa0sMSCAs+tXR5vh/4u9TofzxQa6UlwLXt QLiiqS2N6koEYWqJIukcYNti0101maAJhNuS4ukGHwkyHkqslUplnn+t2oDC9JLWdR Yo9FdREApSX3xiwmiTdjXYVyErOBvC3hYBJF01KUnSxTN9cv8wp4+uv4Q4rUv3QatJ 1itqV0sxX5A3Bb7+pZm5AzP459VJbx9UCq9/APJ3ALd1rqCbIaPbgaBlsBus45oHKv YY2Hhh9PAVHo2hiB8Q2tvB9YBpLPOptKoO9F2QyV60H+KtlXfeRNOmvQWDvGsvdgvb YvezBLLlx68Vw== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH 2/3] ext4: splice stranded fast commit staging queues before starting commit Reply-To: sashiko-reviews@lists.linux.dev To: "Xing Ma" , linux-ext4@vger.kernel.org Cc: tytso@mit.edu In-Reply-To: <20261130163819.13819-3-maxing.lan@bytedance.com> References: <20261130163819.13819-1-maxing.lan@bytedance.com> <20261130163819.13819-3-maxing.lan@bytedance.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Mon, 30 Nov 2026 16:54:56 +0000 X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list 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 > 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 [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 *jour= nal, tid_t commit_tid) > u64 locked_ns; > =20 > /* > - * 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 =3D 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 =3D 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? --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261130163819.1381= 9-1-maxing.lan@bytedance.com?part=3D2