aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/raid1.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/md/raid1.c')
-rw-r--r--drivers/md/raid1.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index 1961d827dbd1..29e2df5cd77b 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -403,11 +403,14 @@ static void raid1_end_write_request(struct bio *bio)
403 struct bio *to_put = NULL; 403 struct bio *to_put = NULL;
404 int mirror = find_bio_disk(r1_bio, bio); 404 int mirror = find_bio_disk(r1_bio, bio);
405 struct md_rdev *rdev = conf->mirrors[mirror].rdev; 405 struct md_rdev *rdev = conf->mirrors[mirror].rdev;
406 bool discard_error;
407
408 discard_error = bio->bi_error && bio_op(bio) == REQ_OP_DISCARD;
406 409
407 /* 410 /*
408 * 'one mirror IO has finished' event handler: 411 * 'one mirror IO has finished' event handler:
409 */ 412 */
410 if (bio->bi_error) { 413 if (bio->bi_error && !discard_error) {
411 set_bit(WriteErrorSeen, &rdev->flags); 414 set_bit(WriteErrorSeen, &rdev->flags);
412 if (!test_and_set_bit(WantReplacement, &rdev->flags)) 415 if (!test_and_set_bit(WantReplacement, &rdev->flags))
413 set_bit(MD_RECOVERY_NEEDED, & 416 set_bit(MD_RECOVERY_NEEDED, &
@@ -444,7 +447,7 @@ static void raid1_end_write_request(struct bio *bio)
444 447
445 /* Maybe we can clear some bad blocks. */ 448 /* Maybe we can clear some bad blocks. */
446 if (is_badblock(rdev, r1_bio->sector, r1_bio->sectors, 449 if (is_badblock(rdev, r1_bio->sector, r1_bio->sectors,
447 &first_bad, &bad_sectors)) { 450 &first_bad, &bad_sectors) && !discard_error) {
448 r1_bio->bios[mirror] = IO_MADE_GOOD; 451 r1_bio->bios[mirror] = IO_MADE_GOOD;
449 set_bit(R1BIO_MadeGood, &r1_bio->state); 452 set_bit(R1BIO_MadeGood, &r1_bio->state);
450 } 453 }
@@ -2294,17 +2297,23 @@ static void handle_read_error(struct r1conf *conf, struct r1bio *r1_bio)
2294 * This is all done synchronously while the array is 2297 * This is all done synchronously while the array is
2295 * frozen 2298 * frozen
2296 */ 2299 */
2300
2301 bio = r1_bio->bios[r1_bio->read_disk];
2302 bdevname(bio->bi_bdev, b);
2303 bio_put(bio);
2304 r1_bio->bios[r1_bio->read_disk] = NULL;
2305
2297 if (mddev->ro == 0) { 2306 if (mddev->ro == 0) {
2298 freeze_array(conf, 1); 2307 freeze_array(conf, 1);
2299 fix_read_error(conf, r1_bio->read_disk, 2308 fix_read_error(conf, r1_bio->read_disk,
2300 r1_bio->sector, r1_bio->sectors); 2309 r1_bio->sector, r1_bio->sectors);
2301 unfreeze_array(conf); 2310 unfreeze_array(conf);
2302 } else 2311 } else {
2303 md_error(mddev, conf->mirrors[r1_bio->read_disk].rdev); 2312 r1_bio->bios[r1_bio->read_disk] = IO_BLOCKED;
2313 }
2314
2304 rdev_dec_pending(conf->mirrors[r1_bio->read_disk].rdev, conf->mddev); 2315 rdev_dec_pending(conf->mirrors[r1_bio->read_disk].rdev, conf->mddev);
2305 2316
2306 bio = r1_bio->bios[r1_bio->read_disk];
2307 bdevname(bio->bi_bdev, b);
2308read_more: 2317read_more:
2309 disk = read_balance(conf, r1_bio, &max_sectors); 2318 disk = read_balance(conf, r1_bio, &max_sectors);
2310 if (disk == -1) { 2319 if (disk == -1) {
@@ -2315,11 +2324,6 @@ read_more:
2315 } else { 2324 } else {
2316 const unsigned long do_sync 2325 const unsigned long do_sync
2317 = r1_bio->master_bio->bi_opf & REQ_SYNC; 2326 = r1_bio->master_bio->bi_opf & REQ_SYNC;
2318 if (bio) {
2319 r1_bio->bios[r1_bio->read_disk] =
2320 mddev->ro ? IO_BLOCKED : NULL;
2321 bio_put(bio);
2322 }
2323 r1_bio->read_disk = disk; 2327 r1_bio->read_disk = disk;
2324 bio = bio_clone_mddev(r1_bio->master_bio, GFP_NOIO, mddev); 2328 bio = bio_clone_mddev(r1_bio->master_bio, GFP_NOIO, mddev);
2325 bio_trim(bio, r1_bio->sector - bio->bi_iter.bi_sector, 2329 bio_trim(bio, r1_bio->sector - bio->bi_iter.bi_sector,