From: sashiko-bot@kernel.org
To: "Ye Bin" <yebin@huaweicloud.com>, linux-ext4@vger.kernel.org
Cc: tytso@mit.edu
Subject: Re: [PATCH v2 2/2] ext4: protect ext4_acquire_dquot against freezing
Date: Wed, 25 Nov 2026 11:30:52 +0000 [thread overview]
Message-ID: <sashiko-outbox-233250@kernel.org> (raw)
In-Reply-To: <20261125111055.3672233-3-yebin@huaweicloud.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] ext4: misplaced sb_end_intwrite() in ext4_write_dquot() instead
of acquire
- [High] ext4: s_umount vs SB_FREEZE_FS deadlock in ext4_acquire_dquot()
via vfs_ustat()
--
commit 365cb575bc6d55af6ebb9f261bcac19d705f99d4
Author: Ye Bin <yebin10@huawei.com>
ext4: protect ext4_acquire_dquot against freezing
This commit takes sb_start_intwrite() around ext4_acquire_dquot() when no
journal transaction is currently active to protect dquot acquisition
against filesystem freezing.
> diff --git a/fs/ext4/super.c b/fs/ext4/super.c
> index 880f664d6c04b..769cae2ae65ff 100644
> --- a/fs/ext4/super.c
> +++ b/fs/ext4/super.c
> @@ -7161,6 +7161,10 @@ static int ext4_write_dquot(struct dquot *dquot)
> err = ext4_journal_stop(handle);
> if (!ret)
> ret = err;
> +
> + if (freeze_protected)
> + sb_end_intwrite(dquot->dq_sb);
> +
> return ret;
> }
[Severity: High]
Was this sb_end_intwrite() hunk meant for the end of ext4_acquire_dquot()
instead of ext4_write_dquot()? freeze_protected is not declared in
ext4_write_dquot(), breaking the build when CONFIG_QUOTA is enabled, and
ext4_acquire_dquot() never releases SB_FREEZE_FS after
ext4_journal_stop().
> @@ -7168,11 +7172,25 @@ static int ext4_acquire_dquot(struct dquot *dquot)
> {
> int ret, err;
> handle_t *handle;
> + bool freeze_protected = false;
> +
> + /*
> + * Trying to sb_start_intwrite() in a running transaction
> + * can result in a deadlock. Further, running transactions
> + * are already protected from freezing.
> + */
> + if (!ext4_journal_current_handle()) {
> + sb_start_intwrite(dquot->dq_sb);
> + freeze_protected = true;
> + }
[Severity: High]
Can calling sb_start_intwrite() here cause an ABBA deadlock between
s_umount and SB_FREEZE_FS when ustat(2) runs on a frozen filesystem?
Unlike Q_XGETQUOTA, vfs_ustat() acquires s_umount for reading via
user_get_super(dev, false) without checking whether the filesystem is
frozen, then calls statfs_by_dentry(s->s_root, sbuf) -> ext4_statfs().
When the root directory has EXT4_INODE_PROJINHERIT set and project quota
limits are enabled, ext4_statfs() calls ext4_statfs_project() -> dqget().
If the root directory's project dquot is not active in cache, dqget()
invokes ext4_acquire_dquot() with no running transaction:
CPU0 CPU1
---- ----
down_read(&s->s_umount)
down_write(&sb->s_umount)
sb_start_intwrite(dquot->dq_sb)
sb_freeze_unlock(sb, SB_FREEZE_FS)
*** DEADLOCK ***
CPU0: vfs_ustat() -> ext4_statfs() -> ext4_statfs_project() -> dqget() ->
ext4_acquire_dquot()
CPU1: thaw_super() -> super_lock_excl() -> thaw_super_locked()
Because CPU0 blocks on SB_FREEZE_FS while holding s_umount for reading,
thaw_super() cannot acquire s_umount exclusively to unfreeze the
filesystem.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261125111055.3672233-1-yebin@huaweicloud.com?part=2
next prev parent reply other threads:[~2026-11-25 11:30 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 11:10 [PATCH v2 0/2] ext4: protect quota acquisition against filesystem freezing Ye Bin
2026-11-25 11:10 ` [PATCH v2 1/2] quota: Forbid Q_XGETQUOTA and Q_XGETNEXTQUOTA for frozen filesystem Ye Bin
2026-11-25 11:10 ` [PATCH v2 2/2] ext4: protect ext4_acquire_dquot against freezing Ye Bin
2026-11-25 11:30 ` sashiko-bot [this message]
2026-11-25 11:30 ` [PATCH v2 0/2] ext4: protect quota acquisition against filesystem freezing sashiko-bot
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-233250@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-ext4@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=tytso@mit.edu \
--cc=yebin@huaweicloud.com \
/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