Commit 7ad4d4a6 authored by NeilBrown's avatar NeilBrown

md/raid1: Don't release reference to device while handling read error.

When we get a read error, we arrange for raid1d to handle it.
Currently we release the reference on the device.  This can result
in
   conf->mirrors[read_disk].rdev
being NULL in fix_read_error, if the device happens to get removed
before the read error is handled.

So instead keep the reference until the read error has been fully
handled.
Reported-by: default avatarhank <pyu@redhat.com>
Signed-off-by: default avatarNeilBrown <neilb@suse.de>
parent fd177481
...@@ -333,9 +333,10 @@ static void raid1_end_read_request(struct bio *bio, int error) ...@@ -333,9 +333,10 @@ static void raid1_end_read_request(struct bio *bio, int error)
spin_unlock_irqrestore(&conf->device_lock, flags); spin_unlock_irqrestore(&conf->device_lock, flags);
} }
if (uptodate) if (uptodate) {
raid_end_bio_io(r1_bio); raid_end_bio_io(r1_bio);
else { rdev_dec_pending(conf->mirrors[mirror].rdev, conf->mddev);
} else {
/* /*
* oops, read error: * oops, read error:
*/ */
...@@ -349,9 +350,8 @@ static void raid1_end_read_request(struct bio *bio, int error) ...@@ -349,9 +350,8 @@ static void raid1_end_read_request(struct bio *bio, int error)
(unsigned long long)r1_bio->sector); (unsigned long long)r1_bio->sector);
set_bit(R1BIO_ReadError, &r1_bio->state); set_bit(R1BIO_ReadError, &r1_bio->state);
reschedule_retry(r1_bio); reschedule_retry(r1_bio);
/* don't drop the reference on read_disk yet */
} }
rdev_dec_pending(conf->mirrors[mirror].rdev, conf->mddev);
} }
static void close_write(struct r1bio *r1_bio) static void close_write(struct r1bio *r1_bio)
...@@ -2229,6 +2229,7 @@ static void handle_read_error(struct r1conf *conf, struct r1bio *r1_bio) ...@@ -2229,6 +2229,7 @@ static void handle_read_error(struct r1conf *conf, struct r1bio *r1_bio)
unfreeze_array(conf); unfreeze_array(conf);
} else } else
md_error(mddev, conf->mirrors[r1_bio->read_disk].rdev); md_error(mddev, conf->mirrors[r1_bio->read_disk].rdev);
rdev_dec_pending(conf->mirrors[r1_bio->read_disk].rdev, conf->mddev);
bio = r1_bio->bios[r1_bio->read_disk]; bio = r1_bio->bios[r1_bio->read_disk];
bdevname(bio->bi_bdev, b); bdevname(bio->bi_bdev, b);
......
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