btrfs: use raid_attr table for btrfs_bg_type_to_factor
authorDavid Sterba <dsterba@suse.com>
Fri, 17 May 2019 09:43:31 +0000 (11:43 +0200)
committerDavid Sterba <dsterba@suse.com>
Mon, 1 Jul 2019 11:34:57 +0000 (13:34 +0200)
The factor is the number of copies.

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

index 71add22e041ade2628bd7c650ccc3fa5706ec347..bbc195c97c740345fa566e5d99f802c908def9e6 100644 (file)
@@ -7586,10 +7586,9 @@ void btrfs_reset_fs_info_ptr(struct btrfs_fs_info *fs_info)
  */
 int btrfs_bg_type_to_factor(u64 flags)
 {
-       if (flags & (BTRFS_BLOCK_GROUP_DUP | BTRFS_BLOCK_GROUP_RAID1 |
-                    BTRFS_BLOCK_GROUP_RAID10))
-               return 2;
-       return 1;
+       const int index = btrfs_bg_flags_to_raid_index(flags);
+
+       return btrfs_raid_array[index].ncopies;
 }