diff options
author | David Sterba <dsterba@suse.com> | 2016-02-15 10:28:14 -0500 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2016-04-28 04:59:13 -0400 |
commit | 418775a22b4c67bd15915e043c3a8f29816799bd (patch) | |
tree | 74f4ef9fc0ef76b2625a1fbdbc48cf2820a7fb14 | |
parent | 621292bae6ae3b25cd3124b63603d01df4cccfb6 (diff) |
btrfs: use existing device constraints table btrfs_raid_array
We should avoid duplicating the device constraints, let's use the
btrfs_raid_array in btrfs_check_raid_min_devices.
Reviewed-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
-rw-r--r-- | fs/btrfs/volumes.c | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 6b38b72d678b..055fbebea199 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c | |||
@@ -1731,6 +1731,7 @@ static int btrfs_check_raid_min_devices(struct btrfs_fs_info *fs_info, | |||
1731 | { | 1731 | { |
1732 | u64 all_avail; | 1732 | u64 all_avail; |
1733 | unsigned seq; | 1733 | unsigned seq; |
1734 | int i; | ||
1734 | 1735 | ||
1735 | do { | 1736 | do { |
1736 | seq = read_seqbegin(&fs_info->profiles_lock); | 1737 | seq = read_seqbegin(&fs_info->profiles_lock); |
@@ -1740,22 +1741,16 @@ static int btrfs_check_raid_min_devices(struct btrfs_fs_info *fs_info, | |||
1740 | fs_info->avail_metadata_alloc_bits; | 1741 | fs_info->avail_metadata_alloc_bits; |
1741 | } while (read_seqretry(&fs_info->profiles_lock, seq)); | 1742 | } while (read_seqretry(&fs_info->profiles_lock, seq)); |
1742 | 1743 | ||
1743 | if ((all_avail & BTRFS_BLOCK_GROUP_RAID10) && num_devices < 4) { | 1744 | for (i = 0; i < BTRFS_NR_RAID_TYPES; i++) { |
1744 | return BTRFS_ERROR_DEV_RAID10_MIN_NOT_MET; | 1745 | if (!(all_avail & btrfs_raid_group[i])) |
1745 | } | 1746 | continue; |
1746 | |||
1747 | if ((all_avail & BTRFS_BLOCK_GROUP_RAID1) && num_devices < 2) { | ||
1748 | return BTRFS_ERROR_DEV_RAID1_MIN_NOT_MET; | ||
1749 | } | ||
1750 | 1747 | ||
1751 | if ((all_avail & BTRFS_BLOCK_GROUP_RAID5) && | 1748 | if (num_devices < btrfs_raid_array[i].devs_min) { |
1752 | fs_info->fs_devices->rw_devices < 2) { | 1749 | int ret = btrfs_raid_mindev_error[i]; |
1753 | return BTRFS_ERROR_DEV_RAID5_MIN_NOT_MET; | ||
1754 | } | ||
1755 | 1750 | ||
1756 | if ((all_avail & BTRFS_BLOCK_GROUP_RAID6) && | 1751 | if (ret) |
1757 | fs_info->fs_devices->rw_devices < 3) { | 1752 | return ret; |
1758 | return BTRFS_ERROR_DEV_RAID6_MIN_NOT_MET; | 1753 | } |
1759 | } | 1754 | } |
1760 | 1755 | ||
1761 | return 0; | 1756 | return 0; |