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=1796057914; b=DRH7l4Ho4rD+CfoqoDAxZ4MbtJLwi+6g99nE85Xl3GYxqai21qXPsM5wukNOZwZp3uBu Q/omh3ykAXOfQifD6IoJBVIwjawEdkNI2wbWFSKpVDhCATZlQbLn8qc+qxsih2rC3qK7S urjVBVWSu1PB2bWeZOW9JO/Hkep6Qu3br5kg7JqSmQOGsDmn32wgi9FSLWVxI0kEDm9AI EvjwhXZ9kWCcV2ZFh6ms72WQ6eSNt/tEJFSy49KnI3RE7tdq33UwDR2SiuWyUDJJmUuay /O7J/A81WOddrX9/1tuV4pJmdQ0RZ+jx1tbCAbYlYYbV2FyFmmQddjNQAOn/CL55YIg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796057914; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=fyqCvXpBEf+5MOob+QPCwaOT7bCVv1fqbURswlMItVg=; b=pa2H2zRq++Sff2oiaGUzdgFIsHpp9q6JRlytxLYS85v1e1kUBY0v+9+mhQ9+cx2Wviaw GCLHY4Fwj2H8aFWvCvpMtfEEoNoXnTUxGKzAFVaVh8WQ7Y387TE1ilxzXVH9zJWguyniF erYCaI8To/MIOqWEn3fac8J3Yr5ZkW3OieED1k6+oN08DTQHDmzQRVDvdiRF9F4vhMX6y VQs5Dyi0+/HQWRhgp0qvzKvP1HjjJUCNxsqxD2omi8h2KIRX7sQWEAlZFVgWK4x48uSsN bIp9kLyUr4EUndXmKvA/DYpfoPiytaXzPNMG2aZYIEIhKGIJe8BVoveQpcV9nrduBcQ== 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=IkQrlijr; 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 A7FA1606A320 for ; Mon, 30 Nov 2026 16:58:34 +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=IkQrlijr Received: by smtp.kernel.org (Postfix) with ESMTPSA id D4F891F0089B; Mon, 30 Nov 2026 16:58:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796057914; bh=fyqCvXpBEf+5MOob+QPCwaOT7bCVv1fqbURswlMItVg=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=IkQrlijrGef9swx5/OtFWnGFfIzJ146Z7qEjvnUOFpLpnvmfqB00xE5ToSi4GQCU8 seo/uEVW6Xlz5CbuI1l194LhhwsWxqeuUyumCtB1lRJo0qhtCS7+owDItk8jGU2iri Kl1ce9sH2rimjcTLHCT+6zm3nvjVlVXZtYk/nBUnzFHCOsjX1v+JGm/jiEh7HNEPtZ gD8qnVVKPBZQ7JJykYDXKk1KJQ1uOmY/9WBih7QYmpfIjQXnklXyWVu2fljYpWNqzW ExstllfY8xJC/lfyn49YI5op9ztaZvOXvaSK+NHysb+9XFqEnvx2qr7UJWJQZNIDAx 5IZX8Et1kIpMw== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH 3/3] ext4: keep tracking newer transactions while older tid is fc-ineligible Reply-To: sashiko-reviews@lists.linux.dev To: "Xing Ma" , linux-ext4@vger.kernel.org Cc: tytso@mit.edu In-Reply-To: <20261130163819.13819-4-maxing.lan@bytedance.com> References: <20261130163819.13819-1-maxing.lan@bytedance.com> <20261130163819.13819-4-maxing.lan@bytedance.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Mon, 30 Nov 2026 16:58:33 +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: ext4_rename() checks EXT4_MF_FC_INELIGIBLE causing torn fc tracking - [Medium] ext4: ordering race in ext4_fc_cleanup() passes s_fc_ineligible_tid=3D0 to tid_gt() - [Low] ext4: unused static ext4_fc_eligible() when CONFIG_EXT4_KUNIT_TESTS=3Dn -- commit ab665c709db8ebc5f4e6685eece8b5ca94164b47 Author: Xing Ma 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)); > } > =20 > +static bool ext4_fc_handle_eligible(struct super_block *sb, handle_t *ha= ndle) > +{ > + struct ext4_sb_info *sbi =3D 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 de= ntry *dentry) > { > struct inode *inode =3D d_inode(dentry); > =20 > - 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, in= t full, tid_t tid) > list_splice_init(&sbi->s_fc_q[FC_Q_STAGING], > &sbi->s_fc_q[FC_Q_MAIN]); > =20 > - if (tid_geq(tid, sbi->s_fc_ineligible_tid)) { > - sbi->s_fc_ineligible_tid =3D 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 =3D=3D 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) =3D=3D 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 >=3D 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. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261130163819.1381= 9-1-maxing.lan@bytedance.com?part=3D3