* 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 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 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