Skip to content

Commit 2702862

Browse files
Tomasz Majchrzakshligit
authored andcommitted
raid10: record correct address of bad block
For failed write request record block address on a device, not block address in an array. Signed-off-by: Tomasz Majchrzak <[email protected]> Signed-off-by: Shaohua Li <[email protected]>
1 parent 0f6187d commit 2702862

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

drivers/md/raid10.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2465,20 +2465,21 @@ static int narrow_write_error(struct r10bio *r10_bio, int i)
24652465

24662466
while (sect_to_write) {
24672467
struct bio *wbio;
2468+
sector_t wsector;
24682469
if (sectors > sect_to_write)
24692470
sectors = sect_to_write;
24702471
/* Write at 'sector' for 'sectors' */
24712472
wbio = bio_clone_mddev(bio, GFP_NOIO, mddev);
24722473
bio_trim(wbio, sector - bio->bi_iter.bi_sector, sectors);
2473-
wbio->bi_iter.bi_sector = (r10_bio->devs[i].addr+
2474-
choose_data_offset(r10_bio, rdev) +
2475-
(sector - r10_bio->sector));
2474+
wsector = r10_bio->devs[i].addr + (sector - r10_bio->sector);
2475+
wbio->bi_iter.bi_sector = wsector +
2476+
choose_data_offset(r10_bio, rdev);
24762477
wbio->bi_bdev = rdev->bdev;
24772478
bio_set_op_attrs(wbio, REQ_OP_WRITE, 0);
24782479

24792480
if (submit_bio_wait(wbio) < 0)
24802481
/* Failure! */
2481-
ok = rdev_set_badblocks(rdev, sector,
2482+
ok = rdev_set_badblocks(rdev, wsector,
24822483
sectors, 0)
24832484
&& ok;
24842485

0 commit comments

Comments
 (0)