diff options
author | Zygo Blaxell <ce3g8jdj@umail.furryterror.org> | 2019-09-12 19:55:01 -0400 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2019-10-01 13:37:29 -0400 |
commit | 7a54789074a54f64addf5b49bf1994f478337a83 (patch) | |
tree | 05c0597acdef1d01393fdc04482c0037ab02cd96 /fs/btrfs | |
parent | 4203e968947071586a98b5314fd7ffdea3b4f971 (diff) |
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: 818255feece6 ("btrfs: use common helper instead of open coding a bit test")
CC: stable@vger.kernel.org # 4.20+
Signed-off-by: Zygo Blaxell <ce3g8jdj@umail.furryterror.org>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs')
-rw-r--r-- | fs/btrfs/volumes.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index cdd7af424033..bdfe4493e43a 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c | |||
@@ -3845,7 +3845,11 @@ static int alloc_profile_is_valid(u64 flags, int extended) | |||
3845 | return !extended; /* "0" is valid for usual profiles */ | 3845 | return !extended; /* "0" is valid for usual profiles */ |
3846 | 3846 | ||
3847 | /* true if exactly one bit set */ | 3847 | /* 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; | ||
3849 | } | 3853 | } |
3850 | 3854 | ||
3851 | static inline int balance_need_close(struct btrfs_fs_info *fs_info) | 3855 | static inline int balance_need_close(struct btrfs_fs_info *fs_info) |