Commit 051449d1 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] md: Fix up handling for read error in raid1.

From: NeilBrown <neilb@cse.unsw.edu.au>

There is severe bit-rot in this code, which is to say that it doesn't work
at all: an io error during read will do bad things.  It should work better
with this patch.
Signed-off-by: default avatarNeil Brown <neilb@cse.unsw.edu.au>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 2257be73
...@@ -206,7 +206,7 @@ static int map(mddev_t *mddev, mdk_rdev_t **rdevp) ...@@ -206,7 +206,7 @@ static int map(mddev_t *mddev, mdk_rdev_t **rdevp)
*rdevp = rdev; *rdevp = rdev;
atomic_inc(&rdev->nr_pending); atomic_inc(&rdev->nr_pending);
spin_unlock_irq(&conf->device_lock); spin_unlock_irq(&conf->device_lock);
return 0; return i;
} }
} }
spin_unlock_irq(&conf->device_lock); spin_unlock_irq(&conf->device_lock);
...@@ -919,18 +919,22 @@ static void raid1d(mddev_t *mddev) ...@@ -919,18 +919,22 @@ static void raid1d(mddev_t *mddev)
mddev = r1_bio->mddev; mddev = r1_bio->mddev;
conf = mddev_to_conf(mddev); conf = mddev_to_conf(mddev);
bio = r1_bio->master_bio;
if (test_bit(R1BIO_IsSync, &r1_bio->state)) { if (test_bit(R1BIO_IsSync, &r1_bio->state)) {
sync_request_write(mddev, r1_bio); sync_request_write(mddev, r1_bio);
unplug = 1; unplug = 1;
} else { } else {
if (map(mddev, &rdev) == -1) { int disk;
bio = r1_bio->bios[r1_bio->read_disk];
if ((disk=map(mddev, &rdev)) == -1) {
printk(KERN_ALERT "raid1: %s: unrecoverable I/O" printk(KERN_ALERT "raid1: %s: unrecoverable I/O"
" read error for block %llu\n", " read error for block %llu\n",
bdevname(bio->bi_bdev,b), bdevname(bio->bi_bdev,b),
(unsigned long long)r1_bio->sector); (unsigned long long)r1_bio->sector);
raid_end_bio_io(r1_bio); raid_end_bio_io(r1_bio);
} else { } else {
r1_bio->bios[r1_bio->read_disk] = NULL;
r1_bio->read_disk = disk;
r1_bio->bios[r1_bio->read_disk] = bio;
printk(KERN_ERR "raid1: %s: redirecting sector %llu to" printk(KERN_ERR "raid1: %s: redirecting sector %llu to"
" another mirror\n", " another mirror\n",
bdevname(rdev->bdev,b), bdevname(rdev->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