Commit 5e7dd2ab authored by NeilBrown's avatar NeilBrown Committed by Linus Torvalds

[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: default avatarNeil Brown <neilb@suse.de>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 62de608d
...@@ -319,6 +319,7 @@ static int raid1_end_write_request(struct bio *bio, unsigned int bytes_done, int ...@@ -319,6 +319,7 @@ static int raid1_end_write_request(struct bio *bio, unsigned int bytes_done, int
set_bit(BarriersNotsupp, &conf->mirrors[mirror].rdev->flags); set_bit(BarriersNotsupp, &conf->mirrors[mirror].rdev->flags);
set_bit(R1BIO_BarrierRetry, &r1_bio->state); set_bit(R1BIO_BarrierRetry, &r1_bio->state);
r1_bio->mddev->barriers_work = 0; r1_bio->mddev->barriers_work = 0;
/* Don't rdev_dec_pending in this branch - keep it for the retry */
} else { } else {
/* /*
* this branch is our 'one mirror IO has finished' event handler: * 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,6 +366,7 @@ static int raid1_end_write_request(struct bio *bio, unsigned int bytes_done, int
} }
} }
} }
rdev_dec_pending(conf->mirrors[mirror].rdev, conf->mddev);
} }
/* /*
* *
...@@ -374,11 +376,9 @@ static int raid1_end_write_request(struct bio *bio, unsigned int bytes_done, int ...@@ -374,11 +376,9 @@ static int raid1_end_write_request(struct bio *bio, unsigned int bytes_done, int
if (atomic_dec_and_test(&r1_bio->remaining)) { if (atomic_dec_and_test(&r1_bio->remaining)) {
if (test_bit(R1BIO_BarrierRetry, &r1_bio->state)) { if (test_bit(R1BIO_BarrierRetry, &r1_bio->state)) {
reschedule_retry(r1_bio); reschedule_retry(r1_bio);
/* Don't dec_pending yet, we want to hold
* the reference over the retry
*/
goto out; goto out;
} }
/* it really is the end of this request */
if (test_bit(R1BIO_BehindIO, &r1_bio->state)) { if (test_bit(R1BIO_BehindIO, &r1_bio->state)) {
/* free extra copy of the data pages */ /* free extra copy of the data pages */
int i = bio->bi_vcnt; int i = bio->bi_vcnt;
...@@ -393,8 +393,6 @@ static int raid1_end_write_request(struct bio *bio, unsigned int bytes_done, int ...@@ -393,8 +393,6 @@ static int raid1_end_write_request(struct bio *bio, unsigned int bytes_done, int
md_write_end(r1_bio->mddev); md_write_end(r1_bio->mddev);
raid_end_bio_io(r1_bio); raid_end_bio_io(r1_bio);
} }
rdev_dec_pending(conf->mirrors[mirror].rdev, conf->mddev);
out: out:
if (to_put) if (to_put)
bio_put(to_put); bio_put(to_put);
...@@ -1414,6 +1412,7 @@ static void raid1d(mddev_t *mddev) ...@@ -1414,6 +1412,7 @@ static void raid1d(mddev_t *mddev)
* Better resubmit without the barrier. * Better resubmit without the barrier.
* We know which devices to resubmit for, because * We know which devices to resubmit for, because
* all others have had their bios[] entry cleared. * all others have had their bios[] entry cleared.
* We already have a nr_pending reference on these rdevs.
*/ */
int i; int i;
clear_bit(R1BIO_BarrierRetry, &r1_bio->state); clear_bit(R1BIO_BarrierRetry, &r1_bio->state);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment