]> www.infradead.org Git - users/hch/misc.git/commit
badblocks: use sector_t instead of int to avoid truncation of badblocks length
authorZheng Qixing <zhengqixing@huawei.com>
Thu, 27 Feb 2025 07:55:07 +0000 (15:55 +0800)
committerJens Axboe <axboe@kernel.dk>
Thu, 6 Mar 2025 15:04:52 +0000 (08:04 -0700)
commitd301f164c3fbff611bd71f57dfa553b9219f0f5e
tree9995759f85e3fbaea8a01986d4715f06e9b41315
parent7e5102dd99f3ad1f981671ad5b4f24ac48c568ad
badblocks: use sector_t instead of int to avoid truncation of badblocks length

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.

Fixes: 9e0e252a048b ("badblocks: Add core badblock management code")
Signed-off-by: Zheng Qixing <zhengqixing@huawei.com>
Reviewed-by: Yu Kuai <yukuai3@huawei.com>
Acked-by: Coly Li <colyli@kernel.org>
Link: https://lore.kernel.org/r/20250227075507.151331-13-zhengqixing@huaweicloud.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/badblocks.c
drivers/block/null_blk/main.c
drivers/md/md.h
drivers/md/raid1-10.c
drivers/md/raid1.c
drivers/md/raid10.c
drivers/nvdimm/nd.h
drivers/nvdimm/pfn_devs.c
drivers/nvdimm/pmem.c
include/linux/badblocks.h