diff --git a/common/utils.c b/common/utils.c index e0b1dc8f..3f93108e 100644 --- a/common/utils.c +++ b/common/utils.c @@ -576,27 +576,6 @@ int get_fsid(const char *path, u8 *fsid, int silent) return ret; } -static int group_profile_devs_min(u64 flag) -{ - switch (flag & BTRFS_BLOCK_GROUP_PROFILE_MASK) { - case 0: /* single */ - case BTRFS_BLOCK_GROUP_DUP: - return 1; - case BTRFS_BLOCK_GROUP_RAID0: - case BTRFS_BLOCK_GROUP_RAID1: - case BTRFS_BLOCK_GROUP_RAID5: - return 2; - case BTRFS_BLOCK_GROUP_RAID6: - case BTRFS_BLOCK_GROUP_RAID1C3: - return 3; - case BTRFS_BLOCK_GROUP_RAID10: - case BTRFS_BLOCK_GROUP_RAID1C4: - return 4; - default: - return -1; - } -} - int test_num_disk_vs_raid(u64 metadata_profile, u64 data_profile, u64 dev_cnt, int mixed, int ssd) { @@ -628,7 +607,7 @@ int test_num_disk_vs_raid(u64 metadata_profile, u64 data_profile, "ERROR: unable to create FS with metadata profile %s " "(have %llu devices but %d devices are required)\n", btrfs_group_profile_str(metadata_profile), dev_cnt, - group_profile_devs_min(metadata_profile)); + btrfs_bg_type_to_devs_min(metadata_profile)); return 1; } if (data_profile & ~allowed) { @@ -636,7 +615,7 @@ int test_num_disk_vs_raid(u64 metadata_profile, u64 data_profile, "ERROR: unable to create FS with data profile %s " "(have %llu devices but %d devices are required)\n", btrfs_group_profile_str(data_profile), dev_cnt, - group_profile_devs_min(data_profile)); + btrfs_bg_type_to_devs_min(data_profile)); return 1; } diff --git a/kernel-shared/volumes.c b/kernel-shared/volumes.c index d8f923c8..28f66397 100644 --- a/kernel-shared/volumes.c +++ b/kernel-shared/volumes.c @@ -217,6 +217,13 @@ int btrfs_bg_type_to_tolerated_failures(u64 flags) return btrfs_raid_array[index].tolerated_failures; } +int btrfs_bg_type_to_devs_min(u64 flags) +{ + const int index = btrfs_bg_flags_to_raid_index(flags); + + return btrfs_raid_array[index].devs_min; +} + static inline int nr_parity_stripes(struct map_lookup *map) { if (map->type & BTRFS_BLOCK_GROUP_RAID5) diff --git a/kernel-shared/volumes.h b/kernel-shared/volumes.h index 33594518..96061dac 100644 --- a/kernel-shared/volumes.h +++ b/kernel-shared/volumes.h @@ -310,5 +310,6 @@ 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); +int btrfs_bg_type_to_devs_min(u64 flags); #endif