Skip to content

Commit 7a54789

Browse files
Zygo Blaxellkdave
authored andcommitted
btrfs: fix balance convert to single on 32-bit host CPUs
Currently, the command: btrfs balance start -dconvert=single,soft . on a Raspberry Pi produces the following kernel message: BTRFS error (device mmcblk0p2): balance: invalid convert data profile single This fails because we use is_power_of_2(unsigned long) to validate the new data profile, the constant for 'single' profile uses bit 48, and there are only 32 bits in a long on ARM. Fix by open-coding the check using u64 variables. Tested by completing the original balance command on several Raspberry Pis. Fixes: 818255f ("btrfs: use common helper instead of open coding a bit test") CC: [email protected] # 4.20+ Signed-off-by: Zygo Blaxell <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 4203e96 commit 7a54789

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

fs/btrfs/volumes.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3845,7 +3845,11 @@ static int alloc_profile_is_valid(u64 flags, int extended)
38453845
return !extended; /* "0" is valid for usual profiles */
38463846

38473847
/* true if exactly one bit set */
3848-
return is_power_of_2(flags);
3848+
/*
3849+
* Don't use is_power_of_2(unsigned long) because it won't work
3850+
* for the single profile (1ULL << 48) on 32-bit CPUs.
3851+
*/
3852+
return flags != 0 && (flags & (flags - 1)) == 0;
38493853
}
38503854

38513855
static inline int balance_need_close(struct btrfs_fs_info *fs_info)

0 commit comments

Comments
 (0)