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; 11+ 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] 11+ messages in thread

* [PATCH v2 1/2] quota: Forbid Q_XGETQUOTA and Q_XGETNEXTQUOTA for frozen filesystem
  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
  2026-11-25 16:29   ` Jan Kara
  2026-11-25 11:10 ` [PATCH v2 2/2] ext4: protect ext4_acquire_dquot against freezing Ye Bin
  2026-11-25 11:30 ` [PATCH v2 0/2] ext4: protect quota acquisition against filesystem freezing sashiko-bot
  2 siblings, 1 reply; 11+ 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>

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


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

* [PATCH v2 2/2] ext4: protect ext4_acquire_dquot against freezing
  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 ` Ye Bin
  2026-11-25 11:30   ` sashiko-bot
                     ` (3 more replies)
  2026-11-25 11:30 ` [PATCH v2 0/2] ext4: protect quota acquisition against filesystem freezing sashiko-bot
  2 siblings, 4 replies; 11+ 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>

A writable open of a regular file reaches the filesystem's ->open()
callback without holding any superblock write (freeze) protection, but
ext4_file_open() -> dquot_file_open() -> dquot_initialize() may need to
acquire a dquot and write the quota file.  If the filesystem reaches
SB_FREEZE_COMPLETE in that window, ext4_journal_check_start() hits

	WARN_ON(sb->s_writers.frozen == SB_FREEZE_COMPLETE);

and the open then sleeps in jbd2 until the filesystem is thawed.

Taking freeze protection for every writable open in the VFS would make a
plain open(O_WRONLY) on a frozen filesystem block even when it never
writes, which is an unacceptable behaviour change.  Instead protect the
quota acquisition path itself: take sb_start_intwrite() around
ext4_acquire_dquot() when no transaction is already running.  Running
transactions are already protected against freezing and taking
sb_start_intwrite() inside one can deadlock.

This protection relies on the preceding quota change ("quota: Forbid
Q_XGETQUOTA and Q_XGETNEXTQUOTA for frozen filesystem").  Those commands
are treated as read-only and run with s_umount held for reading, but they
can still reach ext4_acquire_dquot().  Taking sb_start_intwrite() there
would deadlock against thaw_super(), which can only release the
SB_FREEZE_FS protection after taking s_umount exclusively.  The preceding
change forbids those commands on a frozen filesystem, which makes the new
protection safe, so both patches have to be applied together.

Fixes: 907f4554e252 ("dquot: move dquot initialization responsibility into the filesystem")
Suggested-by: Jan Kara <jack@suse.cz>
Signed-off-by: Ye Bin <yebin10@huawei.com>
---
 fs/ext4/super.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index d0415e5948e1..fc63219f5972 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -7110,11 +7110,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;
+	}
 
 	handle = ext4_journal_start(dquot_to_inode(dquot), EXT4_HT_QUOTA,
 				    EXT4_QUOTA_INIT_BLOCKS(dquot->dq_sb));
-	if (IS_ERR(handle))
+	if (IS_ERR(handle)) {
+		if (freeze_protected)
+			sb_end_intwrite(dquot->dq_sb);
 		return PTR_ERR(handle);
+	}
 	ret = dquot_acquire(dquot);
 	if (ret < 0)
 		ext4_error_err(dquot->dq_sb, -ret,
@@ -7123,6 +7137,10 @@ static int ext4_acquire_dquot(struct dquot *dquot)
 	err = ext4_journal_stop(handle);
 	if (!ret)
 		ret = err;
+
+	if (freeze_protected)
+		sb_end_intwrite(dquot->dq_sb);
+
 	return ret;
 }
 
-- 
2.34.1


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

* Re: [PATCH v2 2/2] ext4: protect ext4_acquire_dquot against freezing
  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 15:19   ` kernel test robot
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 11+ messages in thread
From: sashiko-bot @ 2026-11-25 11:30 UTC (permalink / raw)
  To: Ye Bin, linux-ext4; +Cc: tytso

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

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

