* [f2fs-dev] [PATCH v2] f2fs: quota: fix quota flush failure during filesystem freeze
@ 2026-10-12 2:54 Jianan Huang
2026-10-14 8:41 ` Chao Yu via Linux-f2fs-devel
2026-10-14 15:50 ` patchwork-bot+f2fs--- via Linux-f2fs-devel
0 siblings, 2 replies; 3+ messages in thread
From: Jianan Huang @ 2026-10-12 2:54 UTC (permalink / raw)
To: linux-f2fs-devel, chao, jaegeuk; +Cc: Jianan Huang
Quota flush retries can be exhausted during filesystem freeze.
freeze_super() and the quota checkpoint may race as below.
freeze_super() f2fs_ckpt
- down_write(&sb->s_umount)
- sb->s_writers.frozen = SB_FREEZE_PAGEFAULT
- sync_filesystem()
- f2fs_sync_fs()
- f2fs_issue_checkpoint()
- queue CP_SYNC -----------------> - block_operations()
- down_read_trylock(s_umount)
: fails; freeze holds write lock
- quota flush retries exhausted
- set CP_QUOTA_NEED_FSCK_FLAG
During the PAGEFAULT sync pass, freeze_super() holds s_umount for
write, but umount_lock_holder is not set until f2fs_freeze(). Thus
quota writeback tries to acquire s_umount again and can exhaust retries.
With checkpoint merge enabled, f2fs_issue_checkpoint() may dispatch
CP_SYNC to f2fs_ckpt. That thread also cannot acquire the freeze lock.
Record current as umount_lock_holder around the VFS PAGEFAULT sync so
checkpoint runs in the freeze caller and quota flush uses its existing
s_umount write lock.
Fixes: eb85c2410d6f ("f2fs: quota: fix to avoid warning in dquot_writeback_dquots()")
Signed-off-by: Jianan Huang <jnhuang95@gmail.com>
---
Changes since v1:
- Add a separate VFS sync_fs wrapper to avoid renaming f2fs_sync_fs().
fs/f2fs/super.c | 21 ++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 00da08504d55..fa105ca14653 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -2146,6 +2146,25 @@ int f2fs_sync_fs(struct super_block *sb, int sync)
return err;
}
+static int f2fs_sync_fs_super(struct super_block *sb, int sync)
+{
+ struct f2fs_sb_info *sbi = F2FS_SB(sb);
+ bool freeze_sync = sync &&
+ sb->s_writers.frozen == SB_FREEZE_PAGEFAULT;
+ int err;
+
+ /* freeze_super() holds s_umount for write during this sync pass. */
+ if (freeze_sync)
+ sbi->umount_lock_holder = current;
+
+ err = f2fs_sync_fs(sb, sync);
+
+ if (freeze_sync)
+ sbi->umount_lock_holder = NULL;
+
+ return err;
+}
+
static int f2fs_freeze(struct super_block *sb)
{
struct f2fs_sb_info *sbi = F2FS_SB(sb);
@@ -3757,7 +3776,7 @@ static const struct super_operations f2fs_sops = {
#endif
.evict_inode = f2fs_evict_inode,
.put_super = f2fs_put_super,
- .sync_fs = f2fs_sync_fs,
+ .sync_fs = f2fs_sync_fs_super,
.freeze_fs = f2fs_freeze,
.unfreeze_fs = f2fs_unfreeze,
.statfs = f2fs_statfs,
--
2.43.0
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [f2fs-dev] [PATCH v2] f2fs: quota: fix quota flush failure during filesystem freeze
2026-10-12 2:54 [f2fs-dev] [PATCH v2] f2fs: quota: fix quota flush failure during filesystem freeze Jianan Huang
@ 2026-10-14 8:41 ` Chao Yu via Linux-f2fs-devel
2026-10-14 15:50 ` patchwork-bot+f2fs--- via Linux-f2fs-devel
1 sibling, 0 replies; 3+ messages in thread
From: Chao Yu via Linux-f2fs-devel @ 2026-10-14 8:41 UTC (permalink / raw)
To: Jianan Huang, linux-f2fs-devel, jaegeuk
On 10/12/26 10:54, Jianan Huang wrote:
> Quota flush retries can be exhausted during filesystem freeze.
>
> freeze_super() and the quota checkpoint may race as below.
>
> freeze_super() f2fs_ckpt
> - down_write(&sb->s_umount)
> - sb->s_writers.frozen = SB_FREEZE_PAGEFAULT
> - sync_filesystem()
> - f2fs_sync_fs()
> - f2fs_issue_checkpoint()
> - queue CP_SYNC -----------------> - block_operations()
> - down_read_trylock(s_umount)
> : fails; freeze holds write lock
> - quota flush retries exhausted
> - set CP_QUOTA_NEED_FSCK_FLAG
>
> During the PAGEFAULT sync pass, freeze_super() holds s_umount for
> write, but umount_lock_holder is not set until f2fs_freeze(). Thus
> quota writeback tries to acquire s_umount again and can exhaust retries.
>
> With checkpoint merge enabled, f2fs_issue_checkpoint() may dispatch
> CP_SYNC to f2fs_ckpt. That thread also cannot acquire the freeze lock.
>
> Record current as umount_lock_holder around the VFS PAGEFAULT sync so
> checkpoint runs in the freeze caller and quota flush uses its existing
> s_umount write lock.
>
> Fixes: eb85c2410d6f ("f2fs: quota: fix to avoid warning in dquot_writeback_dquots()")
> Signed-off-by: Jianan Huang <jnhuang95@gmail.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Thanks,
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [f2fs-dev] [PATCH v2] f2fs: quota: fix quota flush failure during filesystem freeze
2026-10-12 2:54 [f2fs-dev] [PATCH v2] f2fs: quota: fix quota flush failure during filesystem freeze Jianan Huang
2026-10-14 8:41 ` Chao Yu via Linux-f2fs-devel
@ 2026-10-14 15:50 ` patchwork-bot+f2fs--- via Linux-f2fs-devel
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+f2fs--- via Linux-f2fs-devel @ 2026-10-14 15:50 UTC (permalink / raw)
To: Jianan Huang; +Cc: jaegeuk, linux-f2fs-devel
Hello:
This patch was applied to jaegeuk/f2fs.git (dev)
by Jaegeuk Kim <jaegeuk@kernel.org>:
On Mon, 12 Oct 2026 10:54:42 +0800 you wrote:
> Quota flush retries can be exhausted during filesystem freeze.
>
> freeze_super() and the quota checkpoint may race as below.
>
> freeze_super() f2fs_ckpt
> - down_write(&sb->s_umount)
> - sb->s_writers.frozen = SB_FREEZE_PAGEFAULT
> - sync_filesystem()
> - f2fs_sync_fs()
> - f2fs_issue_checkpoint()
> - queue CP_SYNC -----------------> - block_operations()
> - down_read_trylock(s_umount)
> : fails; freeze holds write lock
> - quota flush retries exhausted
> - set CP_QUOTA_NEED_FSCK_FLAG
>
> [...]
Here is the summary with links:
- [f2fs-dev,v2] f2fs: quota: fix quota flush failure during filesystem freeze
https://git.kernel.org/jaegeuk/f2fs/c/e455328a66a5
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-10-14 15:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-12 2:54 [f2fs-dev] [PATCH v2] f2fs: quota: fix quota flush failure during filesystem freeze Jianan Huang
2026-10-14 8:41 ` Chao Yu via Linux-f2fs-devel
2026-10-14 15:50 ` patchwork-bot+f2fs--- via Linux-f2fs-devel
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.