[09/15] btrfs: use raid_attr table for btrfs_bg_type_to_factor
diff mbox series

Message ID c67464f4b65eafdfbd31f5013b8954d20ccd9b73.1558085801.git.dsterba@suse.com
State New
Headers show
Series
  • RAID/volumes code cleanups
Related show

Commit Message

David Sterba May 17, 2019, 9:43 a.m. UTC
The factor is the number of copies.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/volumes.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

Patch
diff mbox series

diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 9bcda2d76a33..3d65fdf7884c 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -7581,10 +7581,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;
 }