aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2006-05-01 15:15:47 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-05-01 21:17:42 -0400
commit5e7dd2ab6b9bdfa60e19b8739e6b2a204fd4f477 (patch)
treef9d3ac455ea67f1ea23e7e41848ac422506c474b
parent62de608da0b0ab17d81a233b50d1e952b9816f69 (diff)
[PATCH] md: Fix 'rdev->nr_pending' count when retrying barrier requests
When retrying a failed BIO_RW_BARRIER request, we need to keep the reference in ->nr_pending over the whole retry. Currently, we only hold the reference if the failed request is the *last* one to finish - which is silly, because it would normally be the first to finish. So move the rdev_dec_pending call up into the didn't-fail branch. As the rdev isn't used in the later code, calling rdev_dec_pending earlier doesn't hurt. Signed-off-by: Neil Brown <neilb@suse.de> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r--drivers/md/raid1.c9
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);