btrfs-progs: do table lookup for simple RAID profiles' num_stripes

For the two simple "RAID" profiles single and dup, we can simply fallback
to a table lookup to get num_stripes.

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:53 +09:00 committed by David Sterba
parent 63975f0693
commit 268e4382c3
1 changed files with 1 additions and 4 deletions

View File

@ -1100,7 +1100,7 @@ int btrfs_alloc_chunk(struct btrfs_trans_handle *trans,
}
ctl.type = btrfs_bg_flags_to_raid_index(type);
ctl.num_stripes = 1;
ctl.num_stripes = btrfs_raid_profile_table[ctl.type].num_stripes;
ctl.max_stripes = 0;
ctl.min_stripes = btrfs_raid_profile_table[ctl.type].min_stripes;
ctl.sub_stripes = btrfs_raid_profile_table[ctl.type].sub_stripes;
@ -1136,9 +1136,6 @@ int btrfs_alloc_chunk(struct btrfs_trans_handle *trans,
if (ctl.num_stripes < ctl.min_stripes)
return -ENOSPC;
}
if (ctl.type == BTRFS_RAID_DUP) {
ctl.num_stripes = 2;
}
if (ctl.type == BTRFS_RAID_RAID0) {
ctl.num_stripes = min(ctl.max_stripes, ctl.total_devs);
ctl.min_stripes = btrfs_raid_profile_table[ctl.type].min_stripes;