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=1796163872; b=arI5jHCXEWnXr13Jv0NraQJ86i73HEm1Q0WK/rTJL4842yfe72teYe2T5La3YA/BqwwL G+BgIyDdMBr+mCIX0uYCo5r8UX8U4jLD6PA49y3p6DX91oKjcduDFg/ob525zBTyFZXcl VZJL68tXAH33ug4oZp/5TWARX0QNWkdK9Bxfr7SvZirxEFM5dY8JykrmNhH0hEUctg0D9 BffgTvxHLXccARkzc7sLwoB07qeqoorGMWhO0IaPhoVhTxLz8JGQMwTdRCIvlhOp6ifmS DUyofBW+JjLirDyA2e6ShZMJZT0CspYWEm36YLRZXFMfkNmhZpnF9lc6XsV3QXQzDNg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796163872; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=puJr91iM3e3C0a5Y4stIOtF5aYIDEbN/T9zeIkkdC4A=; b=nEOu5oj5CQRGoxHoIKY14KIuJ84Y651PKxVgtBNdaWvGHVVGEgiu6pDN/ze3bf2l+JLn wkH2b3LMrSA5SrrhlrBTlX03c37B6l82iLDtrU5+FyVWeGtZkEZaNk+p7Y61igkM21cDR 8+bAEptmPgzBt5efwe/GxLDi+1p1Fvf8fgmP/vPYVwueSu7HikZLj0Iu+xAmJuPusmPlq rTNyEfd8z1Oh1aRUFj3VpAiOIAJi1ifF58eLKxM9LBLb6XeW5XS1KQZ7dO8R6jak7iFnB 1DBAakvQK9dZYtrR2WgW7O/9mPEq28Kug1ebf1WHPtDTnthyoShC+38/Mf2MqVjf80Q== 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=iiEy56aY; 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 2E057606A325; Tue, 1 Dec 2026 22:24:32 +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=iiEy56aY Received: by smtp.kernel.org (Postfix) with ESMTPSA id DBBB51F00897; Tue, 1 Dec 2026 22:24:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796163872; bh=puJr91iM3e3C0a5Y4stIOtF5aYIDEbN/T9zeIkkdC4A=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=iiEy56aYP6s3lQP0BoJ4h5rwvwNw6hnPd7o6bg+wFcku16t77vpWPIXeKkgnulhKk osDlRzxFRObpmiWwo6iYUvi1Jcp0MmcySMoW3MkV+rSTKqcSud5tEqc4+wCP5ftH1N 5zKf1tqsvFRPXRCvRcLIecsH3oNCIR8quBZ3JlHqZY7qrXF7T4CMJB8Q+zmRp6uIln 8ZyageZdcSw1aI7vOhNPxOLCTiShWX28ly849P5MLNQsjcM2yYEtUab2QSqatJoPLG Xa04Rsjz0IZ2d2MNlFcxfdhk6Dc6PX17COdS6seby+fBEkrqz1ZPec4keKdlL/IZkJ IWdcItaoa97SQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH] ext4: keep internal quota inode growth out of fast commits Reply-To: sashiko-reviews@lists.linux.dev To: "Wesley Atwell" Cc: linux-ext4@vger.kernel.org, linux-trace-kernel@vger.kernel.org, tytso@mit.edu In-Reply-To: <20261201.da276679711b4a31aaa4af05bfcbc1be@gmail.com> References: <20261201.da276679711b4a31aaa4af05bfcbc1be@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Tue, 01 Dec 2026 22:24:31 +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 4 potential issues to consider: - [Medium] ext4: internal quota inode queued on s_fc_q when fallback clears ineligible flag - [Medium] ext4: premature return in ext4_fc_commit() when fallback clears ineligible flag - [Low] ext4: missing EXT4_FC_REASON_QUOTA_INODE in ext4_fc_stats tracepoint TP_printk - [Low] ext4: duplicate ext4_fc_mark_ineligible() call on block-allocating quota writes It also noticed 1 related pre-existing issue this patch does not introduce: - [High] ext4: stale FC_Q_STAGING entries survive full commit in ext4_fc_cleanup() [1] -- commit dcaa353a248a8dfde49d12865c6eaba385032da3 Author: Wesley Atwell ext4: keep internal quota inode growth out of fast commits This commit marks the filesystem fast-commit ineligible when an internal quota inode maps blocks or grows in size, and rechecks ineligibility in ext4_fc_perform_commit() and ext4_fc_commit(). Link: https://lore.kernel.org/all/20261201013742.1562967-1-maxing.lan@byted= ance.com/ > diff --git a/fs/ext4/fast_commit.c b/fs/ext4/fast_commit.c > index 9beb423b208f8..0c072cf800a4e 100644 > --- a/fs/ext4/fast_commit.c > +++ b/fs/ext4/fast_commit.c > @@ -1414,13 +1414,20 @@ static int ext4_fc_perform_commit(journal_t *jour= nal, tid_t commit_tid) > * doing logical-to-physical mapping. > */ > alloc_ctx =3D ext4_fc_lock(sb); > + /* A drained handle may have made this transaction ineligible. */ > + if (ext4_test_mount_flag(sb, EXT4_MF_FC_INELIGIBLE)) { > + ret =3D -EAGAIN; > + goto out_unlock_fc; > + } > list_for_each_entry(iter, &sbi->s_fc_q[FC_Q_MAIN], i_fc_list) { > ext4_set_inode_state(&iter->vfs_inode, > EXT4_STATE_FC_COMMITTING); > } [Severity: High] This problem wasn't introduced by this patch, but can ext4_fc_cleanup() promote stale entries [1] from FC_Q_STAGING into FC_Q_MAIN when an active handle in the committing transaction tracks updates after JBD2_FULL_COMMIT_ONGOING is set? CPU0 (transaction T) CPU1 (kjournald2, transaction T) ext4_unlink() ext4_journal_start() jbd2_journal_commit_transaction() j_flags |=3D JBD2_FULL_COMMIT_ONGOING ext4_fc_track_unlink() __track_dentry_update() list_add_tail(..., &s_fc_dentry_q[FC_Q_STAGING]) ext4_journal_stop() jbd2_journal_wait_updates() ... ext4_fc_cleanup(journal, 1, T) /* drains FC_Q_MAIN only */ list_splice_init( &s_fc_dentry_q[FC_Q_STAGING], &s_fc_dentry_q[FC_Q_MAIN]) <-- stale T entry in FC_Q_MAIN __track_dentry_update() and ext4_fc_track_template() queue updates onto FC_Q_STAGING while JBD2_FULL_COMMIT_ONGOING is set. Because jbd2_journal_commit_transaction() sets that flag before calling jbd2_journal_wait_updates(), in-flight handles in transaction T land on FC_Q_STAGING. At the end of full commit T, ext4_fc_cleanup() only drains FC_Q_MAIN and splices FC_Q_STAGING into FC_Q_MAIN for transaction T+1. A fast commit in T+1 then logs those already-committed updates, so crash recovery replays them after full commit T and corrupts directory state. > +out_unlock_fc: > ext4_fc_unlock(sb, alloc_ctx); > =20 > - ret =3D ext4_fc_snapshot_inodes(journal, inodes, inodes_size, > + if (!ret) > + ret =3D ext4_fc_snapshot_inodes(journal, inodes, inodes_size, > &snap_inodes, &snap_ranges, &snap_err); > jbd2_journal_unlock_updates(journal); > locked_ns =3D ktime_to_ns(ktime_sub(ktime_get(), lock_start)); > @@ -1604,6 +1611,13 @@ int ext4_fc_commit(journal_t *journal, tid_t commi= t_tid) > restart_fc: > ret =3D jbd2_fc_begin_commit(journal, commit_tid); > if (ret =3D=3D -EALREADY) { > + /* An ongoing commit may not cover this ineligible transaction. */ > + if (ext4_test_mount_flag(sb, EXT4_MF_FC_INELIGIBLE) && > + !jbd2_transaction_committed(journal, commit_tid)) { > + ext4_fc_update_stats(sb, EXT4_FC_STATUS_INELIGIBLE, 0, 0, > + commit_tid); > + return jbd2_complete_transaction(journal, commit_tid); > + } [Severity: Medium] Can a waiter returning -EALREADY from jbd2_fc_begin_commit() miss EXT4_MF_FC_INELIGIBLE and return 0 before the fallback full commit of commit_tid finishes? CPU0 CPU1 CPU2 /* fast commit on T, * s_fc_subtid =3D=3D N, * past unlock_updates */ ext4_fc_mark_ineligible() ext4_fc_commit(T) subtid =3D N jbd2_fc_begin_commit(T) /* sleeps on j_fc_wait */ atomic_inc(&s_fc_subtid) jbd2_fc_end_commit() wake_up(&j_fc_wait) ext4_fc_commit(= T) jbd2_fc_begin= _commit(T) jbd2_fc_end_c= ommit_fallback() ext4_fc_cle= anup(0, T) clear EXT= 4_MF_FC_INELIGIBLE wake_up(&j_= fc_wait) /* wakes, returns -EALREADY */ test EXT4_MF_FC_INELIGIBLE -> false s_fc_subtid <=3D subtid -> false (N + 1 <=3D N) return 0 <-- T not yet committed jbd2_comple= te_transaction(T) Inside jbd2_fc_end_commit_fallback() -> __jbd2_fc_end_commit(), ext4_fc_cleanup(journal, 0, tid) clears EXT4_MF_FC_INELIGIBLE before jbd2_complete_transaction(journal, tid) runs. If CPU0's earlier fast commit already incremented s_fc_subtid without covering CPU1's post-snapshot ineligible update, CPU1 sees neither EXT4_MF_FC_INELIGIBLE nor s_fc_subtid <=3D subtid and returns to ext4_sync_file() while commit_tid is still uncommitted. [ ... ] > diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c > index 07a62d8569d31..eec8cf33a4e73 100644 > --- a/fs/ext4/inode.c > +++ b/fs/ext4/inode.c > @@ -929,6 +929,11 @@ int ext4_map_blocks(handle_t *handle, struct inode *= inode, > internal_handle =3D true; > } > =20 > + /* Internal quota inode mappings cannot be replayed by fast commit. */ > + if (ext4_is_quota_file(inode) && > + is_special_ino(inode->i_sb, inode->i_ino)) > + ext4_fc_mark_ineligible(inode->i_sb, > + EXT4_FC_REASON_QUOTA_INODE, handle); > ext4_fc_track_inode(handle, inode); [Severity: Medium] Can the internal quota inode still be queued onto s_fc_q[FC_Q_STAGING] if a concurrent fast commit falls back before ext4_fc_track_inode() or ext4_fc_track_range() runs? CPU0 (transaction T) CPU1 (transaction T) ext4_map_blocks(quota_inode) ext4_fc_mark_ineligible(..., T) ext4_fc_commit(T) /* sees EXT4_MF_FC_INELIGIBLE */ jbd2_fc_end_commit_fallback() ext4_fc_cleanup(journal, 0, T) clear EXT4_MF_FC_INELIGIBLE j_flags |=3D JBD2_FULL_COMMIT_ONG= OING ext4_fc_track_inode(quota_inode) /* ext4_fc_eligible() is true */ list_add_tail(..., &s_fc_q[FC_Q_STAGING]) jbd2_complete_transaction(T) ... ext4_fc_cleanup(journal, 1, T) list_splice_init( &s_fc_q[FC_Q_STAGING], &s_fc_q[FC_Q_MAIN]) <-- quota_inode on FC_Q_MAIN Both ext4_map_blocks() and ext4_quota_write() (via ext4_mark_inode_dirty()) still call ext4_fc_track_inode() on the internal quota inode after marking the filesystem ineligible, relying on EXT4_MF_FC_INELIGIBLE to make ext4_fc_eligible() return false. However, jbd2_fc_end_commit_fallback() runs ext4_fc_cleanup(journal, 0, tid) before jbd2_complete_transaction() waits for open handles on tid to drain, and ext4_fc_cleanup() clears EXT4_MF_FC_INELIGIBLE even when full =3D=3D 0. Once spliced onto FC_Q_MAIN, the special quota inode is written out by the next fast commit and causes mount recovery to fail in ext4_fc_replay_inode(). Should ext4_fc_track_inode() and ext4_fc_track_range() ignore special quota inodes directly (or should ext4_fc_cleanup() only clear EXT4_MF_FC_INELIGIBLE when full is set)? > diff --git a/fs/ext4/super.c b/fs/ext4/super.c > index 880f664d6c04b..76d617e023d2c 100644 > --- a/fs/ext4/super.c > +++ b/fs/ext4/super.c > @@ -7539,6 +7539,10 @@ static ssize_t ext4_quota_write(struct super_block= *sb, int type, > (unsigned long long)off, (unsigned long long)len); > return -EIO; > } > + /* Size can grow even when the quota inode's last block is mapped. */ > + if (inode->i_size < off + len && ext4_is_quota_file(inode) && > + is_special_ino(sb, inode->i_ino)) > + ext4_fc_mark_ineligible(sb, EXT4_FC_REASON_QUOTA_INODE, handle); > =20 > do { > bh =3D ext4_bread(handle, inode, blk, [Severity: Low] When a write to an internal quota file grows i_size and allocates a new block via ext4_bread(..., EXT4_GET_BLOCKS_CREATE), doesn't this call ext4_fc_mark_ineligible() twice for the same write=E2=80=94once here and ag= ain in ext4_map_blocks()=E2=80=94taking s_fc_lock twice and double-counting fc_ineligible_reason_count[EXT4_FC_REASON_QUOTA_INODE]? > diff --git a/include/trace/events/ext4.h b/include/trace/events/ext4.h > index 92048da9dae43..f73288d0d6ffe 100644 > --- a/include/trace/events/ext4.h > +++ b/include/trace/events/ext4.h [ ... ] > @@ -141,7 +142,8 @@ TRACE_SNAP_ERR > { EXT4_FC_REASON_ENCRYPTED_FILENAME, "ENCRYPTED_FILENAME"}, \ > { EXT4_FC_REASON_MIGRATE, "MIGRATE"}, \ > { EXT4_FC_REASON_VERITY, "VERITY"}, \ > - { EXT4_FC_REASON_MOVE_EXT, "MOVE_EXT"}) > + { EXT4_FC_REASON_MOVE_EXT, "MOVE_EXT"}, \ > + { EXT4_FC_REASON_QUOTA_INODE, "QUOTA_INODE"}) [Severity: Low] show_fc_reason() is only used by FC_REASON_NAME_STAT() in TRACE_EVENT(ext4_fc_stats). Should TP_printk in TRACE_EVENT(ext4_fc_stats) also be updated to print FC_REASON_NAME_STAT(EXT4_FC_REASON_QUOTA_INODE)? [1] https://sashiko.dev/#/bug/linux-1abe6f8d-3af8-47e4-9040-53c37377486a --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261201.da27667971= 1b4a31aaa4af05bfcbc1be@gmail.com?part=3D1