Skip to content

Commit 8250dab

Browse files
aspro-atJosef Bacik
authored andcommitted
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: Andreas Philipp <philipp.andreas@gmail.com> Signed-off-by: Josef Bacik <jbacik@fusionio.com>
1 parent 379cde7 commit 8250dab

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

‎fs/btrfs/volumes.c‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3120,14 +3120,13 @@ int btrfs_balance(struct btrfs_balance_control *bctl,
31203120
allowed = BTRFS_AVAIL_ALLOC_BIT_SINGLE;
31213121
if (num_devices == 1)
31223122
allowed |= BTRFS_BLOCK_GROUP_DUP;
3123-
else if (num_devices < 4)
3123+
else if (num_devices > 1)
31243124
allowed |= (BTRFS_BLOCK_GROUP_RAID0 | BTRFS_BLOCK_GROUP_RAID1);
3125-
else
3126-
allowed |= (BTRFS_BLOCK_GROUP_RAID0 | BTRFS_BLOCK_GROUP_RAID1 |
3127-
BTRFS_BLOCK_GROUP_RAID10 |
3128-
BTRFS_BLOCK_GROUP_RAID5 |
3129-
BTRFS_BLOCK_GROUP_RAID6);
3130-
3125+
if (num_devices > 2)
3126+
allowed |= BTRFS_BLOCK_GROUP_RAID5;
3127+
if (num_devices > 3)
3128+
allowed |= (BTRFS_BLOCK_GROUP_RAID10 |
3129+
BTRFS_BLOCK_GROUP_RAID6);
31313130
if ((bctl->data.flags & BTRFS_BALANCE_ARGS_CONVERT) &&
31323131
(!alloc_profile_is_valid(bctl->data.target, 1) ||
31333132
(bctl->data.target & ~allowed))) {

0 commit comments

Comments
 (0)