* Re: [PATCH v2 0/2] ext4: protect quota acquisition against filesystem freezing
  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
  2 siblings, 0 replies; 11+ messages in thread
From: sashiko-bot @ 2026-11-25 11:30 UTC (permalink / raw)
  To: Ye Bin, linux-ext4; +Cc: tytso

Sashiko has finished reviewing this 2-patch series:

- Patch 1: no issues found.
- Patch 2 ("ext4: protect ext4_acquire_dquot against freezing"): 2
  potential issues (2 High)

A detailed review has been sent as a separate reply to patch 2.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261125111055.3672233-1-yebin@huaweicloud.com

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

* Re: [PATCH v2 2/2] ext4: protect ext4_acquire_dquot against freezing
  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 15:19   ` kernel test robot
  2026-11-25 16:33   ` Jan Kara
  2026-11-25 17:58   ` kernel test robot
  3 siblings, 0 replies; 11+ messages in thread
From: kernel test robot @ 2026-11-25 15:19 UTC (permalink / raw)
  To: Ye Bin, tytso, adilger.kernel, linux-ext4; +Cc: llvm, oe-kbuild-all, jack

Hi Ye,

kernel test robot noticed the following build errors:

[auto build test ERROR on tytso-ext4/dev]
[also build test ERROR on linus/master v7.4-rc4]
[cannot apply to brauner-vfs/vfs.all next-20261124]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Ye-Bin/quota-Forbid-Q_XGETQUOTA-and-Q_XGETNEXTQUOTA-for-frozen-filesystem/20261125-191054
base:   https://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4.git dev
patch link:    https://lore.kernel.org/r/20261125111055.3672233-3-yebin%40huaweicloud.com
patch subject: [PATCH v2 2/2] ext4: protect ext4_acquire_dquot against freezing
config: hexagon-defconfig (https://download.01.org/0day-ci/archive/20261125/20261125231648.ZdN8QBCN-lkp@intel.com/config)
compiler: clang version 24.0.0git (https://github.com/llvm/llvm-project 2012344e5da8e03ea4b8283ecd6fad6e13f09d64)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261125/20261125231648.ZdN8QBCN-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/20261125231648.ZdN8QBCN-lkp@intel.com/

All error/warnings (new ones prefixed by >>):

>> fs/ext4/super.c:7165:6: error: use of undeclared identifier 'freeze_protected'; did you mean 'freeze_processes'?
    7165 |         if (freeze_protected)
         |             ^~~~~~~~~~~~~~~~
         |             freeze_processes
   include/linux/freezer.h:84:19: note: 'freeze_processes' declared here
      84 | static inline int freeze_processes(void) { return -ENOSYS; }
         |                   ^
>> fs/ext4/super.c:7165:6: warning: address of function 'freeze_processes' will always evaluate to 'true' [-Wpointer-bool-conversion]
    7165 |         if (freeze_protected)
         |         ~~  ^~~~~~~~~~~~~~~~
   fs/ext4/super.c:7165:6: note: prefix with the address-of operator to silence this warning
    7165 |         if (freeze_protected)
         |             ^
         |             &
   1 warning and 1 error generated.


vim +7165 fs/ext4/super.c

  7144	
  7145	static int ext4_write_dquot(struct dquot *dquot)
  7146	{
  7147		int ret, err;
  7148		handle_t *handle;
  7149		struct inode *inode;
  7150	
  7151		inode = dquot_to_inode(dquot);
  7152		handle = ext4_journal_start(inode, EXT4_HT_QUOTA,
  7153					    EXT4_QUOTA_TRANS_BLOCKS(dquot->dq_sb));
  7154		if (IS_ERR(handle))
  7155			return PTR_ERR(handle);
  7156		ret = dquot_commit(dquot);
  7157		if (ret < 0)
  7158			ext4_error_err(dquot->dq_sb, -ret,
  7159				       "Failed to commit dquot type %d",
  7160				       dquot->dq_id.type);
  7161		err = ext4_journal_stop(handle);
  7162		if (!ret)
  7163			ret = err;
  7164	
> 7165		if (freeze_protected)
  7166			sb_end_intwrite(dquot->dq_sb);
  7167	
  7168		return ret;
  7169	}
  7170	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

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

* Re: [PATCH v2 1/2] quota: Forbid Q_XGETQUOTA and Q_XGETNEXTQUOTA for frozen filesystem
  2026-11-25 11:10 ` [PATCH v2 1/2] quota: Forbid Q_XGETQUOTA and Q_XGETNEXTQUOTA for frozen filesystem Ye Bin
