diff options
Diffstat (limited to 'drivers/md/raid1.c')
-rw-r--r-- | drivers/md/raid1.c | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index 6081941de1b3..4070eff6f0f8 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c | |||
@@ -315,10 +315,11 @@ static int raid1_end_write_request(struct bio *bio, unsigned int bytes_done, int | |||
315 | if (r1_bio->bios[mirror] == bio) | 315 | if (r1_bio->bios[mirror] == bio) |
316 | break; | 316 | break; |
317 | 317 | ||
318 | if (error == -ENOTSUPP && test_bit(R1BIO_Barrier, &r1_bio->state)) { | 318 | if (error == -EOPNOTSUPP && test_bit(R1BIO_Barrier, &r1_bio->state)) { |
319 | set_bit(BarriersNotsupp, &conf->mirrors[mirror].rdev->flags); | 319 | set_bit(BarriersNotsupp, &conf->mirrors[mirror].rdev->flags); |
320 | set_bit(R1BIO_BarrierRetry, &r1_bio->state); | 320 | set_bit(R1BIO_BarrierRetry, &r1_bio->state); |
321 | r1_bio->mddev->barriers_work = 0; | 321 | r1_bio->mddev->barriers_work = 0; |
322 | /* Don't rdev_dec_pending in this branch - keep it for the retry */ | ||
322 | } else { | 323 | } else { |
323 | /* | 324 | /* |
324 | * this branch is our 'one mirror IO has finished' event handler: | 325 | * this branch is our 'one mirror IO has finished' event handler: |
@@ -365,6 +366,7 @@ static int raid1_end_write_request(struct bio *bio, unsigned int bytes_done, int | |||
365 | } | 366 | } |
366 | } | 367 | } |
367 | } | 368 | } |
369 | rdev_dec_pending(conf->mirrors[mirror].rdev, conf->mddev); | ||
368 | } | 370 | } |
369 | /* | 371 | /* |
370 | * | 372 | * |
@@ -374,11 +376,9 @@ static int raid1_end_write_request(struct bio *bio, unsigned int bytes_done, int | |||
374 | if (atomic_dec_and_test(&r1_bio->remaining)) { | 376 | if (atomic_dec_and_test(&r1_bio->remaining)) { |
375 | if (test_bit(R1BIO_BarrierRetry, &r1_bio->state)) { | 377 | if (test_bit(R1BIO_BarrierRetry, &r1_bio->state)) { |
376 | reschedule_retry(r1_bio); | 378 | reschedule_retry(r1_bio); |
377 | /* Don't dec_pending yet, we want to hold | ||
378 | * the reference over the retry | ||
379 | */ | ||
380 | goto out; | 379 | goto out; |
381 | } | 380 | } |
381 | /* it really is the end of this request */ | ||
382 | if (test_bit(R1BIO_BehindIO, &r1_bio->state)) { | 382 | if (test_bit(R1BIO_BehindIO, &r1_bio->state)) { |
383 | /* free extra copy of the data pages */ | 383 | /* free extra copy of the data pages */ |
384 | int i = bio->bi_vcnt; | 384 | int i = bio->bi_vcnt; |
@@ -393,8 +393,6 @@ static int raid1_end_write_request(struct bio *bio, unsigned int bytes_done, int | |||
393 | md_write_end(r1_bio->mddev); | 393 | md_write_end(r1_bio->mddev); |
394 | raid_end_bio_io(r1_bio); | 394 | raid_end_bio_io(r1_bio); |
395 | } | 395 | } |
396 | |||
397 | rdev_dec_pending(conf->mirrors[mirror].rdev, conf->mddev); | ||
398 | out: | 396 | out: |
399 | if (to_put) | 397 | if (to_put) |
400 | bio_put(to_put); | 398 | bio_put(to_put); |
@@ -753,18 +751,24 @@ static int make_request(request_queue_t *q, struct bio * bio) | |||
753 | const int rw = bio_data_dir(bio); | 751 | const int rw = bio_data_dir(bio); |
754 | int do_barriers; | 752 | int do_barriers; |
755 | 753 | ||
756 | if (unlikely(!mddev->barriers_work && bio_barrier(bio))) { | ||
757 | bio_endio(bio, bio->bi_size, -EOPNOTSUPP); | ||
758 | return 0; | ||
759 | } | ||
760 | |||
761 | /* | 754 | /* |
762 | * Register the new request and wait if the reconstruction | 755 | * Register the new request and wait if the reconstruction |
763 | * thread has put up a bar for new requests. | 756 | * thread has put up a bar for new requests. |
764 | * Continue immediately if no resync is active currently. | 757 | * Continue immediately if no resync is active currently. |
758 | * We test barriers_work *after* md_write_start as md_write_start | ||
759 | * may cause the first superblock write, and that will check out | ||
760 | * if barriers work. | ||
765 | */ | 761 | */ |
762 | |||
766 | md_write_start(mddev, bio); /* wait on superblock update early */ | 763 | md_write_start(mddev, bio); /* wait on superblock update early */ |
767 | 764 | ||
765 | if (unlikely(!mddev->barriers_work && bio_barrier(bio))) { | ||
766 | if (rw == WRITE) | ||
767 | md_write_end(mddev); | ||
768 | bio_endio(bio, bio->bi_size, -EOPNOTSUPP); | ||
769 | return 0; | ||
770 | } | ||
771 | |||
768 | wait_barrier(conf); | 772 | wait_barrier(conf); |
769 | 773 | ||
770 | disk_stat_inc(mddev->gendisk, ios[rw]); | 774 | disk_stat_inc(mddev->gendisk, ios[rw]); |
@@ -1404,10 +1408,11 @@ static void raid1d(mddev_t *mddev) | |||
1404 | unplug = 1; | 1408 | unplug = 1; |
1405 | } else if (test_bit(R1BIO_BarrierRetry, &r1_bio->state)) { | 1409 | } else if (test_bit(R1BIO_BarrierRetry, &r1_bio->state)) { |
1406 | /* some requests in the r1bio were BIO_RW_BARRIER | 1410 | /* some requests in the r1bio were BIO_RW_BARRIER |
1407 | * requests which failed with -ENOTSUPP. Hohumm.. | 1411 | * requests which failed with -EOPNOTSUPP. Hohumm.. |
1408 | * Better resubmit without the barrier. | 1412 | * Better resubmit without the barrier. |
1409 | * We know which devices to resubmit for, because | 1413 | * We know which devices to resubmit for, because |
1410 | * all others have had their bios[] entry cleared. | 1414 | * all others have had their bios[] entry cleared. |
1415 | * We already have a nr_pending reference on these rdevs. | ||
1411 | */ | 1416 | */ |
1412 | int i; | 1417 | int i; |
1413 | clear_bit(R1BIO_BarrierRetry, &r1_bio->state); | 1418 | clear_bit(R1BIO_BarrierRetry, &r1_bio->state); |