diff options
| author | Zheng Qixing <[email protected]> | 2025-02-27 07:55:07 +0000 |
|---|---|---|
| committer | Jens Axboe <[email protected]> | 2025-03-06 15:04:52 +0000 |
| commit | d301f164c3fbff611bd71f57dfa553b9219f0f5e (patch) | |
| tree | 9995759f85e3fbaea8a01986d4715f06e9b41315 /drivers/md/raid1.c | |
| parent | md: improve return types of badblocks handling functions (diff) | |
| download | kernel-d301f164c3fbff611bd71f57dfa553b9219f0f5e.tar.gz kernel-d301f164c3fbff611bd71f57dfa553b9219f0f5e.zip | |
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 <[email protected]>
Reviewed-by: Yu Kuai <[email protected]>
Acked-by: Coly Li <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jens Axboe <[email protected]>
Diffstat (limited to 'drivers/md/raid1.c')
| -rw-r--r-- | drivers/md/raid1.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index 8beb8cccc6af..0b2839105857 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c @@ -1537,7 +1537,7 @@ static void raid1_write_request(struct mddev *mddev, struct bio *bio, atomic_inc(&rdev->nr_pending); if (test_bit(WriteErrorSeen, &rdev->flags)) { sector_t first_bad; - int bad_sectors; + sector_t bad_sectors; int is_bad; is_bad = is_badblock(rdev, r1_bio->sector, max_sectors, @@ -2886,7 +2886,7 @@ static sector_t raid1_sync_request(struct mddev *mddev, sector_t sector_nr, } else { /* may need to read from here */ sector_t first_bad = MaxSector; - int bad_sectors; + sector_t bad_sectors; if (is_badblock(rdev, sector_nr, good_sectors, &first_bad, &bad_sectors)) { |
