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=1796268268; b=qfXWJoOaB9PNb1B2shGFNsn950N7jC/s3S+UwW9Rt1a5HQ4pM2pfoUaTHvdav5T4vHV3 RwBOb8Z3utthMOzBZvN1dYxkZ9uHqDYcHm5gZYGP+JpPL6T46ifztzn5D9YNxULRDavcS W7n5I7xa8FbowXWIHTNQ1fKyDh6OSe1e+2ULumNy6p3bo90cVodYW0jNGAk2NUdkwZSFj jWE58dMWDjliKHDzR1nsekQJz8DlMuebezW6QKAh5qCJoJlG+F3iTlp4CYKJHKoye77P3 eZme6vdtSnuhRFPSGd0+PJ2JH5fDdY5h+wPRs8VXayV/f5a/NrlnZonG7fdHji2CP0w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796268268; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=AUN+j4+9TZbDiElaxad3242t5k0C78CojAsYOoIzcbc=; b=1j2jTs9L8H+fs+G7FFLNeKGKS7egNnYbVOTX5HeKc713eAMvXIFAzgiwE8vXskJ9ZxWH kYWRwVYo7cmEqyjmwNOgeHkM6hwrx22tPVRObBQk77+arZiaf+4pzLw/lmLj+2wiqB38n icFuEjqmMo8OgUbYFiExoBsbyoTOoEldTYcdl69tyc3+OWvKCefow5vNYrv9jbX5CQZt8 ppyiDZLEGezOziY71WkEMD5s4wezzatQBWZa9twiz8ffsUBCfVVZdwDe6iXxmZzTGl1W9 JLnKM6N/8JM85aiO8F7Cf0Gncxxa+7yxw8sWLci+1rBOMVn4VsUs0P6kVqeqEX0qtwA== 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=arihFJ4J; 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 672EF606A32F for ; Thu, 3 Dec 2026 03:24:28 +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=arihFJ4J Received: by smtp.kernel.org (Postfix) with ESMTPSA id CD2F31F000C1; Thu, 3 Dec 2026 03:24:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796268268; bh=AUN+j4+9TZbDiElaxad3242t5k0C78CojAsYOoIzcbc=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=arihFJ4JFBh26XAJhGL0EjOYZXaQDSIqCWp9ogJ4GkfO+pGicQG/tXP8xzO19gmCd MU68SHzHDUknPlNknUiTEVTHeyrcOQPs3MdwnuVPv27QHjxMb3KKNZl88ezPbzJ2Ey BSUagUhg6uMKWIMlYIrMiY8LJXOrOaB1uBTjJDRe+khQwKOiCn8s0aCfKjLlywur5+ uAR0X1YAtAPoPIcS3CCU061XqXEutxcUaKFI05ZPW6GouvatTCVt3dVAYBBR8aU8M5 3XRY7S/0Sa+cfp0MUMpenmBufkX4fZpglfqJ7NflJYU6UR2rSUTNAwS33dZ6bsu5qS jLBViLcc9dP9g== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v2] ext4: require a quota check after unclean fast-commit mounts Reply-To: sashiko-reviews@lists.linux.dev To: "Wesley Atwell" Cc: linux-ext4@vger.kernel.org, tytso@mit.edu In-Reply-To: References: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 03 Dec 2026 03:24:25 +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 6 potential issues to consider: - [Medium] ext4: missing EXT4_VALID_FS restore and clear in ext4_freeze() and unfreeze - [Medium] ext4: RO alternate-sb mount replays journal without primary repair marker - [Medium] ext4: failure after ext4_setup_super() leaves clean fs marked unclean - [Medium] ext4: broken barrier check on remount-ro and noload in __ext4_remount() - [Medium] ext4: __ext4_remount() restores EXT4_VALID_FS when es->s_last_orphan !=3D 0 - [Medium] ext4: unjournaled orphan cleanup on ro,noload mount in __ext4_fill_super() -- commit ed35d76551f991fed3ccca432a490ffbc38374a5 Author: Wesley Atwell ext4: require a quota check after unclean fast-commit mounts This commit keeps EXT4_VALID_FS cleared on the primary superblock during writable mounts of filesystems with both quota and fast-commit features enabled, and refuses writable mounts or remounts after an unclean shutdown until e2fsck runs. Link: https://lore.kernel.org/linux-ext4/kernel-7f509bcdfe16388c-v1.atwellw= ea@gmail.com/ > diff --git a/fs/ext4/super.c b/fs/ext4/super.c > index 880f664d6c04b..00d4150ba9ad1 100644 > --- a/fs/ext4/super.c > +++ b/fs/ext4/super.c [ ... ] > @@ -3240,6 +3264,11 @@ static int ext4_setup_super(struct super_block *sb= , struct ext4_super_block *es, > ext4_msg(sb, KERN_WARNING, > "warning: checktime reached, " > "running e2fsck is recommended"); > + if (ext4_fc_quota_guard(sb)) { > + err =3D ext4_fc_quota_mark_repair_needed(sb); > + if (err) > + goto done; > + } [Severity: Medium] Should ext4_freeze() and ext4_unfreeze() also restore and re-clear EXT4_VALID_FS when ext4_fc_quota_guard(sb) is true? ext4_setup_super() clears EXT4_VALID_FS in es->s_state on disk for the duration of a writable mount. When ext4_freeze() flushes the journal and clears EXT4_FEATURE_INCOMPAT_RECOVER and EXT4_FEATURE_RO_COMPAT_ORPHAN_PRESENT to prepare a clean on-disk state for snapshots, EXT4_VALID_FS remains cleared in es->s_state, so any snapshot taken while frozen fails writable mounts with -EUCLEAN. [Severity: Medium] If a later step in __ext4_fill_super() or __ext4_remount() fails after ext4_setup_super() commits the superblock, does the error path leave a clean filesystem marked unclean on disk? For example, during a read-only to read-write remount in __ext4_remount(), ext4_setup_super() clears EXT4_VALID_FS and sets EXT4_FEATURE_INCOMPAT_RECOVER on disk before ext4_multi_mount_protect(), ext4_setup_system_zone(), and ext4_enable_quotas() run. If any of those fails, restore_opts reverts sb->s_flags to SB_RDONLY without restoring es->s_state or clearing the recovery flags on disk, so subsequent writable remounts or mounts after umount fail with -EUCLEAN until e2fsck is run. > @@ -5618,6 +5647,37 @@ static int __ext4_fill_super(struct fs_context *fc= , struct super_block *sb) > goto failed_mount3a; > } > =20 > + if (ext4_fc_quota_guard(sb)) { > + if (sbi->s_sb_block !=3D 1 && !sb_rdonly(sb)) { > + ext4_msg(sb, KERN_ERR, > + "quota fast commit requires primary superblock"); > + err =3D -EOPNOTSUPP; > + goto failed_mount3a; > + } [Severity: Medium] Can a read-only mount using an alternate superblock (sbi->s_sb_block !=3D 1) without noload replay or wipe the journal without recording the repair marker on the primary superblock? When sb_rdonly(sb) is true and sbi->s_sb_block !=3D 1, sbi->s_mount_state and needs_recovery are loaded from the alternate superblock rather than block 1, and ext4_fc_quota_mark_repair_needed() in ext4_load_journal() is a no-op because it returns early when sbi->s_sb_block !=3D 1. If the alternate superblock has EXT4_VALID_FS cleared and INCOMPAT_RECOVER set (for example after an online resize updated backup superblocks while mounted), a read-only mount replays and resets the journal without reasserting ~EXT4_VALID_FS on the primary superblock; conversely, if the alternate superblock is clean and lacks INCOMPAT_RECOVER after a crash, ext4_load_journal() calls jbd2_journal_wipe() and wipes the unrecovered journal. > + /* RO replay is safe when the repair marker is already durable. */ > + if ((needs_recovery || !(sbi->s_mount_state & EXT4_VALID_FS)) && > + (!sb_rdonly(sb) || > + (!test_opt(sb, NOLOAD) && > + (sbi->s_mount_state & EXT4_VALID_FS)))) { > + if (needs_recovery && !sb_rdonly(sb)) { > + err =3D ext4_fc_quota_mark_repair_needed(sb); > + if (err) > + goto failed_mount3a; > + } > + ext4_msg(sb, KERN_ERR, > + "run e2fsck before quota fast-commit recovery"); > + err =3D -EUCLEAN; > + goto failed_mount3a; > + } [Severity: Medium] When an unclean filesystem with pending orphans is mounted with -o ro,noload on a writable block device, doesn't __ext4_fill_super() still run ext4_orphan_cleanup() without replaying the journal? Exempting test_opt(sb, NOLOAD) here allows the mount to proceed with sbi->s_journal =3D=3D NULL into ext4_orphan_cleanup(), which does not check test_opt(sb, NOLOAD). When !bdev_read_only(sb->s_bdev), ext4_orphan_cleanup() temporarily clears SB_RDONLY, enables quotas, and truncates and deletes orphan inodes using unjournaled handles on top of the un-replayed journal; if es->s_last_orphan was the only recovery indicator on an image with EXT4_VALID_FS set, this also clears es->s_last_orphan on disk without clearing EXT4_VALID_FS. [ ... ] > @@ -6811,6 +6896,15 @@ static int __ext4_remount(struct fs_context *fc, s= truct super_block *sb) > =20 > es =3D sbi->s_es; > =20 > + if (ext4_fc_quota_guard(sb) && !test_opt(sb, BARRIER) && > + test_opt2(sb, JOURNAL_FAST_COMMIT) && > + (!sb_rdonly(sb) || !(fc->sb_flags & SB_RDONLY))) { > + ext4_msg(sb, KERN_ERR, > + "quota fast commit requires barriers"); > + err =3D -EINVAL; > + goto restore_opts; > + } [Severity: Medium] Does checking !sb_rdonly(sb) here reject remounting a writable filesystem to read-only when barriers are disabled? At this point in __ext4_remount(), sb->s_flags still holds the pre-remount flags while fc->sb_flags holds the requested remount flags, so a rw-to-ro remount with nobarrier sees !sb_rdonly(sb) as true and fails with -EINVAL. Also, in __ext4_fill_super(), the barrier check runs before the NOLOAD / no-journal branch calls clear_opt2(sb, JOURNAL_FAST_COMMIT), so a clean writable mount with -o noload,nobarrier is rejected with -EINVAL even though fast commits are disabled. [ ... ] > @@ -6981,6 +7084,13 @@ static int __ext4_remount(struct fs_context *fc, s= truct super_block *sb) > */ > if (test_opt2(sb, ABORT)) > ext4_abort(sb, ESHUTDOWN, "Abort forced by user"); > + if (finish_fc_quota_ro && !ext4_emergency_state(sb) && > + !ext4_mark_recovery_complete(sb, es) && > + !(es->s_state & cpu_to_le16(EXT4_VALID_FS)) && > + (sbi->s_mount_state & EXT4_VALID_FS)) { > + es->s_state =3D cpu_to_le16(sbi->s_mount_state); > + ext4_commit_super(sb); > + } [Severity: Medium] Can this restore EXT4_VALID_FS on disk while es->s_last_orphan is still non-zero? ext4_mark_recovery_complete() checks ext4_orphan_file_empty(sb) but does not check es->s_last_orphan. If es->s_last_orphan is non-zero during a read-write to read-only transition (for example, on an emergency remount via SB_FORCE that bypasses sb_prepare_remount_readonly(), or after an error path calls ext4_orphan_del(NULL, inode) on a linked inode), committing EXT4_VALID_FS with es->s_last_orphan !=3D 0 causes subsequent mounts=E2=80=94including read-only mounts without noload=E2=80=94to see nee= ds_recovery && (sbi->s_mount_state & EXT4_VALID_FS) and fail with -EUCLEAN. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/kernel-ext4-fc-quot= a-recovery-v2-d1a77368f2d9e49c0f709e35e6b6637186fa2908@gmail.com?part=3D1