btrfs-progs: provide better error message for raid profile mismatch
PATCH 1/1 btrfs-progs: provide better error message for raid profile mismatch
Current error messages are like following:
Error: unable to create FS with metadata profile 32 (have 2 devices)
Error: unable to create FS with metadata profile 256 (have 2 devices)
Obviously it is hard for users to interpret "profile XX" to proper meaning, such as "raidN". So use recongizable string instead of internal numerical value. In case of "dup", use an explicit message.
Plus this patch fix a bug that message mistake metadata profile for data profile.
After applying this patch, messages will be like:
Error: dup is not allowed when FS have multiple devices
Error: unable to create FS with metadata profile RAID6 (have 2 devices but 3 devices are required)
--- cmds-filesystem.c | 22 ------------------ utils.c | 63 +++++++++++++++++++++++++++++++++++++++++++++++----- utils.h | 1 + 3 files changed, 58 insertions(+), 28 deletions(-)
cmds-filesystem.c +0 -22
@@ -134,28 +134,6 @@ static char *group_type_str(u64 flag) } } -static char *group_profile_str (u64 flag) -{ -switch (flag &BTRFS_BLOCK_GROUP_PROFILE_MASK ) { -case 0 : -return "single" ; -case BTRFS_BLOCK_GROUP_RAID0 : -return "RAID0" ; -case BTRFS_BLOCK_GROUP_RAID1 : -return "RAID1" ; -case BTRFS_BLOCK_GROUP_RAID5 : -return "RAID5" ; -case BTRFS_BLOCK_GROUP_RAID6 : -return "RAID6" ; -case BTRFS_BLOCK_GROUP_DUP : -return "DUP" ; -case BTRFS_BLOCK_GROUP_RAID10 : -return "RAID10" ; -default : -return "unknown" ; - } -} -static int get_df (int fd,struct btrfs_ioctl_space_args **sargs_ret) {u64 count =0 ;
utils.c +57 -6
79 lines not on this page · raw message
utils.h +1 -0
@@ -88,6 +88,7 @@ u64 btrfs_device_size(int fd, struct stat *st);int test_dev_for_mkfs (char *file,int force_overwrite,char *estr);int scan_for_btrfs (int where,int update_kernel);int get_label_mounted (const char *mount_path,char *labelp); +char *group_profile_str (u64 flag);int test_num_disk_vs_raid (u64 metadata_profile,u64 data_profile,u64 dev_cnt,int mixed,char *estr);int is_vol_small (char *file);
Signature · 1 line
1.7.1
Quoted 8 lines · Hidetoshi Seto
Current error messages are like following:
Error: unable to create FS with metadata profile 32 (have 2 devices)
Error: unable to create FS with metadata profile 256 (have 2 devices)Obviously it is hard for users to interpret "profile XX" to proper meaning, such as "raidN". So use recongizable string instead of internal numerical value. In case of "dup", use an explicit message.
Quoted 7 lines
Plus this patch fix a bug that message mistake metadata profile for data profile.
After applying this patch, messages will be like:
Error: dup is not allowed when FS have multiple devices
Error: unable to create FS with metadata profile RAID6 (have 2 devices but 3 devices are required)
Nice, thanks.
Moving the group_profile_* functions to utils.c was done in "Enhance the command btrfs filesystem df", so your patch ends up a bit shorter.
I've modified the 'dup' to be 'DUP' in the error message and changelog so it's consistent with spelling of the RAIDx names.