Skip to contentSkip to conversation

f2fs: quota: fix quota flush failure during filesystem freeze

PATCH Applied Jianan Huang 2 participants 3 messages Oct 12 – Oct 14 F2FS file system

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 f2fs: quota: fix quota flush failure during filesystem freeze

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()")

---
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(-)
fs/f2fs/super.c +20 -1
index 00da08504d55..fa105ca14653 100644
@@ -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,
Signature · 8 lines
2.43.0



_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Reviewed-by Chao Yu on v2 1/1
#1 lore raw
Quoted 23 lines · 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.

Quoted 6 lines

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()")

Thanks,

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

#2 lore raw
In reply to Jianan Huang

Hello:

This patch was applied to jaegeuk/f2fs.git (dev)
by Jaegeuk Kim <[email protected]>:

Quoted 16 lines · 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

Quoted 1 line

[...]

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!

Signature · 10 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html




_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel