btrfs-progs: consolidate setting of RAID1 stripes

All 3 different RAID1 profiles use the same calculation mehod for the
number of used stripes.

Now that we do table lookups fo rmost of the allocation control
parameters, we can consolidate all 3 RAID1 profiles into a single branch
for the calculation.

Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
Johannes Thumshirn 2020-06-10 21:32:52 +09:00 committed by David Sterba
parent 9b591da1f6
commit 63975f0693

View File

@ -1129,20 +1129,9 @@ int btrfs_alloc_chunk(struct btrfs_trans_handle *trans,
ctl.max_stripes = BTRFS_MAX_DEVS(info);
}
}
if (ctl.type == BTRFS_RAID_RAID1) {
ctl.min_stripes = btrfs_raid_profile_table[ctl.type].min_stripes;
ctl.num_stripes = min(ctl.min_stripes, ctl.total_devs);
if (ctl.num_stripes < ctl.min_stripes)
return -ENOSPC;
}
if (ctl.type == BTRFS_RAID_RAID1C3) {
ctl.min_stripes = btrfs_raid_profile_table[ctl.type].min_stripes;
ctl.num_stripes = min(ctl.min_stripes, ctl.total_devs);
if (ctl.num_stripes < ctl.min_stripes)
return -ENOSPC;
}
if (ctl.type == BTRFS_RAID_RAID1C4) {
ctl.min_stripes = btrfs_raid_profile_table[ctl.type].min_stripes;
if (ctl.type == BTRFS_RAID_RAID1 ||
ctl.type == BTRFS_RAID_RAID1C3 ||
ctl.type == BTRFS_RAID_RAID1C4) {
ctl.num_stripes = min(ctl.min_stripes, ctl.total_devs);
if (ctl.num_stripes < ctl.min_stripes)
return -ENOSPC;