From: sashiko-bot@kernel.org
To: "Wesley Atwell" <atwellwea@gmail.com>
Cc: linux-ext4@vger.kernel.org, tytso@mit.edu
Subject: Re: [PATCH v2] ext4: require a quota check after unclean fast-commit mounts
Date: Thu, 03 Dec 2026 03:24:25 +0000 [thread overview]
Message-ID: <sashiko-outbox-247089@kernel.org> (raw)
In-Reply-To: <kernel-ext4-fc-quota-recovery-v2-d1a77368f2d9e49c0f709e35e6b6637186fa2908@gmail.com>
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 != 0
- [Medium] ext4: unjournaled orphan cleanup on ro,noload mount in
__ext4_fill_super()
--
commit ed35d76551f991fed3ccca432a490ffbc38374a5
Author: Wesley Atwell <atwellwea@gmail.com>
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.atwellwea@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 = 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;
> }
>
> + if (ext4_fc_quota_guard(sb)) {
> + if (sbi->s_sb_block != 1 && !sb_rdonly(sb)) {
> + ext4_msg(sb, KERN_ERR,
> + "quota fast commit requires primary superblock");
> + err = -EOPNOTSUPP;
> + goto failed_mount3a;
> + }
[Severity: Medium]
Can a read-only mount using an alternate superblock (sbi->s_sb_block != 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 != 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 != 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 = 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 = -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 == 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, struct super_block *sb)
>
> es = sbi->s_es;
>
> + 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 = -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, struct 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 = 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 != 0 causes subsequent
mounts—including read-only mounts without noload—to see needs_recovery &&
(sbi->s_mount_state & EXT4_VALID_FS) and fail with -EUCLEAN.
--
Sashiko AI review · https://sashiko.dev/#/patchset/kernel-ext4-fc-quota-recovery-v2-d1a77368f2d9e49c0f709e35e6b6637186fa2908@gmail.com?part=1
prev parent reply other threads:[~2026-12-03 3:24 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 2:54 [PATCH v2] ext4: require a quota check after unclean fast-commit mounts Wesley Atwell
2026-12-03 3:24 ` sashiko-bot [this message]
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-247089@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=atwellwea@gmail.com \
--cc=linux-ext4@vger.kernel.org \
--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