Skip to content

Commit 0196816

Browse files
Zhiguo NiuJaegeuk Kim
authored andcommitted
f2fs: fix to preserve previous reserve_{blocks,node} value when remount
The following steps will change previous value of reserve_{blocks,node}, this dones not match the original intention. 1.mount -t f2fs -o reserve_root=8192 imgfile test_mount/ F2FS-fs (loop56): Mounted with checkpoint version = 1b69f8c7 mount info: /dev/block/loop56 on /data/test_mount type f2fs (xxx,reserve_root=8192,reserve_node=0,resuid=0,resgid=0,xxx) 2.mount -t f2fs -o remount,reserve_root=4096 /data/test_mount F2FS-fs (loop56): Preserve previous reserve_root=8192 check mount info: reserve_root change to 4096 /dev/block/loop56 on /data/test_mount type f2fs (xxx,reserve_root=4096,reserve_node=0,resuid=0,resgid=0,xxx) Prior to commit d185351 ("f2fs: separate the options parsing and options checking"), the value of reserve_{blocks,node} was only set during the first mount, along with the corresponding mount option F2FS_MOUNT_RESERVE_{ROOT,NODE} . If the mount option F2FS_MOUNT_RESERVE_{ROOT,NODE} was found to have been set during the mount/remount, the previously value of reserve_{blocks,node} would also be preserved, as shown in the code below. if (test_opt(sbi, RESERVE_ROOT)) { f2fs_info(sbi, "Preserve previous reserve_root=%u", F2FS_OPTION(sbi).root_reserved_blocks); } else { F2FS_OPTION(sbi).root_reserved_blocks = arg; set_opt(sbi, RESERVE_ROOT); } But commit d185351 ("f2fs: separate the options parsing and options checking") only preserved the previous mount option; it did not preserve the previous value of reserve_{blocks,node}. Since value of reserve_{blocks,node} value is assigned or not depends on ctx->spec_mask, ctx->spec_mask should be alos handled in f2fs_check_opt_consistency. This patch will clear the corresponding ctx->spec_mask bits in f2fs_check_opt_consistency to preserve the previously values of reserve_{blocks,node} if it already have a value. Fixes: d185351 ("f2fs: separate the options parsing and options checking") Signed-off-by: Zhiguo Niu <[email protected]> Reviewed-by: Chao Yu <[email protected]> Signed-off-by: Jaegeuk Kim <[email protected]>
1 parent 8979bc3 commit 0196816

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

fs/f2fs/super.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1515,6 +1515,7 @@ static int f2fs_check_opt_consistency(struct fs_context *fc,
15151515
F2FS_OPTION(sbi).root_reserved_blocks);
15161516
ctx_clear_opt(ctx, F2FS_MOUNT_RESERVE_ROOT);
15171517
ctx->opt_mask &= ~BIT(F2FS_MOUNT_RESERVE_ROOT);
1518+
ctx->spec_mask &= ~F2FS_SPEC_reserve_root;
15181519
}
15191520
if (test_opt(sbi, RESERVE_NODE) &&
15201521
(ctx->opt_mask & BIT(F2FS_MOUNT_RESERVE_NODE)) &&
@@ -1523,6 +1524,7 @@ static int f2fs_check_opt_consistency(struct fs_context *fc,
15231524
F2FS_OPTION(sbi).root_reserved_nodes);
15241525
ctx_clear_opt(ctx, F2FS_MOUNT_RESERVE_NODE);
15251526
ctx->opt_mask &= ~BIT(F2FS_MOUNT_RESERVE_NODE);
1527+
ctx->spec_mask &= ~F2FS_SPEC_reserve_node;
15261528
}
15271529

15281530
err = f2fs_check_test_dummy_encryption(fc, sb);

0 commit comments

Comments
 (0)