btrfs-progs: rename and move group_profile_max_safe_loss

The helper belongs to the others that translate bg flags to the raid
attr table member.

Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
David Sterba 2021-09-07 16:38:56 +02:00
parent a5becbde35
commit 76ab1fa364
5 changed files with 10 additions and 11 deletions

View File

@ -652,13 +652,6 @@ int test_num_disk_vs_raid(u64 metadata_profile, u64 data_profile,
return 0;
}
int group_profile_max_safe_loss(u64 flags)
{
const int index = btrfs_bg_flags_to_raid_index(flags);
return btrfs_raid_array[index].tolerated_failures;
}
/*
* This reads a line from the stdin and only returns non-zero if the
* first whitespace delimited token is a case insensitive match with yes

View File

@ -61,7 +61,6 @@ int set_label(const char *btrfs_dev, const char *label);
int check_arg_type(const char *input);
int get_label_mounted(const char *mount_path, char *labelp);
int get_label_unmounted(const char *dev, char *label);
int group_profile_max_safe_loss(u64 flags);
int csum_tree_block(struct btrfs_fs_info *root, struct extent_buffer *buf,
int verify);
int ask_user(const char *question);

View File

@ -210,6 +210,13 @@ const char *btrfs_bg_type_to_raid_name(u64 flags)
return btrfs_raid_array[index].raid_name;
}
int btrfs_bg_type_to_tolerated_failures(u64 flags)
{
const int index = btrfs_bg_flags_to_raid_index(flags);
return btrfs_raid_array[index].tolerated_failures;
}
static inline int nr_parity_stripes(struct map_lookup *map)
{
if (map->type & BTRFS_BLOCK_GROUP_RAID5)

View File

@ -308,5 +308,6 @@ int btrfs_fix_device_and_super_size(struct btrfs_fs_info *fs_info);
enum btrfs_raid_types btrfs_bg_flags_to_raid_index(u64 flags);
int btrfs_bg_type_to_factor(u64 flags);
const char *btrfs_bg_type_to_raid_name(u64 flags);
int btrfs_bg_type_to_tolerated_failures(u64 flags);
#endif

View File

@ -1341,10 +1341,9 @@ int BOX_MAIN(mkfs)(int argc, char **argv)
goto error;
}
if (group_profile_max_safe_loss(metadata_profile) <
group_profile_max_safe_loss(data_profile)){
if (btrfs_bg_type_to_tolerated_failures(metadata_profile) <
btrfs_bg_type_to_tolerated_failures(data_profile))
warning("metadata has lower redundancy than data!\n");
}
mkfs_cfg.label = label;
memcpy(mkfs_cfg.fs_uuid, fs_uuid, sizeof(mkfs_cfg.fs_uuid));