Commit 41a6e891 authored by Anand Jain's avatar Anand Jain Committed by David Sterba

btrfs: move btrfs_raid_group values to btrfs_raid_attr table

Add a new member struct btrfs_raid_attr::bg_flag so that
btrfs_raid_array can maintain the bit map flag of the raid type, and
so we can drop btrfs_raid_group.
Signed-off-by: default avatarAnand Jain <anand.jain@oracle.com>
Reviewed-by: default avatarNikolay Borisov <nborisov@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent ed23467b
...@@ -3521,7 +3521,7 @@ int btrfs_get_num_tolerated_disk_barrier_failures(u64 flags) ...@@ -3521,7 +3521,7 @@ int btrfs_get_num_tolerated_disk_barrier_failures(u64 flags)
for (raid_type = 0; raid_type < BTRFS_NR_RAID_TYPES; raid_type++) { for (raid_type = 0; raid_type < BTRFS_NR_RAID_TYPES; raid_type++) {
if (raid_type == BTRFS_RAID_SINGLE) if (raid_type == BTRFS_RAID_SINGLE)
continue; continue;
if (!(flags & btrfs_raid_group[raid_type])) if (!(flags & btrfs_raid_array[raid_type].bg_flag))
continue; continue;
min_tolerated = min(min_tolerated, min_tolerated = min(min_tolerated,
btrfs_raid_array[raid_type]. btrfs_raid_array[raid_type].
......
...@@ -4180,7 +4180,7 @@ static u64 btrfs_reduce_alloc_profile(struct btrfs_fs_info *fs_info, u64 flags) ...@@ -4180,7 +4180,7 @@ static u64 btrfs_reduce_alloc_profile(struct btrfs_fs_info *fs_info, u64 flags)
/* First, mask out the RAID levels which aren't possible */ /* First, mask out the RAID levels which aren't possible */
for (raid_type = 0; raid_type < BTRFS_NR_RAID_TYPES; raid_type++) { for (raid_type = 0; raid_type < BTRFS_NR_RAID_TYPES; raid_type++) {
if (num_devices >= btrfs_raid_array[raid_type].devs_min) if (num_devices >= btrfs_raid_array[raid_type].devs_min)
allowed |= btrfs_raid_group[raid_type]; allowed |= btrfs_raid_array[raid_type].bg_flag;
} }
allowed &= flags; allowed &= flags;
......
...@@ -41,6 +41,7 @@ const struct btrfs_raid_attr btrfs_raid_array[BTRFS_NR_RAID_TYPES] = { ...@@ -41,6 +41,7 @@ const struct btrfs_raid_attr btrfs_raid_array[BTRFS_NR_RAID_TYPES] = {
.devs_increment = 2, .devs_increment = 2,
.ncopies = 2, .ncopies = 2,
.raid_name = "raid10", .raid_name = "raid10",
.bg_flag = BTRFS_BLOCK_GROUP_RAID10,
}, },
[BTRFS_RAID_RAID1] = { [BTRFS_RAID_RAID1] = {
.sub_stripes = 1, .sub_stripes = 1,
...@@ -51,6 +52,7 @@ const struct btrfs_raid_attr btrfs_raid_array[BTRFS_NR_RAID_TYPES] = { ...@@ -51,6 +52,7 @@ const struct btrfs_raid_attr btrfs_raid_array[BTRFS_NR_RAID_TYPES] = {
.devs_increment = 2, .devs_increment = 2,
.ncopies = 2, .ncopies = 2,
.raid_name = "raid1", .raid_name = "raid1",
.bg_flag = BTRFS_BLOCK_GROUP_RAID1,
}, },
[BTRFS_RAID_DUP] = { [BTRFS_RAID_DUP] = {
.sub_stripes = 1, .sub_stripes = 1,
...@@ -61,6 +63,7 @@ const struct btrfs_raid_attr btrfs_raid_array[BTRFS_NR_RAID_TYPES] = { ...@@ -61,6 +63,7 @@ const struct btrfs_raid_attr btrfs_raid_array[BTRFS_NR_RAID_TYPES] = {
.devs_increment = 1, .devs_increment = 1,
.ncopies = 2, .ncopies = 2,
.raid_name = "dup", .raid_name = "dup",
.bg_flag = BTRFS_BLOCK_GROUP_DUP,
}, },
[BTRFS_RAID_RAID0] = { [BTRFS_RAID_RAID0] = {
.sub_stripes = 1, .sub_stripes = 1,
...@@ -71,6 +74,7 @@ const struct btrfs_raid_attr btrfs_raid_array[BTRFS_NR_RAID_TYPES] = { ...@@ -71,6 +74,7 @@ const struct btrfs_raid_attr btrfs_raid_array[BTRFS_NR_RAID_TYPES] = {
.devs_increment = 1, .devs_increment = 1,
.ncopies = 1, .ncopies = 1,
.raid_name = "raid0", .raid_name = "raid0",
.bg_flag = BTRFS_BLOCK_GROUP_RAID0,
}, },
[BTRFS_RAID_SINGLE] = { [BTRFS_RAID_SINGLE] = {
.sub_stripes = 1, .sub_stripes = 1,
...@@ -81,6 +85,7 @@ const struct btrfs_raid_attr btrfs_raid_array[BTRFS_NR_RAID_TYPES] = { ...@@ -81,6 +85,7 @@ const struct btrfs_raid_attr btrfs_raid_array[BTRFS_NR_RAID_TYPES] = {
.devs_increment = 1, .devs_increment = 1,
.ncopies = 1, .ncopies = 1,
.raid_name = "single", .raid_name = "single",
.bg_flag = 0,
}, },
[BTRFS_RAID_RAID5] = { [BTRFS_RAID_RAID5] = {
.sub_stripes = 1, .sub_stripes = 1,
...@@ -91,6 +96,7 @@ const struct btrfs_raid_attr btrfs_raid_array[BTRFS_NR_RAID_TYPES] = { ...@@ -91,6 +96,7 @@ const struct btrfs_raid_attr btrfs_raid_array[BTRFS_NR_RAID_TYPES] = {
.devs_increment = 1, .devs_increment = 1,
.ncopies = 2, .ncopies = 2,
.raid_name = "raid5", .raid_name = "raid5",
.bg_flag = BTRFS_BLOCK_GROUP_RAID5,
}, },
[BTRFS_RAID_RAID6] = { [BTRFS_RAID_RAID6] = {
.sub_stripes = 1, .sub_stripes = 1,
...@@ -101,6 +107,7 @@ const struct btrfs_raid_attr btrfs_raid_array[BTRFS_NR_RAID_TYPES] = { ...@@ -101,6 +107,7 @@ const struct btrfs_raid_attr btrfs_raid_array[BTRFS_NR_RAID_TYPES] = {
.devs_increment = 1, .devs_increment = 1,
.ncopies = 3, .ncopies = 3,
.raid_name = "raid6", .raid_name = "raid6",
.bg_flag = BTRFS_BLOCK_GROUP_RAID6,
}, },
}; };
...@@ -112,16 +119,6 @@ const char *get_raid_name(enum btrfs_raid_types type) ...@@ -112,16 +119,6 @@ const char *get_raid_name(enum btrfs_raid_types type)
return btrfs_raid_array[type].raid_name; return btrfs_raid_array[type].raid_name;
} }
const u64 btrfs_raid_group[BTRFS_NR_RAID_TYPES] = {
[BTRFS_RAID_RAID10] = BTRFS_BLOCK_GROUP_RAID10,
[BTRFS_RAID_RAID1] = BTRFS_BLOCK_GROUP_RAID1,
[BTRFS_RAID_DUP] = BTRFS_BLOCK_GROUP_DUP,
[BTRFS_RAID_RAID0] = BTRFS_BLOCK_GROUP_RAID0,
[BTRFS_RAID_SINGLE] = 0,
[BTRFS_RAID_RAID5] = BTRFS_BLOCK_GROUP_RAID5,
[BTRFS_RAID_RAID6] = BTRFS_BLOCK_GROUP_RAID6,
};
/* /*
* Table to convert BTRFS_RAID_* to the error code if minimum number of devices * Table to convert BTRFS_RAID_* to the error code if minimum number of devices
* condition is not met. Zero means there's no corresponding * condition is not met. Zero means there's no corresponding
...@@ -1899,7 +1896,7 @@ static int btrfs_check_raid_min_devices(struct btrfs_fs_info *fs_info, ...@@ -1899,7 +1896,7 @@ static int btrfs_check_raid_min_devices(struct btrfs_fs_info *fs_info,
} while (read_seqretry(&fs_info->profiles_lock, seq)); } while (read_seqretry(&fs_info->profiles_lock, seq));
for (i = 0; i < BTRFS_NR_RAID_TYPES; i++) { for (i = 0; i < BTRFS_NR_RAID_TYPES; i++) {
if (!(all_avail & btrfs_raid_group[i])) if (!(all_avail & btrfs_raid_array[i].bg_flag))
continue; continue;
if (num_devices < btrfs_raid_array[i].devs_min) { if (num_devices < btrfs_raid_array[i].devs_min) {
......
...@@ -330,11 +330,11 @@ struct btrfs_raid_attr { ...@@ -330,11 +330,11 @@ struct btrfs_raid_attr {
int devs_increment; /* ndevs has to be a multiple of this */ int devs_increment; /* ndevs has to be a multiple of this */
int ncopies; /* how many copies to data has */ int ncopies; /* how many copies to data has */
const char raid_name[8]; /* name of the raid */ const char raid_name[8]; /* name of the raid */
u64 bg_flag; /* block group flag of the raid */
}; };
extern const struct btrfs_raid_attr btrfs_raid_array[BTRFS_NR_RAID_TYPES]; extern const struct btrfs_raid_attr btrfs_raid_array[BTRFS_NR_RAID_TYPES];
extern const int btrfs_raid_mindev_error[BTRFS_NR_RAID_TYPES]; extern const int btrfs_raid_mindev_error[BTRFS_NR_RAID_TYPES];
extern const u64 btrfs_raid_group[BTRFS_NR_RAID_TYPES];
struct map_lookup { struct map_lookup {
u64 type; u64 type;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment