btrfs-progs: get rid of btrfs_raid_profile_table
cover btrfs-progs: get rid of btrfs_raid_profile_table
From: Johannes Thumshirn <[email protected]>
As promised here's the removal of btrfs_raid_profile_table which helped as a intermediate step to refactor the raid specific settings in block group creation in progs.
As Qu remindet me of the outstanding debts this morning, I decided to go ahead and pay my debt today.
It will not be the last refactoring round in this area though, as the btrfs-progs side and the kernel side still diverge a lot.
This series passes a full 'make test' run from btrfs-progs.
Johannes Thumshirn (4):
btrfs-progs: use sub_stripes property from btrfs_raid_attr
btrfs-progs: use minimal number of stripes from btrfs_raid_attr
btrfs-progs: remove unused btrfs_raid_profile::max_stripes
btrfs-progs: remove btrfs_raid_profile_table
volumes.c | 71 +++++-------------------------------------------------- 1 file changed, 6 insertions(+), 65 deletions(-)
Signature · 1 line
2.26.2
PATCH 1/4 btrfs-progs: use sub_stripes property from btrfs_raid_attr
From: Johannes Thumshirn <[email protected]>
Both btrfs_raid_attr and btrfs_raid_profile define the number of sub_stripes a raid type has.
Use the one from btrfs_raid_attr and get rid of the field in btrfs_raid_profile.
--- volumes.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-)
volumes.c +1 -11
@@ -1002,61 +1002,51 @@ static const struct btrfs_raid_profile {int num_stripes;int max_stripes;int min_stripes; -int sub_stripes; } btrfs_raid_profile_table[BTRFS_NR_RAID_TYPES] = { [BTRFS_RAID_RAID10] = { .num_stripes = 0, .max_stripes = 0, .min_stripes = 4, - .sub_stripes = 2, }, [BTRFS_RAID_RAID1] = { .num_stripes = 0, .max_stripes = 0, .min_stripes = 2, - .sub_stripes = 1, }, [BTRFS_RAID_RAID1C3] = { .num_stripes = 0, .max_stripes = 0, .min_stripes = 3, - .sub_stripes = 1, }, [BTRFS_RAID_RAID1C4] = { .num_stripes = 0, .max_stripes = 0, .min_stripes = 4, - .sub_stripes = 1, }, [BTRFS_RAID_DUP] = { .num_stripes = 2, .max_stripes = 0, .min_stripes = 2, - .sub_stripes = 1, }, [BTRFS_RAID_RAID0] = { .num_stripes = 0, .max_stripes = 0, .min_stripes = 2, - .sub_stripes = 1, }, [BTRFS_RAID_SINGLE] = { .num_stripes = 1, .max_stripes = 0, .min_stripes = 1, - .sub_stripes = 1, }, [BTRFS_RAID_RAID5] = { .num_stripes = 0, .max_stripes = 0, .min_stripes = 2, - .sub_stripes = 1, }, [BTRFS_RAID_RAID6] = { .num_stripes = 0, .max_stripes = 0, .min_stripes = 3, - .sub_stripes = 1, }, };
@@ -1067,7 +1057,7 @@ static void init_alloc_chunk_ctl(struct btrfs_fs_info *info, ctl->num_stripes = btrfs_raid_profile_table[type].num_stripes; ctl->min_stripes = btrfs_raid_profile_table[type].min_stripes; - ctl->sub_stripes = btrfs_raid_profile_table[type].sub_stripes; + ctl->sub_stripes = btrfs_raid_array[type].sub_stripes; ctl->stripe_len =BTRFS_STRIPE_LEN ;switch (type) {
Signature · 1 line
2.26.2
PATCH 2/4 btrfs-progs: use minimal number of stripes from btrfs_raid_attr
In reply to Johannes ThumshirnFrom: Johannes Thumshirn <[email protected]>
Both btrfs_raid_attr and btrfs_raid_profile define the minimal number of stripes for each raid profile.
The difference is in btrfs_raid_attr the number of stripes is called devs_min and in btrfs_raid_profile its called min_stripes.
--- volumes.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-)
volumes.c +4 -11
@@ -1001,52 +1001,42 @@ error:static const struct btrfs_raid_profile {int num_stripes;int max_stripes; -int min_stripes; } btrfs_raid_profile_table[BTRFS_NR_RAID_TYPES ] = { [BTRFS_RAID_RAID10 ] = { .num_stripes =0 , .max_stripes =0 , - .min_stripes =4 , }, [BTRFS_RAID_RAID1 ] = { .num_stripes =0 , .max_stripes =0 , - .min_stripes =2 , }, [BTRFS_RAID_RAID1C3 ] = { .num_stripes =0 , .max_stripes =0 , - .min_stripes =3 , }, [BTRFS_RAID_RAID1C4 ] = { .num_stripes =0 , .max_stripes =0 , - .min_stripes =4 , }, [BTRFS_RAID_DUP ] = { .num_stripes =2 , .max_stripes =0 , - .min_stripes =2 , }, [BTRFS_RAID_RAID0 ] = { .num_stripes =0 , .max_stripes =0 , - .min_stripes =2 , }, [BTRFS_RAID_SINGLE ] = { .num_stripes =1 , .max_stripes =0 , - .min_stripes =1 , }, [BTRFS_RAID_RAID5 ] = { .num_stripes =0 , .max_stripes =0 , - .min_stripes =2 , }, [BTRFS_RAID_RAID6 ] = { .num_stripes =0 , .max_stripes =0 , - .min_stripes =3 , }, };
@@ -1056,11 +1046,14 @@ static void init_alloc_chunk_ctl(struct btrfs_fs_info *info,int type = ctl->type; ctl->num_stripes = btrfs_raid_profile_table[type].num_stripes; - ctl->min_stripes = btrfs_raid_profile_table[type].min_stripes; + ctl->min_stripes = btrfs_raid_array[type].devs_min; ctl->sub_stripes = btrfs_raid_array[type].sub_stripes; ctl->stripe_len =BTRFS_STRIPE_LEN ;switch (type) { +case BTRFS_RAID_DUP : + ctl->min_stripes =2 ; +break ;case BTRFS_RAID_RAID1 :case BTRFS_RAID_RAID1C3 :case BTRFS_RAID_RAID1C4 :
Signature · 1 line
2.26.2
PATCH 3/4 btrfs-progs: remove unused btrfs_raid_profile::max_stripes
In reply to Johannes ThumshirnFrom: Johannes Thumshirn <[email protected]>
The max_stripes value of btrfs_raid_profile_table is unused, so we can just remove it as well.
--- volumes.c | 10 ---------- 1 file changed, 10 deletions(-)
volumes.c +0 -10
@@ -1000,43 +1000,33 @@ error:static const struct btrfs_raid_profile {int num_stripes; -int max_stripes; } btrfs_raid_profile_table[BTRFS_NR_RAID_TYPES ] = { [BTRFS_RAID_RAID10 ] = { .num_stripes =0 , - .max_stripes =0 , }, [BTRFS_RAID_RAID1 ] = { .num_stripes =0 , - .max_stripes =0 , }, [BTRFS_RAID_RAID1C3 ] = { .num_stripes =0 , - .max_stripes =0 , }, [BTRFS_RAID_RAID1C4 ] = { .num_stripes =0 , - .max_stripes =0 , }, [BTRFS_RAID_DUP ] = { .num_stripes =2 , - .max_stripes =0 , }, [BTRFS_RAID_RAID0 ] = { .num_stripes =0 , - .max_stripes =0 , }, [BTRFS_RAID_SINGLE ] = { .num_stripes =1 , - .max_stripes =0 , }, [BTRFS_RAID_RAID5 ] = { .num_stripes =0 , - .max_stripes =0 , }, [BTRFS_RAID_RAID6 ] = { .num_stripes =0 , - .max_stripes =0 , }, };
Signature · 1 line
2.26.2
PATCH 4/4 btrfs-progs: remove btrfs_raid_profile_table
In reply to Johannes ThumshirnFrom: Johannes Thumshirn <[email protected]>
For SINGLE and DUP RAID profiles we can get the num_stripes values from btrfs_raid_attr::dev:stripes. For all other RAID profiles the value is calculated anyways.
As this was the last remaining member of the btrfs_raid_profile_table we can remove it as well.
--- volumes.c | 34 +--------------------------------- 1 file changed, 1 insertion(+), 33 deletions(-)
volumes.c +1 -33
@@ -998,44 +998,12 @@ error: - 2 * sizeof(struct btrfs_chunk)) \ / sizeof(struct btrfs_stripe) + 1) -static const struct btrfs_raid_profile { -int num_stripes; -} btrfs_raid_profile_table[BTRFS_NR_RAID_TYPES ] = { - [BTRFS_RAID_RAID10 ] = { - .num_stripes =0 , - }, - [BTRFS_RAID_RAID1 ] = { - .num_stripes =0 , - }, - [BTRFS_RAID_RAID1C3 ] = { - .num_stripes =0 , - }, - [BTRFS_RAID_RAID1C4 ] = { - .num_stripes =0 , - }, - [BTRFS_RAID_DUP ] = { - .num_stripes =2 , - }, - [BTRFS_RAID_RAID0 ] = { - .num_stripes =0 , - }, - [BTRFS_RAID_SINGLE ] = { - .num_stripes =1 , - }, - [BTRFS_RAID_RAID5 ] = { - .num_stripes =0 , - }, - [BTRFS_RAID_RAID6 ] = { - .num_stripes =0 , - }, -}; -static void init_alloc_chunk_ctl (struct btrfs_fs_info *info,struct alloc_chunk_ctl *ctl) {int type = ctl->type; - ctl->num_stripes = btrfs_raid_profile_table[type].num_stripes; + ctl->num_stripes = btrfs_raid_array[type].dev_stripes; ctl->min_stripes = btrfs_raid_array[type].devs_min; ctl->sub_stripes = btrfs_raid_array[type].sub_stripes; ctl->stripe_len =BTRFS_STRIPE_LEN ;
Signature · 1 line
2.26.2
Quoted 11 lines · Johannes Thumshirn
From: Johannes Thumshirn <[email protected]>
As promised here's the removal of
btrfs_raid_profile_tablewhich helped as a intermediate step to refactor the raid specific settings in block group creation in progs.As Qu remindet me of the outstanding debts this morning, I decided to go ahead and pay my debt today.
It will not be the last refactoring round in this area though, as the btrfs-progs side and the kernel side still diverge a lot.
Thanks, all look good. This level of granularity makes review easy and as said before, the intermediate patches are ok esp when the code diverged.