On Wed, Jun 10, 2020 at 09:32:49PM +0900, Johannes Thumshirn wrote:
> Introduce a table holding the paramenters for chunk allocation per RAID
> profile.
>
> Also convert all assignments of hardcoded numbers to table lookups in this
> process. Further changes will reduce code duplication even more.
>
> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@xxxxxxx>
> ---
> volumes.c | 95 +++++++++++++++++++++++++++++++++++++++++++++----------
> 1 file changed, 79 insertions(+), 16 deletions(-)
>
> diff --git a/volumes.c b/volumes.c
> index 04bc3d19a025..fc14283db2bb 100644
> --- a/volumes.c
> +++ b/volumes.c
> @@ -1005,6 +1005,68 @@ error:
> - 2 * sizeof(struct btrfs_chunk)) \
> / sizeof(struct btrfs_stripe) + 1)
>
> +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,
> + },
...
This duplicates btrfs_raid_array values, the member variable names don't
match so this makes it hard to compare. I wouldn't mind to create this
table as an intermediate step to clean up the code but in the end we
really don't want to keep btrfs_raid_profile, in the same file even.