@ 2026-11-25 16:29   ` Jan Kara
  0 siblings, 0 replies; 11+ messages in thread
From: Jan Kara @ 2026-11-25 16:29 UTC (permalink / raw)
  To: Ye Bin; +Cc: tytso, adilger.kernel, linux-ext4, jack, linux-fsdevel

[added fsdevel to CC since people there might be interested as well,
keeping patch intact]

On Wed 25-11-26 19:10:54, Ye Bin wrote:
> 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>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  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
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

* Re: [PATCH v2 2/2] ext4: protect ext4_acquire_dquot against freezing
  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 15:19   ` kernel test robot
@ 2026-11-25 16:33   ` Jan Kara
  2026-11-25 17:58   ` kernel test robot
  3 siblings, 0 replies; 11+ messages in thread
From: Jan Kara @ 2026-11-25 16:33 UTC (permalink / raw)
  To: Ye Bin; +Cc: tytso, adilger.kernel, linux-ext4, jack

On Wed 25-11-26 19:10:55, Ye Bin wrote:
> From: Ye Bin <yebin10@huawei.com>
> 
> A writable open of a regular file reaches the filesystem's ->open()
> callback without holding any superblock write (freeze) protection, but
> ext4_file_open() -> dquot_file_open() -> dquot_initialize() may need to
> acquire a dquot and write the quota file.  If the filesystem reaches
> SB_FREEZE_COMPLETE in that window, ext4_journal_check_start() hits
> 
> 	WARN_ON(sb->s_writers.frozen == SB_FREEZE_COMPLETE);
> 
> and the open then sleeps in jbd2 until the filesystem is thawed.
> 
> Taking freeze protection for every writable open in the VFS would make a
> plain open(O_WRONLY) on a frozen filesystem block even when it never
> writes, which is an unacceptable behaviour change.  Instead protect the
> quota acquisition path itself: take sb_start_intwrite() around
> ext4_acquire_dquot() when no transaction is already running.  Running
> transactions are already protected against freezing and taking
> sb_start_intwrite() inside one can deadlock.
> 
> This protection relies on the preceding quota change ("quota: Forbid
> Q_XGETQUOTA and Q_XGETNEXTQUOTA for frozen filesystem").  Those commands
> are treated as read-only and run with s_umount held for reading, but they
> can still reach ext4_acquire_dquot().  Taking sb_start_intwrite() there
> would deadlock against thaw_super(), which can only release the
> SB_FREEZE_FS protection after taking s_umount exclusively.  The preceding
> change forbids those commands on a frozen filesystem, which makes the new
> protection safe, so both patches have to be applied together.
> 
> Fixes: 907f4554e252 ("dquot: move dquot initialization responsibility into the filesystem")
> Suggested-by: Jan Kara <jack@suse.cz>
> Signed-off-by: Ye Bin <yebin10@huawei.com>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  fs/ext4/super.c | 20 +++++++++++++++++++-
>  1 file changed, 19 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/ext4/super.c b/fs/ext4/super.c
> index d0415e5948e1..fc63219f5972 100644
> --- a/fs/ext4/super.c
> +++ b/fs/ext4/super.c
> @@ -7110,11 +7110,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;
> +	}
>  
>  	handle = ext4_journal_start(dquot_to_inode(dquot), EXT4_HT_QUOTA,
>  				    EXT4_QUOTA_INIT_BLOCKS(dquot->dq_sb));
> -	if (IS_ERR(handle))
> +	if (IS_ERR(handle)) {
> +		if (freeze_protected)
> +			sb_end_intwrite(dquot->dq_sb);
>  		return PTR_ERR(handle);
> +	}
>  	ret = dquot_acquire(dquot);
>  	if (ret < 0)
>  		ext4_error_err(dquot->dq_sb, -ret,
> @@ -7123,6 +7137,10 @@ static int ext4_acquire_dquot(struct dquot *dquot)
>  	err = ext4_journal_stop(handle);
>  	if (!ret)
>  		ret = err;
> +
> +	if (freeze_protected)
> +		sb_end_intwrite(dquot->dq_sb);
> +
>  	return ret;
>  }
>  
> -- 
> 2.34.1
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

