Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 418775a2 authored by David Sterba's avatar David Sterba
Browse files

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: default avatarAnand Jain <anand.jain@oracle.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 621292ba
Loading
Loading
Loading
Loading
+9 −14
Original line number Original line Diff line number Diff line
@@ -1731,6 +1731,7 @@ static int btrfs_check_raid_min_devices(struct btrfs_fs_info *fs_info,
{
{
	u64 all_avail;
	u64 all_avail;
	unsigned seq;
	unsigned seq;
	int i;


	do {
	do {
		seq = read_seqbegin(&fs_info->profiles_lock);
		seq = read_seqbegin(&fs_info->profiles_lock);
@@ -1740,22 +1741,16 @@ static int btrfs_check_raid_min_devices(struct btrfs_fs_info *fs_info,
			    fs_info->avail_metadata_alloc_bits;
			    fs_info->avail_metadata_alloc_bits;
	} while (read_seqretry(&fs_info->profiles_lock, seq));
	} while (read_seqretry(&fs_info->profiles_lock, seq));


	if ((all_avail & BTRFS_BLOCK_GROUP_RAID10) && num_devices < 4) {
	for (i = 0; i < BTRFS_NR_RAID_TYPES; i++) {
		return BTRFS_ERROR_DEV_RAID10_MIN_NOT_MET;
		if (!(all_avail & btrfs_raid_group[i]))
	}
			continue;


	if ((all_avail & BTRFS_BLOCK_GROUP_RAID1) && num_devices < 2) {
		if (num_devices < btrfs_raid_array[i].devs_min) {
		return BTRFS_ERROR_DEV_RAID1_MIN_NOT_MET;
			int ret = btrfs_raid_mindev_error[i];
	}


	if ((all_avail & BTRFS_BLOCK_GROUP_RAID5) &&
			if (ret)
	    fs_info->fs_devices->rw_devices < 2) {
				return ret;
		return BTRFS_ERROR_DEV_RAID5_MIN_NOT_MET;
		}
		}

	if ((all_avail & BTRFS_BLOCK_GROUP_RAID6) &&
	    fs_info->fs_devices->rw_devices < 3) {
		return BTRFS_ERROR_DEV_RAID6_MIN_NOT_MET;
	}
	}


	return 0;
	return 0;