From: Ye Bin <yebin@huaweicloud.com>
To: tytso@mit.edu, adilger.kernel@dilger.ca, linux-ext4@vger.kernel.org
Cc: jack@suse.cz
Subject: [PATCH v2 1/2] quota: Forbid Q_XGETQUOTA and Q_XGETNEXTQUOTA for frozen filesystem
Date: Wed, 25 Nov 2026 19:10:54 +0800 [thread overview]
Message-ID: <20261125111055.3672233-2-yebin@huaweicloud.com> (raw)
In-Reply-To: <20261125111055.3672233-1-yebin@huaweicloud.com>
From: Ye Bin <yebin10@huawei.com>
Commit ccf370e43e08 (quota: Forbid Q_GETQUOTA and Q_GETNEXTQUOTA for
frozen filesystem) forbade Q_GETQUOTA and Q_GETNEXTQUOTA on a frozen
filesystem because ext4_acquire_dquot() prepares for allocating space for
a new quota structure and OCFS2 needs to update the on-disk structure use
count when a new cluster node loads quota information from disk. The
same applies to Q_XGETQUOTA and Q_XGETNEXTQUOTA: userspace treats them as
read-only commands, but if the queried dquot is not cached yet,
->get_dqblk()/->get_nextdqblk() call dqget() -> ->acquire_dquot(), which
may write to the filesystem.
Until now this only made ext4 warn about starting a transaction on a
frozen filesystem. Now that ext4_acquire_dquot() also takes
sb_start_intwrite() to protect against freezing, it turns into a
deadlock: the query holds s_umount for reading and blocks on the
SB_FREEZE_FS freeze protection, which thaw_super() can only release
after taking s_umount exclusively.
So forbid Q_XGETQUOTA and Q_XGETNEXTQUOTA on a frozen filesystem as well
by moving them out of the read-only set in quotactl_cmd_write(), just
like Q_GETQUOTA and Q_GETNEXTQUOTA. This also makes quotactl_fd() take
write access for them, so a query on a read-only mount now fails with
-EROFS; that is the same behavior the generic quota commands already
have. If someone needs read-only querying on a frozen or read-only
filesystem, proper read-only dquot lookup can be implemented separately.
Suggested-by: Jan Kara <jack@suse.cz>
Signed-off-by: Ye Bin <yebin10@huawei.com>
---
fs/quota/quota.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/fs/quota/quota.c b/fs/quota/quota.c
index 94e6407734c7..1669bb09b9f7 100644
--- a/fs/quota/quota.c
+++ b/fs/quota/quota.c
@@ -834,9 +834,10 @@ static int do_quotactl(struct super_block *sb, int type, int cmd, qid_t id,
static int quotactl_cmd_write(int cmd)
{
/*
- * We cannot allow Q_GETQUOTA and Q_GETNEXTQUOTA without write access
- * as dquot_acquire() may allocate space for new structure and OCFS2
- * needs to increment on-disk use count.
+ * We cannot allow Q_GETQUOTA, Q_GETNEXTQUOTA, Q_XGETQUOTA and
+ * Q_XGETNEXTQUOTA without write access as dquot_acquire() may allocate
+ * space for new structure and OCFS2 needs to increment on-disk use
+ * count.
*/
switch (cmd) {
case Q_GETFMT:
@@ -844,8 +845,6 @@ static int quotactl_cmd_write(int cmd)
case Q_SYNC:
case Q_XGETQSTAT:
case Q_XGETQSTATV:
- case Q_XGETQUOTA:
- case Q_XGETNEXTQUOTA:
case Q_XQUOTASYNC:
return 0;
}
--
2.34.1
next prev parent reply other threads:[~2026-11-25 11:11 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 ` Ye Bin [this message]
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
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=20261125111055.3672233-2-yebin@huaweicloud.com \
--to=yebin@huaweicloud.com \
--cc=adilger.kernel@dilger.ca \
--cc=jack@suse.cz \
--cc=linux-ext4@vger.kernel.org \
--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