For raid10 it needs to choose new data offset and old offset in reshape. So it's better to calculate discard start address and size in specific raid type. Signed-off-by: Xiao Ni <xni@xxxxxxxxxx> --- drivers/md/md.c | 9 +++------ drivers/md/md.h | 3 +-- drivers/md/raid0.c | 5 +++-- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/drivers/md/md.c b/drivers/md/md.c index 10743be..e360d46 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -8585,15 +8585,12 @@ EXPORT_SYMBOL(md_write_end); /* This is used by raid0 and raid10 */ void md_submit_discard_bio(struct mddev *mddev, struct md_rdev *rdev, - struct bio *bio, - sector_t dev_start, sector_t dev_end) + struct bio *bio, sector_t start, sector_t size) { struct bio *discard_bio = NULL; - if (__blkdev_issue_discard(rdev->bdev, - dev_start + rdev->data_offset, - dev_end - dev_start, GFP_NOIO, 0, &discard_bio) || - !discard_bio) + if (__blkdev_issue_discard(rdev->bdev, start, size, + GFP_NOIO, 0, &discard_bio) || !discard_bio) return; bio_chain(discard_bio, bio); diff --git a/drivers/md/md.h b/drivers/md/md.h index bae3bd5..da9997a 100644 --- a/drivers/md/md.h +++ b/drivers/md/md.h @@ -714,8 +714,7 @@ extern void md_done_sync(struct mddev *mddev, int blocks, int ok); extern void md_error(struct mddev *mddev, struct md_rdev *rdev); extern void md_finish_reshape(struct mddev *mddev); extern void md_submit_discard_bio(struct mddev *mddev, struct md_rdev *rdev, - struct bio *bio, - sector_t dev_start, sector_t dev_end); + struct bio *bio, sector_t start, sector_t size); extern bool __must_check md_flush_request(struct mddev *mddev, struct bio *bio); extern void md_super_write(struct mddev *mddev, struct md_rdev *rdev, diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c index 2868294..d3da17b 100644 --- a/drivers/md/raid0.c +++ b/drivers/md/raid0.c @@ -532,8 +532,9 @@ static void raid0_handle_discard(struct mddev *mddev, struct bio *bio) rdev = conf->devlist[(zone - conf->strip_zone) * conf->strip_zone[0].nb_dev + disk]; - dev_start += zone->dev_start; - md_submit_discard_bio(mddev, rdev, bio, dev_start, dev_end); + md_submit_discard_bio(mddev, rdev, bio, + dev_start + zone->dev_start + rdev->data_offset, + dev_end - dev_start); } bio_endio(bio); } -- 2.7.5