* Re: [PATCH v2 2/2] ext4: protect ext4_acquire_dquot against freezing
  2026-11-25 11:10 ` [PATCH v2 2/2] ext4: protect ext4_acquire_dquot against freezing Ye Bin
                     ` (2 preceding siblings ...)
  2026-11-25 16:33   ` Jan Kara
@ 2026-11-25 17:58   ` kernel test robot
  2026-11-26  6:10     ` yebin (H)
  3 siblings, 1 reply; 11+ messages in thread
From: kernel test robot @ 2026-11-25 17:58 UTC (permalink / raw)
  To: Ye Bin, tytso, adilger.kernel, linux-ext4; +Cc: oe-kbuild-all, jack

Hi Ye,

kernel test robot noticed the following build errors:

[auto build test ERROR on tytso-ext4/dev]
[also build test ERROR on linus/master v7.4-rc4]
[cannot apply to brauner-vfs/vfs.all next-20261124]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Ye-Bin/quota-Forbid-Q_XGETQUOTA-and-Q_XGETNEXTQUOTA-for-frozen-filesystem/20261125-191054
base:   https://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4.git dev
patch link:    https://lore.kernel.org/r/20261125111055.3672233-3-yebin%40huaweicloud.com
patch subject: [PATCH v2 2/2] ext4: protect ext4_acquire_dquot against freezing
config: x86_64-rhel-9.4 (https://download.01.org/0day-ci/archive/20261126/20261126015002.1lcIDaq1-lkp@intel.com/config)
compiler: gcc-14 (Debian 14.2.0-19) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261126/20261126015002.1lcIDaq1-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/20261126015002.1lcIDaq1-lkp@intel.com/

All errors (new ones prefixed by >>):

   fs/ext4/super.c: In function 'ext4_write_dquot':
>> fs/ext4/super.c:7165:13: error: 'freeze_protected' undeclared (first use in this function); did you mean 'freeze_processes'?
    7165 |         if (freeze_protected)
         |             ^~~~~~~~~~~~~~~~
         |             freeze_processes
   fs/ext4/super.c:7165:13: note: each undeclared identifier is reported only once for each function it appears in


vim +7165 fs/ext4/super.c

  7144	
  7145	static int ext4_write_dquot(struct dquot *dquot)
  7146	{
  7147		int ret, err;
  7148		handle_t *handle;
  7149		struct inode *inode;
  7150	
  7151		inode = dquot_to_inode(dquot);
  7152		handle = ext4_journal_start(inode, EXT4_HT_QUOTA,
  7153					    EXT4_QUOTA_TRANS_BLOCKS(dquot->dq_sb));
  7154		if (IS_ERR(handle))
  7155			return PTR_ERR(handle);
  7156		ret = dquot_commit(dquot);
  7157		if (ret < 0)
  7158			ext4_error_err(dquot->dq_sb, -ret,
  7159				       "Failed to commit dquot type %d",
  7160				       dquot->dq_id.type);
  7161		err = ext4_journal_stop(handle);
  7162		if (!ret)
  7163			ret = err;
  7164	
> 7165		if (freeze_protected)
  7166			sb_end_intwrite(dquot->dq_sb);
  7167	
  7168		return ret;
  7169	}
  7170	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

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

* Re: [PATCH v2 2/2] ext4: protect ext4_acquire_dquot against freezing
  2026-11-25 17:58   ` kernel test robot
