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

Commit 8250dabe authored by Andreas Philipp's avatar Andreas Philipp Committed by Josef Bacik
Browse files

Correct allowed raid levels on balance.



Raid5 with 3 devices is well defined while the old logic allowed
raid5 only with a minimum of 4 devices when converting the block group
profile via btrfs balance. Creating a raid5 with just three devices
using mkfs.btrfs worked always as expected. This is now fixed and the
whole logic is rewritten.

Signed-off-by: default avatarAndreas Philipp <philipp.andreas@gmail.com>
Signed-off-by: default avatarJosef Bacik <jbacik@fusionio.com>
parent 379cde74
Loading
Loading
Loading
Loading
+6 −7
Original line number Original line Diff line number Diff line
@@ -3120,14 +3120,13 @@ int btrfs_balance(struct btrfs_balance_control *bctl,
	allowed = BTRFS_AVAIL_ALLOC_BIT_SINGLE;
	allowed = BTRFS_AVAIL_ALLOC_BIT_SINGLE;
	if (num_devices == 1)
	if (num_devices == 1)
		allowed |= BTRFS_BLOCK_GROUP_DUP;
		allowed |= BTRFS_BLOCK_GROUP_DUP;
	else if (num_devices < 4)
	else if (num_devices > 1)
		allowed |= (BTRFS_BLOCK_GROUP_RAID0 | BTRFS_BLOCK_GROUP_RAID1);
		allowed |= (BTRFS_BLOCK_GROUP_RAID0 | BTRFS_BLOCK_GROUP_RAID1);
	else
	if (num_devices > 2)
		allowed |= (BTRFS_BLOCK_GROUP_RAID0 | BTRFS_BLOCK_GROUP_RAID1 |
		allowed |= BTRFS_BLOCK_GROUP_RAID5;
				BTRFS_BLOCK_GROUP_RAID10 |
	if (num_devices > 3)
				BTRFS_BLOCK_GROUP_RAID5 |
		allowed |= (BTRFS_BLOCK_GROUP_RAID10 |
			    BTRFS_BLOCK_GROUP_RAID6);
			    BTRFS_BLOCK_GROUP_RAID6);

	if ((bctl->data.flags & BTRFS_BALANCE_ARGS_CONVERT) &&
	if ((bctl->data.flags & BTRFS_BALANCE_ARGS_CONVERT) &&
	    (!alloc_profile_is_valid(bctl->data.target, 1) ||
	    (!alloc_profile_is_valid(bctl->data.target, 1) ||
	     (bctl->data.target & ~allowed))) {
	     (bctl->data.target & ~allowed))) {