Re: [PATCH V2 12/12] badblocks: use sector_t instead of int to avoid truncation of badblocks length
From: Ira Weiny
Date: Thu Feb 27 2025 - 10:27:48 EST
Zheng Qixing wrote:
> From: Zheng Qixing <zhengqixing@xxxxxxxxxx>
>
> There is a truncation of badblocks length issue when set badblocks as
> follow:
>
> echo "2055 4294967299" > bad_blocks
> cat bad_blocks
> 2055 3
>
> Change 'sectors' argument type from 'int' to 'sector_t'.
>
> This change avoids truncation of badblocks length for large sectors by
> replacing 'int' with 'sector_t' (u64), enabling proper handling of larger
> disk sizes and ensuring compatibility with 64-bit sector addressing.
__add_badblock_range() in drivers/nvdimm/badrange.c limits the number of
badblocks which can be set in each call to badblocks_set().
After this change can that algorithm be eliminated? I'm not familiar with
the badblocks code to know for certain.
Regardless I think the types used in badrange.c could be updated with this
change.
Also pmem_clear_bb() should have it's type changed to match
badblocks_clear()
Ira
[snip]