Skip to contentSkip to conversation

f2fs: quota: fix stale lock holder on remount failure

PATCH Superseded Jianan Huang 2 participants 3 messages Sep 8 – Sep 9 F2FS file system

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 f2fs: quota: fix stale lock holder on remount failure

F2FS remount can fail while duplicating a journalled quota file name.

f2fs_remount()
- sbi->umount_lock_holder = current
- kstrdup(F2FS_OPTION(sbi).s_qf_names[i])
: fails
- free previously duplicated names
- return -ENOMEM

The direct return leaves umount_lock_holder pointing at the failed remount context. A later checkpoint may then wrongly treat another context as the s_umount lock holder.

Clear umount_lock_holder before returning -ENOMEM.

Fixes eb85c2410d6f ("f2fs: quota: fix to avoid warning in dquot_writeback_dquots()")
---
 fs/f2fs/super.c | 1 +
 1 file changed, 1 insertion(+)
fs/f2fs/super.c +1 -0
index 1314b6ccced9..e249ea19beaf 100644
@@ -2864,6 +2864,7 @@ static int __f2fs_remount(struct fs_context *fc, struct super_block *sb)
 			if (!org_mount_opt.s_qf_names[i]) {
 				for (j = 0; j < i; j++)
 					kfree(org_mount_opt.s_qf_names[j]);
+				sbi->umount_lock_holder = NULL;
 				return -ENOMEM;
 			}
 		} else {
Signature · 8 lines
2.43.0



_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
#1 lore raw
Quoted 26 lines · Jianan Huang

F2FS remount can fail while duplicating a journalled quota file name.

f2fs_remount()
- sbi->umount_lock_holder = current
- kstrdup(F2FS_OPTION(sbi).s_qf_names[i])
: fails
- free previously duplicated names
- return -ENOMEM

The direct return leaves umount_lock_holder pointing at the failed remount context. A later checkpoint may then wrongly treat another context as the s_umount lock holder.

Clear umount_lock_holder before returning -ENOMEM.

Fixes eb85c2410d6f ("f2fs: quota: fix to avoid warning in dquot_writeback_dquots()")
---
 fs/f2fs/super.c | 1 +
 1 file changed, 1 insertion(+)
fs/f2fs/super.c +0 -0
index 1314b6ccced9..e249ea19beaf 100644

fs/f2fs/super.c static int __f2fs_remount(struct fs_context *fc, struct super_block *sb) · line 2868

Quoted 5 lines
fs/f2fs/super.c +1 -0
@@ -2864,6 +2864,7 @@ static int __f2fs_remount(struct fs_context *fc, struct super_block *sb)
 			if (!org_mount_opt.s_qf_names[i]) {
 				for (j = 0; j < i; j++)
 					kfree(org_mount_opt.s_qf_names[j]);
+				sbi->umount_lock_holder = NULL;
 				return -ENOMEM;

How about adding restore_holder label, call goto restore_holder here?

Thanks,

fs/f2fs/super.c static int __f2fs_remount(struct fs_context *fc, struct super_block *sb) · line 2870

Quoted 2 lines
fs/f2fs/super.c +0 -0
 			}
 		} else {

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

#2 lore raw
Quoted 36 lines · Chao Yu <[email protected]> 于2026年9月9日周三 19:15写道:
Quoted 26 lines · Jianan Huang

F2FS remount can fail while duplicating a journalled quota file name.

f2fs_remount()
- sbi->umount_lock_holder = current
- kstrdup(F2FS_OPTION(sbi).s_qf_names[i])
: fails
- free previously duplicated names
- return -ENOMEM

The direct return leaves umount_lock_holder pointing at the failed remount context. A later checkpoint may then wrongly treat another context as the s_umount lock holder.

Clear umount_lock_holder before returning -ENOMEM.

Fixes eb85c2410d6f ("f2fs: quota: fix to avoid warning in dquot_writeback_dquots()")
---
 fs/f2fs/super.c | 1 +
 1 file changed, 1 insertion(+)
fs/f2fs/super.c +0 -0
index 1314b6ccced9..e249ea19beaf 100644

fs/f2fs/super.c static int __f2fs_remount(struct fs_context *fc, struct super_block *sb) · line 2868

Quoted 5 lines
fs/f2fs/super.c +1 -0
@@ -2864,6 +2864,7 @@ static int __f2fs_remount(struct fs_context *fc, struct super_block *sb)
                      if (!org_mount_opt.s_qf_names[i]) {
                              for (j = 0; j < i; j++)
                                      kfree(org_mount_opt.s_qf_names[j]);
+                             sbi->umount_lock_holder = NULL;
                              return -ENOMEM;

How about adding restore_holder label, call goto restore_holder here?

Quoted 1 line

Thanks,

Updated in v2,

Thanks,

Quoted 4 lines

fs/f2fs/super.c static int __f2fs_remount(struct fs_context *fc, struct super_block *sb) · line 2870

Quoted 3 lines
fs/f2fs/super.c +0 -0
                      }
              } else {

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