md/raid5: fix miscalculation of 'end_sector' in raid5_read_one_chunk()

Message ID 20230524014118.3172781-1-yukuai1@huaweicloud.com
State New
Headers
Series md/raid5: fix miscalculation of 'end_sector' in raid5_read_one_chunk() |

Commit Message

Yu Kuai May 24, 2023, 1:41 a.m. UTC
  From: Yu Kuai <yukuai3@huawei.com>

'end_sector' is compared to 'rdev->recovery_offset', which is offset to
rdev, however, commit e82ed3a4fbb5 ("md/raid6: refactor
raid5_read_one_chunk") changes the calculation of 'end_sector' to offset
to the array. Fix this miscalculation.

Fixes: e82ed3a4fbb5 ("md/raid6: refactor raid5_read_one_chunk")
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
 drivers/md/raid5.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Christoph Hellwig May 24, 2023, 6:04 a.m. UTC | #1
Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>
  
Jens Axboe May 24, 2023, 3:03 p.m. UTC | #2
On 5/23/23 7:41 PM, Yu Kuai wrote:
> From: Yu Kuai <yukuai3@huawei.com>
> 
> 'end_sector' is compared to 'rdev->recovery_offset', which is offset to
> rdev, however, commit e82ed3a4fbb5 ("md/raid6: refactor
> raid5_read_one_chunk") changes the calculation of 'end_sector' to offset
> to the array. Fix this miscalculation.
> 
> Fixes: e82ed3a4fbb5 ("md/raid6: refactor raid5_read_one_chunk")

This needs a stable tag as well, Fixes alone is not enough to guarantee
it ends up in stable.

Song, are you picking this up?
  
Song Liu May 24, 2023, 5:21 p.m. UTC | #3
On Wed, May 24, 2023 at 8:03 AM Jens Axboe <axboe@kernel.dk> wrote:
>
> On 5/23/23 7:41 PM, Yu Kuai wrote:
> > From: Yu Kuai <yukuai3@huawei.com>
> >
> > 'end_sector' is compared to 'rdev->recovery_offset', which is offset to
> > rdev, however, commit e82ed3a4fbb5 ("md/raid6: refactor
> > raid5_read_one_chunk") changes the calculation of 'end_sector' to offset
> > to the array. Fix this miscalculation.
> >
> > Fixes: e82ed3a4fbb5 ("md/raid6: refactor raid5_read_one_chunk")
>
> This needs a stable tag as well, Fixes alone is not enough to guarantee
> it ends up in stable.
>
> Song, are you picking this up?

Yes, I will test it and send it via md-fixes.

Thanks,
Song
  

Patch

diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 7e2bbcfef325..8686d629e3f2 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -5516,7 +5516,7 @@  static int raid5_read_one_chunk(struct mddev *mddev, struct bio *raid_bio)
 
 	sector = raid5_compute_sector(conf, raid_bio->bi_iter.bi_sector, 0,
 				      &dd_idx, NULL);
-	end_sector = bio_end_sector(raid_bio);
+	end_sector = sector + bio_sectors(raid_bio);
 
 	rcu_read_lock();
 	if (r5c_big_stripe_cached(conf, sector))