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/volumes.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/volumes.c')
-rw-r--r-- | fs/btrfs/volumes.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 0b9023f52b2a..eca67529e536 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -7292,3 +7292,14 @@ void btrfs_reset_fs_info_ptr(struct btrfs_fs_info *fs_info) fs_devices = fs_devices->seed; } } + +/* + * Multiplicity factor for simple profiles: DUP, RAID1-like and RAID10. + */ +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; +} |