Skip to content

Commit 1afe9e7

Browse files
committed
f2fs: fix freezing filesystem during resize
Using FREEZE_HOLDER_USERSPACE has two consequences: (1) If userspace freezes the filesystem after mnt_drop_write_file() but before freeze_super() was called filesystem resizing will fail because the freeze isn't marked as nestable. (2) If the kernel has successfully frozen the filesystem via FREEZE_HOLDER_USERSPACE userspace can simply undo it by using the FITHAW ioctl. Fix both issues by using FREEZE_HOLDER_KERNEL. It will nest with FREEZE_HOLDER_USERSPACE and cannot be undone by userspace. And it is the correct thing to do because the kernel temporarily freezes the filesystem. Signed-off-by: Christian Brauner <[email protected]>
1 parent 05b158d commit 1afe9e7

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

fs/f2fs/gc.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2271,12 +2271,12 @@ int f2fs_resize_fs(struct file *filp, __u64 block_count)
22712271
if (err)
22722272
return err;
22732273

2274-
err = freeze_super(sbi->sb, FREEZE_HOLDER_USERSPACE, NULL);
2274+
err = freeze_super(sbi->sb, FREEZE_HOLDER_KERNEL, NULL);
22752275
if (err)
22762276
return err;
22772277

22782278
if (f2fs_readonly(sbi->sb)) {
2279-
err = thaw_super(sbi->sb, FREEZE_HOLDER_USERSPACE, NULL);
2279+
err = thaw_super(sbi->sb, FREEZE_HOLDER_KERNEL, NULL);
22802280
if (err)
22812281
return err;
22822282
return -EROFS;
@@ -2333,6 +2333,6 @@ int f2fs_resize_fs(struct file *filp, __u64 block_count)
23332333
out_err:
23342334
f2fs_up_write(&sbi->cp_global_sem);
23352335
f2fs_up_write(&sbi->gc_lock);
2336-
thaw_super(sbi->sb, FREEZE_HOLDER_USERSPACE, NULL);
2336+
thaw_super(sbi->sb, FREEZE_HOLDER_KERNEL, NULL);
23372337
return err;
23382338
}

0 commit comments

Comments
 (0)