Skip to content

Commit fab2735

Browse files
adam900710kdave
authored andcommitted
btrfs: Fix a regression which we can't convert to SINGLE profile
[BUG] With v5.3 kernel, we can't convert to SINGLE profile: # btrfs balance start -f -dconvert=single $mnt ERROR: error during balancing '/mnt/btrfs': Invalid argument # dmesg -t | tail validate_convert_profile: data profile=0x1000000000000 allowed=0x20 is_valid=1 final=0x1000000000000 ret=1 BTRFS error (device dm-3): balance: invalid convert data profile single [CAUSE] With the extra debug output added, it shows that the @Allowed bit is lacking the special in-memory only SINGLE profile bit. Thus we fail at that (profile & ~allowed) check. This regression is caused by commit 081db89 ("btrfs: use raid_attr to get allowed profiles for balance conversion") and the fact that we don't use any bit to indicate SINGLE profile on-disk, but uses special in-memory only bit to help distinguish different profiles. [FIX] Add that BTRFS_AVAIL_ALLOC_BIT_SINGLE to @Allowed, so the code should be the same as it was and fix the regression. Reported-by: Chris Murphy <[email protected]> Fixes: 081db89 ("btrfs: use raid_attr to get allowed profiles for balance conversion") CC: [email protected] # 5.3+ Reviewed-by: Anand Jain <[email protected]> Signed-off-by: Qu Wenruo <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 1fac4a5 commit fab2735

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

fs/btrfs/volumes.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4063,7 +4063,13 @@ int btrfs_balance(struct btrfs_fs_info *fs_info,
40634063
}
40644064

40654065
num_devices = btrfs_num_devices(fs_info);
4066-
allowed = 0;
4066+
4067+
/*
4068+
* SINGLE profile on-disk has no profile bit, but in-memory we have a
4069+
* special bit for it, to make it easier to distinguish. Thus we need
4070+
* to set it manually, or balance would refuse the profile.
4071+
*/
4072+
allowed = BTRFS_AVAIL_ALLOC_BIT_SINGLE;
40674073
for (i = 0; i < ARRAY_SIZE(btrfs_raid_array); i++)
40684074
if (num_devices >= btrfs_raid_array[i].devs_min)
40694075
allowed |= btrfs_raid_array[i].bg_flag;

0 commit comments

Comments
 (0)