btrfs: use raid_attr table in get_profile_num_devs
authorDavid Sterba <dsterba@suse.com>
Fri, 17 May 2019 09:43:20 +0000 (11:43 +0200)
committerDavid Sterba <dsterba@suse.com>
Mon, 1 Jul 2019 11:34:56 +0000 (13:34 +0200)
The dev_max constraints are defined in the raid_attr table, use it
instead of open-coding it.

Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/extent-tree.c

index cbe6a72780081fcaad5c1ba77e66fea53c9db9dc..326fd8660efbc216e9881f7bd3fb2a0de42707eb 100644 (file)
@@ -4336,15 +4336,9 @@ static u64 get_profile_num_devs(struct btrfs_fs_info *fs_info, u64 type)
 {
        u64 num_dev;
 
-       if (type & (BTRFS_BLOCK_GROUP_RAID10 |
-                   BTRFS_BLOCK_GROUP_RAID0 |
-                   BTRFS_BLOCK_GROUP_RAID5 |
-                   BTRFS_BLOCK_GROUP_RAID6))
+       num_dev = btrfs_raid_array[btrfs_bg_flags_to_raid_index(type)].devs_max;
+       if (!num_dev)
                num_dev = fs_info->fs_devices->rw_devices;
-       else if (type & BTRFS_BLOCK_GROUP_RAID1)
-               num_dev = 2;
-       else
-               num_dev = 1;    /* DUP or single */
 
        return num_dev;
 }