summaryrefslogtreecommitdiffstats
path: root/drivers/md
diff options
context:
space:
mode:
authorGuoqing Jiang <jgq516@gmail.com>2021-05-25 17:46:18 +0800
committerSong Liu <song@kernel.org>2021-06-14 22:32:06 -0700
commitc82aa1b76787c34fd02374e519b6f52cdeb2f54b (patch)
treebda1865dde7f1be50a5e75c33d0d710fce2d6224 /drivers/md
parent10764815ff4728d2c57da677cd5d3dd6f446cf5f (diff)
downloadlinux-c82aa1b76787c34fd02374e519b6f52cdeb2f54b.tar.bz2
md/raid5: move checking badblock before clone bio in raid5_read_one_chunk
We don't need to clone bio if the relevant region has badblock. Signed-off-by: Guoqing Jiang <jiangguoqing@kylinos.cn> Signed-off-by: Song Liu <song@kernel.org>
Diffstat (limited to 'drivers/md')
-rw-r--r--drivers/md/raid5.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 58e9dbc0f683..5a05277f4be7 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -5427,6 +5427,13 @@ static int raid5_read_one_chunk(struct mddev *mddev, struct bio *raid_bio)
atomic_inc(&rdev->nr_pending);
rcu_read_unlock();
+ if (is_badblock(rdev, sector, bio_sectors(raid_bio), &first_bad,
+ &bad_sectors)) {
+ bio_put(raid_bio);
+ rdev_dec_pending(rdev, mddev);
+ return 0;
+ }
+
align_bio = bio_clone_fast(raid_bio, GFP_NOIO, &mddev->bio_set);
bio_set_dev(align_bio, rdev->bdev);
align_bio->bi_end_io = raid5_align_endio;
@@ -5435,13 +5442,6 @@ static int raid5_read_one_chunk(struct mddev *mddev, struct bio *raid_bio)
raid_bio->bi_next = (void *)rdev;
- if (is_badblock(rdev, sector, bio_sectors(align_bio), &first_bad,
- &bad_sectors)) {
- bio_put(align_bio);
- rdev_dec_pending(rdev, mddev);
- return 0;
- }
-
/* No reshape active, so we can trust rdev->data_offset */
align_bio->bi_iter.bi_sector += rdev->data_offset;