Linux EXT4 FS development
 help / color / mirror / Atom feed
* [PATCH v2 0/2] ext4: protect quota acquisition against filesystem freezing
@ 2026-11-25 11:10 Ye Bin
  2026-11-25 11:10 ` [PATCH v2 1/2] quota: Forbid Q_XGETQUOTA and Q_XGETNEXTQUOTA for frozen filesystem Ye Bin
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Ye Bin @ 2026-11-25 11:10 UTC (permalink / raw)
  To: tytso, adilger.kernel, linux-ext4; +Cc: jack

From: Ye Bin <yebin10@huawei.com>

This series fixes quota operations running against a frozen filesystem,
and the resulting freeze protection for ext4's dquot acquisition.

Patch 1 makes Q_XGETQUOTA/Q_XGETNEXTQUOTA consistent with Q_GETQUOTA and
Q_GETNEXTQUOTA and forbids them on a frozen filesystem.  These commands
may end up in ->acquire_dquot() when the queried dquot is not cached yet,
and thus may write to the filesystem, just like Q_GETQUOTA/Q_GETNEXTQUOTA
which commit ccf370e43e08 ("quota: Forbid Q_GETQUOTA and Q_GETNEXTQUOTA
for frozen filesystem") already handles.  They were historically treated
as read-only because they come from XFS, where quota is always coherent,
but generic quota now routes them through dquot_get_dqblk()/
dquot_get_next_dqblk() and dqget().  Running them on a frozen filesystem
makes ext4 start a transaction on it and warn.  As suggested by Jan, they
are now handled exactly like the generic commands, including taking write
access, so a Q_XGETQUOTA on a read-only mount will report -EROFS; proper
read-only querying can be added later if somebody actually needs it.

Patch 2 protects ext4_acquire_dquot() itself.  A writable open reaches
the filesystem's ->open() callback without superblock freeze protection,
so ext4_file_open() -> dquot_file_open() -> dquot_initialize() can
acquire a dquot and start a transaction after the filesystem has been
frozen.  Take sb_start_intwrite() around ext4_acquire_dquot() when no
transaction is already running; running transactions are already
protected against freezing.

Patch 2 relies on the preceding patch 1.  Taking freeze protection in
ext4_acquire_dquot() while holding s_umount, as the Q_XGETQUOTA and
Q_XGETNEXTQUOTA paths do, would deadlock against thaw_super(), which
needs s_umount exclusively to release the SB_FREEZE_FS protection.
Patch 1 forbids those commands on a frozen filesystem and thus makes the
new protection in patch 2 safe.  Both patches must be applied together.

Ye Bin (2):
  quota: Forbid Q_XGETQUOTA and Q_XGETNEXTQUOTA for frozen filesystem
  ext4: protect ext4_acquire_dquot against freezing

 fs/ext4/super.c  | 20 +++++++++++++++++++-
 fs/quota/quota.c |  9 ++++-----
 2 files changed, 23 insertions(+), 6 deletions(-)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-11-25 11:31 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2026-11-25 11:30 ` [PATCH v2 0/2] ext4: protect quota acquisition against filesystem freezing sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox