On 14.09.19 г. 7:59 ч., Zygo Blaxell wrote: > On Fri, Sep 13, 2019 at 09:14:08AM -0700, Josef Bacik wrote: >> On Thu, Sep 12, 2019 at 07:55:01PM -0400, Zygo Blaxell wrote: >>> 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. >>> >>> Signed-off-by: Zygo Blaxell <ce3g8jdj@xxxxxxxxxxxxxxxxxxxxx> >> >> Honestly I'd rather we fixed is_power_of_2 to work on 32bit, that way any other >> users don't get bitten by the same problem. Thanks, > > is_power_of_2 doesn't live in the btrfs tree. I considered modifying it, > but worried about side-effects elsewhere (i.e. breaking some other 32-bit > device I've never heard of). > > What do you think about using the IS_ALIGNED macro? THe problem is that is_power_of_2 is defined as a function that takes an unsigned long which is defined as able to hold at least 32 bits. One possible change will be do change it to being a macro. However, as you note, this might lead to subtle breakage elsewhere. Furthermore other functions in log2.h are also defined with unsigned long as their input params. > >> Josef
