diff options
author | David Sterba <dsterba@suse.com> | 2019-05-17 11:43:27 +0200 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2019-07-01 13:34:56 +0200 |
commit | 081db89b13cb26f9ef1f5b1752f7fcb775191cbe (patch) | |
tree | 219e167b6ea01081d5e2e333c35ef0a1497e4e83 /fs/btrfs/volumes.c | |
parent | fc9a2ac77c05ba060dcfb084a752aa3ee37f9e2a (diff) | |
download | linux-stable-081db89b13cb26f9ef1f5b1752f7fcb775191cbe.tar.gz linux-stable-081db89b13cb26f9ef1f5b1752f7fcb775191cbe.tar.bz2 linux-stable-081db89b13cb26f9ef1f5b1752f7fcb775191cbe.zip |
btrfs: use raid_attr to get allowed profiles for balance conversion
Iterate over the table and gather all allowed profiles for a given
number of devices, instead of open coding.
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/volumes.c')
-rw-r--r-- | fs/btrfs/volumes.c | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 995a15a816f2..301e60b11dd0 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -4047,6 +4047,7 @@ int btrfs_balance(struct btrfs_fs_info *fs_info, u64 num_devices; unsigned seq; bool reducing_integrity; + int i; if (btrfs_fs_closing(fs_info) || atomic_read(&fs_info->balance_pause_req) || @@ -4076,16 +4077,11 @@ int btrfs_balance(struct btrfs_fs_info *fs_info, } num_devices = btrfs_num_devices(fs_info); + allowed = 0; + for (i = 0; i < ARRAY_SIZE(btrfs_raid_array); i++) + if (num_devices >= btrfs_raid_array[i].devs_min) + allowed |= btrfs_raid_array[i].bg_flag; - allowed = BTRFS_AVAIL_ALLOC_BIT_SINGLE | BTRFS_BLOCK_GROUP_DUP; - if (num_devices > 1) - allowed |= (BTRFS_BLOCK_GROUP_RAID0 | BTRFS_BLOCK_GROUP_RAID1); - if (num_devices >= 2) - allowed |= BTRFS_BLOCK_GROUP_RAID5; - if (num_devices >= 3) - allowed |= BTRFS_BLOCK_GROUP_RAID6; - if (num_devices > 3) - allowed |= BTRFS_BLOCK_GROUP_RAID10; if (validate_convert_profile(&bctl->data, allowed)) { int index = btrfs_bg_flags_to_raid_index(bctl->data.target); |