diff options
-rw-r--r-- | drivers/md/raid1.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index b8c13c897ccb..4070eff6f0f8 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c | |||
@@ -319,6 +319,7 @@ static int raid1_end_write_request(struct bio *bio, unsigned int bytes_done, int | |||
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); |
@@ -1414,6 +1412,7 @@ static void raid1d(mddev_t *mddev) | |||
1414 | * Better resubmit without the barrier. | 1412 | * Better resubmit without the barrier. |
1415 | * We know which devices to resubmit for, because | 1413 | * We know which devices to resubmit for, because |
1416 | * 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. | ||
1417 | */ | 1416 | */ |
1418 | int i; | 1417 | int i; |
1419 | clear_bit(R1BIO_BarrierRetry, &r1_bio->state); | 1418 | clear_bit(R1BIO_BarrierRetry, &r1_bio->state); |