diff mbox series

[10/15] btrfs-progs: do table lookup for simple RAID profiles' num_stripes

Message ID 20200610123258.12382-11-johannes.thumshirn@wdc.com (mailing list archive)
State New, archived
Headers show
Series btrfs-progs: simplify chunk allocation a bit | expand

Commit Message

Johannes Thumshirn June 10, 2020, 12:32 p.m. UTC
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>
---
 volumes.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/volumes.c b/volumes.c
index 24e6d151c313..80b4b373f012 100644
--- a/volumes.c
+++ b/volumes.c
@@ -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;