* [PATCH] raid10: record correct address of bad block
@ 2016-08-12 9:03 Tomasz Majchrzak
2016-08-17 16:52 ` Shaohua Li
0 siblings, 1 reply; 2+ messages in thread
From: Tomasz Majchrzak @ 2016-08-12 9:03 UTC (permalink / raw)
To: linux-raid; +Cc: shli, aleksey.obitotskiy, pawel.baldysiak, artur.paszkiewicz
For failed write request record block address on a device, not block
address in an array.
Signed-off-by: Tomasz Majchrzak <tomasz.majchrzak@intel.com>
---
drivers/md/raid10.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index cfa96b5..d18b26d 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -2449,6 +2449,7 @@ static int narrow_write_error(struct r10bio *r10_bio, int i)
int block_sectors;
sector_t sector;
+ sector_t data_offset;
int sectors;
int sect_to_write = r10_bio->sectors;
int ok = 1;
@@ -2462,6 +2463,7 @@ static int narrow_write_error(struct r10bio *r10_bio, int i)
sectors = ((r10_bio->sector + block_sectors)
& ~(sector_t)(block_sectors - 1))
- sector;
+ data_offset = choose_data_offset(r10_bio, rdev);
while (sect_to_write) {
struct bio *wbio;
@@ -2471,13 +2473,12 @@ static int narrow_write_error(struct r10bio *r10_bio, int i)
wbio = bio_clone_mddev(bio, GFP_NOIO, mddev);
bio_trim(wbio, sector - bio->bi_iter.bi_sector, sectors);
wbio->bi_iter.bi_sector = (r10_bio->devs[i].addr+
- choose_data_offset(r10_bio, rdev) +
- (sector - r10_bio->sector));
+ data_offset + (sector - r10_bio->sector));
wbio->bi_bdev = rdev->bdev;
if (submit_bio_wait(WRITE, wbio) < 0)
/* Failure! */
- ok = rdev_set_badblocks(rdev, sector,
- sectors, 0)
+ ok = rdev_set_badblocks(rdev, wbio->bi_iter.bi_sector -
+ data_offset, sectors, 0)
&& ok;
bio_put(wbio);
--
1.8.3.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] raid10: record correct address of bad block
2016-08-12 9:03 [PATCH] raid10: record correct address of bad block Tomasz Majchrzak
@ 2016-08-17 16:52 ` Shaohua Li
0 siblings, 0 replies; 2+ messages in thread
From: Shaohua Li @ 2016-08-17 16:52 UTC (permalink / raw)
To: Tomasz Majchrzak
Cc: linux-raid, aleksey.obitotskiy, pawel.baldysiak,
artur.paszkiewicz
On Fri, Aug 12, 2016 at 11:03:53AM +0200, Tomasz Majchrzak wrote:
> For failed write request record block address on a device, not block
> address in an array.
>
> Signed-off-by: Tomasz Majchrzak <tomasz.majchrzak@intel.com>
> ---
> drivers/md/raid10.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
> index cfa96b5..d18b26d 100644
> --- a/drivers/md/raid10.c
> +++ b/drivers/md/raid10.c
> @@ -2449,6 +2449,7 @@ static int narrow_write_error(struct r10bio *r10_bio, int i)
>
> int block_sectors;
> sector_t sector;
> + sector_t data_offset;
> int sectors;
> int sect_to_write = r10_bio->sectors;
> int ok = 1;
> @@ -2462,6 +2463,7 @@ static int narrow_write_error(struct r10bio *r10_bio, int i)
> sectors = ((r10_bio->sector + block_sectors)
> & ~(sector_t)(block_sectors - 1))
> - sector;
> + data_offset = choose_data_offset(r10_bio, rdev);
>
> while (sect_to_write) {
> struct bio *wbio;
> @@ -2471,13 +2473,12 @@ static int narrow_write_error(struct r10bio *r10_bio, int i)
> wbio = bio_clone_mddev(bio, GFP_NOIO, mddev);
> bio_trim(wbio, sector - bio->bi_iter.bi_sector, sectors);
> wbio->bi_iter.bi_sector = (r10_bio->devs[i].addr+
> - choose_data_offset(r10_bio, rdev) +
> - (sector - r10_bio->sector));
> + data_offset + (sector - r10_bio->sector));
> wbio->bi_bdev = rdev->bdev;
> if (submit_bio_wait(WRITE, wbio) < 0)
> /* Failure! */
> - ok = rdev_set_badblocks(rdev, sector,
> - sectors, 0)
> + ok = rdev_set_badblocks(rdev, wbio->bi_iter.bi_sector -
> + data_offset, sectors, 0)
bi_iter is immutable after submit_bio, so please not use it
Thanks,
Shaohua
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-08-17 16:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-12 9:03 [PATCH] raid10: record correct address of bad block Tomasz Majchrzak
2016-08-17 16:52 ` Shaohua Li
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).