@@ -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;
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> --- volumes.c | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-)