Hi Johannes,
On Mon, Sep 18, 2023 at 4:14 PM Johannes Thumshirn
<[email protected]> wrote:
> Fix modpost error due to 64bit division on 32bit systems in
> btrfs_insert_striped_mirrored_raid_extents.
>
> Cc: Geert Uytterhoeven <[email protected]>
> Signed-off-by: Johannes Thumshirn <[email protected]>
Thanks for your patch!
> --- a/fs/btrfs/raid-stripe-tree.c
> +++ b/fs/btrfs/raid-stripe-tree.c
> @@ -148,10 +148,10 @@ static int btrfs_insert_striped_mirrored_raid_extents(
> {
> struct btrfs_io_context *bioc;
> struct btrfs_io_context *rbioc;
> - const int nstripes = list_count_nodes(&ordered->bioc_list);
> - const int index = btrfs_bg_flags_to_raid_index(map_type);
> - const int substripes = btrfs_raid_array[index].sub_stripes;
> - const int max_stripes = trans->fs_info->fs_devices->rw_devices / substripes;
> + const size_t nstripes = list_count_nodes(&ordered->bioc_list);
> + const enum btrfs_raid_types index = btrfs_bg_flags_to_raid_index(map_type);
> + const u8 substripes = btrfs_raid_array[index].sub_stripes;
> + const int max_stripes = div_u64(trans->fs_info->fs_devices->rw_devices, substripes);
What if the quotient does not fit in a signed 32-bit value?
> int left = nstripes;
> int i;
> int ret = 0;
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
On 18.09.23 16:19, Geert Uytterhoeven wrote:
> Hi Johannes,
>
> On Mon, Sep 18, 2023 at 4:14 PM Johannes Thumshirn
> <[email protected]> wrote:
>> Fix modpost error due to 64bit division on 32bit systems in
>> btrfs_insert_striped_mirrored_raid_extents.
>>
>> Cc: Geert Uytterhoeven <[email protected]>
>> Signed-off-by: Johannes Thumshirn <[email protected]>
>
> Thanks for your patch!
>
>> --- a/fs/btrfs/raid-stripe-tree.c
>> +++ b/fs/btrfs/raid-stripe-tree.c
>> @@ -148,10 +148,10 @@ static int btrfs_insert_striped_mirrored_raid_extents(
>> {
>> struct btrfs_io_context *bioc;
>> struct btrfs_io_context *rbioc;
>> - const int nstripes = list_count_nodes(&ordered->bioc_list);
>> - const int index = btrfs_bg_flags_to_raid_index(map_type);
>> - const int substripes = btrfs_raid_array[index].sub_stripes;
>> - const int max_stripes = trans->fs_info->fs_devices->rw_devices / substripes;
>> + const size_t nstripes = list_count_nodes(&ordered->bioc_list);
>> + const enum btrfs_raid_types index = btrfs_bg_flags_to_raid_index(map_type);
>> + const u8 substripes = btrfs_raid_array[index].sub_stripes;
>> + const int max_stripes = div_u64(trans->fs_info->fs_devices->rw_devices, substripes);
>
> What if the quotient does not fit in a signed 32-bit value?
Then you've bought a lot of HDDs ;-)
Jokes aside, yes this is theoretically correct. Dave can you fix
max_stripes up to be u64 when applying?