From 572ef3db925d93924494fdd258cac0304c8bb2b1 Mon Sep 17 00:00:00 2001 From: Yu Kuai Date: Wed, 6 Dec 2023 09:52:04 +0800 Subject: [PATCH] md/raid5: fix miscalculation of 'end_sector' in raid5_read_one_chunk() mainline inclusion from mainline-v6.4-rc5 commit 8557dc27126949c702bd3aafe8a7e0b7e4fcb44c category: bugfix bugzilla: 189405, https://gitee.com/openeuler/kernel/issues/I8LZMK Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=8557dc27126949c702bd3aafe8a7e0b7e4fcb44c -------------------------------- '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") Cc: stable@vger.kernel.org # v5.12+ Signed-off-by: Yu Kuai Reviewed-by: Christoph Hellwig Signed-off-by: Song Liu Link: https://lore.kernel.org/r/20230524014118.3172781-1-yukuai1@huaweicloud.com Conflict: Commit 2c897e63a100 ("[Backport] md/raid6: refactor raid5_read_one_chunk") missed the space of the previous line. Signed-off-by: Li Nan --- drivers/md/raid5.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index 5af25898baad..b4d004b623e7 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c @@ -5408,8 +5408,8 @@ 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); + &dd_idx, NULL); + end_sector = sector + bio_sectors(raid_bio); rcu_read_lock(); if (r5c_big_stripe_cached(conf, sector)) -- Gitee