Skip to content

Commit 4d5711f

Browse files
adam900710kdave
authored andcommitted
btrfs-progs: tune: reject csum change if the fs is already using the target csum type
Currently "btrfstune --csum" allows us to change the csum to the same one, this is good for testing but not good for end users, as if the end user interrupts it, they have to resume the change (even it's to the same csum type) until it finished, or kernel would reject such fs. Furthermore, we never change the super block csum type until we completely changed the csum type, thus for resume cases, the fs would still show up as using the old csum type thus won't cause any problem resuming. So here we just reject the csum conversion if the target csum type is the same as the existing csum type. Signed-off-by: Qu Wenruo <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 03b4952 commit 4d5711f

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

tune/change-csum.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#include "common/utils.h"
3030
#include "tune/tune.h"
3131

32-
static int check_csum_change_requreiment(struct btrfs_fs_info *fs_info)
32+
static int check_csum_change_requreiment(struct btrfs_fs_info *fs_info, u16 new_csum_type)
3333
{
3434
struct btrfs_root *tree_root = fs_info->tree_root;
3535
struct btrfs_root *dev_root = fs_info->dev_root;
@@ -75,6 +75,12 @@ static int check_csum_change_requreiment(struct btrfs_fs_info *fs_info)
7575
error("running dev-replace detected, please finish or cancel it.");
7676
return -EINVAL;
7777
}
78+
79+
if (fs_info->csum_type == new_csum_type) {
80+
error("the fs is already using csum type %s (%u)",
81+
btrfs_super_csum_name(new_csum_type), new_csum_type);
82+
return -EINVAL;
83+
}
7884
return 0;
7985
}
8086

@@ -1002,7 +1008,7 @@ int btrfs_change_csum_type(struct btrfs_fs_info *fs_info, u16 new_csum_type)
10021008
int ret;
10031009

10041010
/* Phase 0, check conflicting features. */
1005-
ret = check_csum_change_requreiment(fs_info);
1011+
ret = check_csum_change_requreiment(fs_info, new_csum_type);
10061012
if (ret < 0)
10071013
return ret;
10081014

0 commit comments

Comments
 (0)