diff options
author | David Sterba <dsterba@suse.com> | 2018-07-13 20:46:30 +0200 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2018-08-06 13:12:53 +0200 |
commit | 46df06b85e28eaf430aa5c8f8aa26120fa746b72 (patch) | |
tree | 274185638f029f3be8da1ab56d2f84bbd98943e1 /fs/btrfs/super.c | |
parent | 321a4bf72b251319aa456ea542161729442b6f61 (diff) |
btrfs: refactor block group replication factor calculation to a helper
There are many places that open code the duplicity factor of the block
group profiles, create a common helper. This can be easily extended for
more copies.
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/super.c')
-rw-r--r-- | fs/btrfs/super.c | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index d7a54c648c5f..efe8b03ce380 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -2107,14 +2107,9 @@ static int btrfs_statfs(struct dentry *dentry, struct kstatfs *buf) btrfs_account_ro_block_groups_free_space(found); for (i = 0; i < BTRFS_NR_RAID_TYPES; i++) { - if (!list_empty(&found->block_groups[i])) { - switch (i) { - case BTRFS_RAID_DUP: - case BTRFS_RAID_RAID1: - case BTRFS_RAID_RAID10: - factor = 2; - } - } + if (!list_empty(&found->block_groups[i])) + factor = btrfs_bg_type_to_factor( + btrfs_raid_array[i].bg_flag); } } |