@ 2026-11-26  6:10     ` yebin (H)
  2026-11-26 11:08       ` Jan Kara
  0 siblings, 1 reply; 11+ messages in thread
From: yebin (H) @ 2026-11-26  6:10 UTC (permalink / raw)
  To: kernel test robot, Ye Bin, tytso, adilger.kernel, linux-ext4
  Cc: oe-kbuild-all, jack



On 2026/11/26 1:58, kernel test robot wrote:
> Hi Ye,
>
> kernel test robot noticed the following build errors:
>
> [auto build test ERROR on tytso-ext4/dev]
> [also build test ERROR on linus/master v7.4-rc4]
> [cannot apply to brauner-vfs/vfs.all next-20261124]
> [If your patch is applied to the wrong git tree, kindly drop us a note.
> And when submitting patch, we suggest to use '--base' as documented in
> https://git-scm.com/docs/git-format-patch#_base_tree_information]
>
> url:    https://github.com/intel-lab-lkp/linux/commits/Ye-Bin/quota-Forbid-Q_XGETQUOTA-and-Q_XGETNEXTQUOTA-for-frozen-filesystem/20261125-191054
> base:   https://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4.git dev
> patch link:    https://lore.kernel.org/r/20261125111055.3672233-3-yebin%40huaweicloud.com
> patch subject: [PATCH v2 2/2] ext4: protect ext4_acquire_dquot against freezing
> config: x86_64-rhel-9.4 (https://download.01.org/0day-ci/archive/20261126/20261126015002.1lcIDaq1-lkp@intel.com/config)
> compiler: gcc-14 (Debian 14.2.0-19) 14.2.0
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261126/20261126015002.1lcIDaq1-lkp@intel.com/reproduce)
>
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <lkp@intel.com>
> | Closes: https://lore.kernel.org/oe-kbuild-all/20261126015002.1lcIDaq1-lkp@intel.com/
>
> All errors (new ones prefixed by >>):
>
>     fs/ext4/super.c: In function 'ext4_write_dquot':
>>> fs/ext4/super.c:7165:13: error: 'freeze_protected' undeclared (first use in this function); did you mean 'freeze_processes'?
>      7165 |         if (freeze_protected)
>           |             ^~~~~~~~~~~~~~~~
>           |             freeze_processes
>     fs/ext4/super.c:7165:13: note: each undeclared identifier is reported only once for each function it appears in
>

This is a bit strange. The ext4_write_dquot() function hasn't been modified at
all, and the nearby functions don't seem to have been changed in the latest
version either. It's possible that the patch wasn't generated based on the
latest linux-next code, causing git to apply the patch incorrectly by matching
only the context and line numbers, thus targeting the wrong function. I'll
regenerate the patch and send a new version, and I'll also CC linux-fsdevel
this time.

>
> vim +7165 fs/ext4/super.c
>
>    7144	
>    7145	static int ext4_write_dquot(struct dquot *dquot)
>    7146	{
>    7147		int ret, err;
>    7148		handle_t *handle;
>    7149		struct inode *inode;
>    7150	
>    7151		inode = dquot_to_inode(dquot);
>    7152		handle = ext4_journal_start(inode, EXT4_HT_QUOTA,
>    7153					    EXT4_QUOTA_TRANS_BLOCKS(dquot->dq_sb));
>    7154		if (IS_ERR(handle))
>    7155			return PTR_ERR(handle);
>    7156		ret = dquot_commit(dquot);
>    7157		if (ret < 0)
>    7158			ext4_error_err(dquot->dq_sb, -ret,
>    7159				       "Failed to commit dquot type %d",
>    7160				       dquot->dq_id.type);
>    7161		err = ext4_journal_stop(handle);
>    7162		if (!ret)
>    7163			ret = err;
>    7164	
>> 7165		if (freeze_protected)
>    7166			sb_end_intwrite(dquot->dq_sb);
>    7167	
>    7168		return ret;
>    7169	}
>    7170	
>

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

* Re: [PATCH v2 2/2] ext4: protect ext4_acquire_dquot against freezing
  2026-11-26  6:10     ` yebin (H)
@ 2026-11-26 11:08       ` Jan Kara
  0 siblings, 0 replies; 11+ messages in thread
From: Jan Kara @ 2026-11-26 11:08 UTC (permalink / raw)
  To: yebin (H)
  Cc: kernel test robot, Ye Bin, tytso, adilger.kernel, linux-ext4,
	oe-kbuild-all, jack

On Thu 26-11-26 14:10:14, yebin (H) wrote:
> 
> 
> On 2026/11/26 1:58, kernel test robot wrote:
> > Hi Ye,
> > 
> > kernel test robot noticed the following build errors:
> > 
> > [auto build test ERROR on tytso-ext4/dev]
> > [also build test ERROR on linus/master v7.4-rc4]
> > [cannot apply to brauner-vfs/vfs.all next-20261124]
> > [If your patch is applied to the wrong git tree, kindly drop us a note.
> > And when submitting patch, we suggest to use '--base' as documented in
> > https://git-scm.com/docs/git-format-patch#_base_tree_information]
> > 
> > url:    https://github.com/intel-lab-lkp/linux/commits/Ye-Bin/quota-Forbid-Q_XGETQUOTA-and-Q_XGETNEXTQUOTA-for-frozen-filesystem/20261125-191054
> > base:   https://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4.git dev
> > patch link:    https://lore.kernel.org/r/20261125111055.3672233-3-yebin%40huaweicloud.com
> > patch subject: [PATCH v2 2/2] ext4: protect ext4_acquire_dquot against freezing
> > config: x86_64-rhel-9.4 (https://download.01.org/0day-ci/archive/20261126/20261126015002.1lcIDaq1-lkp@intel.com/config)
> > compiler: gcc-14 (Debian 14.2.0-19) 14.2.0
> > reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261126/20261126015002.1lcIDaq1-lkp@intel.com/reproduce)
> > 
> > If you fix the issue in a separate patch/commit (i.e. not just a new version of
> > the same patch/commit), kindly add following tags
> > | Reported-by: kernel test robot <lkp@intel.com>
> > | Closes: https://lore.kernel.org/oe-kbuild-all/20261126015002.1lcIDaq1-lkp@intel.com/
> > 
> > All errors (new ones prefixed by >>):
> > 
> >     fs/ext4/super.c: In function 'ext4_write_dquot':
> > > > fs/ext4/super.c:7165:13: error: 'freeze_protected' undeclared (first use in this function); did you mean 'freeze_processes'?
> >      7165 |         if (freeze_protected)
> >           |             ^~~~~~~~~~~~~~~~
> >           |             freeze_processes
> >     fs/ext4/super.c:7165:13: note: each undeclared identifier is reported only once for each function it appears in
> > 
> 
> This is a bit strange. The ext4_write_dquot() function hasn't been modified at
> all, and the nearby functions don't seem to have been changed in the latest
> version either. It's possible that the patch wasn't generated based on the
> latest linux-next code, causing git to apply the patch incorrectly by matching
> only the context and line numbers, thus targeting the wrong function. I'll
> regenerate the patch and send a new version, and I'll also CC linux-fsdevel
> this time.

Yes, I think the the patch just misapplied in the test infrastructure.

								Honza
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

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

Thread overview: 11+ 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 16:29   ` Jan Kara
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 15:19   ` kernel test robot
2026-11-25 16:33   ` Jan Kara
2026-11-25 17:58   ` kernel test robot
2026-11-26  6:10     ` yebin (H)
2026-11-26 11:08       ` Jan Kara
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