diff options
author | NeilBrown <neilb@suse.de> | 2005-11-09 00:39:22 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-11-09 10:56:36 -0500 |
commit | 4e5314b56a7ea11c7a5f2b8418992b2f49648a25 (patch) | |
tree | 58b0c604f4f4e55523d2c93971f79d80e406b9ce /drivers | |
parent | 703ebe86a999861e833be4015aaf552837e9613a (diff) |
[PATCH] md: better handling of readerrors with raid5.
This patch changes the behaviour of raid5 when it gets a read error.
Instead of just failing the device, it tried to find out what should have
been there, and writes it over the bad block. For some media-errors, this
has a reasonable chance of fixing the error. If the write succeeds, and a
subsequent read succeeds as well, raid5 decided the address is OK and
conitnues.
Instead of failing a drive on read-error, we attempt to re-write the block,
and then re-read. If that all works, we allow the device to remain in the
array.
Signed-off-by: Neil Brown <neilb@suse.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/md/raid5.c | 61 |
1 files changed, 56 insertions, 5 deletions
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index 1223e98ecd70..8cf1ae8b8a71 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c | |||
@@ -349,7 +349,7 @@ static void shrink_stripes(raid5_conf_t *conf) | |||
349 | conf->slab_cache = NULL; | 349 | conf->slab_cache = NULL; |
350 | } | 350 | } |
351 | 351 | ||
352 | static int raid5_end_read_request (struct bio * bi, unsigned int bytes_done, | 352 | static int raid5_end_read_request(struct bio * bi, unsigned int bytes_done, |
353 | int error) | 353 | int error) |
354 | { | 354 | { |
355 | struct stripe_head *sh = bi->bi_private; | 355 | struct stripe_head *sh = bi->bi_private; |
@@ -401,10 +401,27 @@ static int raid5_end_read_request (struct bio * bi, unsigned int bytes_done, | |||
401 | } | 401 | } |
402 | #else | 402 | #else |
403 | set_bit(R5_UPTODATE, &sh->dev[i].flags); | 403 | set_bit(R5_UPTODATE, &sh->dev[i].flags); |
404 | #endif | 404 | #endif |
405 | if (test_bit(R5_ReadError, &sh->dev[i].flags)) { | ||
406 | printk("R5: read error corrected!!\n"); | ||
407 | clear_bit(R5_ReadError, &sh->dev[i].flags); | ||
408 | clear_bit(R5_ReWrite, &sh->dev[i].flags); | ||
409 | } | ||
405 | } else { | 410 | } else { |
406 | md_error(conf->mddev, conf->disks[i].rdev); | ||
407 | clear_bit(R5_UPTODATE, &sh->dev[i].flags); | 411 | clear_bit(R5_UPTODATE, &sh->dev[i].flags); |
412 | if (conf->mddev->degraded) { | ||
413 | printk("R5: read error not correctable.\n"); | ||
414 | clear_bit(R5_ReadError, &sh->dev[i].flags); | ||
415 | clear_bit(R5_ReWrite, &sh->dev[i].flags); | ||
416 | md_error(conf->mddev, conf->disks[i].rdev); | ||
417 | } else if (test_bit(R5_ReWrite, &sh->dev[i].flags)) { | ||
418 | /* Oh, no!!! */ | ||
419 | printk("R5: read error NOT corrected!!\n"); | ||
420 | clear_bit(R5_ReadError, &sh->dev[i].flags); | ||
421 | clear_bit(R5_ReWrite, &sh->dev[i].flags); | ||
422 | md_error(conf->mddev, conf->disks[i].rdev); | ||
423 | } else | ||
424 | set_bit(R5_ReadError, &sh->dev[i].flags); | ||
408 | } | 425 | } |
409 | rdev_dec_pending(conf->disks[i].rdev, conf->mddev); | 426 | rdev_dec_pending(conf->disks[i].rdev, conf->mddev); |
410 | #if 0 | 427 | #if 0 |
@@ -966,6 +983,12 @@ static void handle_stripe(struct stripe_head *sh) | |||
966 | if (dev->written) written++; | 983 | if (dev->written) written++; |
967 | rdev = conf->disks[i].rdev; /* FIXME, should I be looking rdev */ | 984 | rdev = conf->disks[i].rdev; /* FIXME, should I be looking rdev */ |
968 | if (!rdev || !rdev->in_sync) { | 985 | if (!rdev || !rdev->in_sync) { |
986 | /* The ReadError flag wil just be confusing now */ | ||
987 | clear_bit(R5_ReadError, &dev->flags); | ||
988 | clear_bit(R5_ReWrite, &dev->flags); | ||
989 | } | ||
990 | if (!rdev || !rdev->in_sync | ||
991 | || test_bit(R5_ReadError, &dev->flags)) { | ||
969 | failed++; | 992 | failed++; |
970 | failed_num = i; | 993 | failed_num = i; |
971 | } else | 994 | } else |
@@ -980,6 +1003,14 @@ static void handle_stripe(struct stripe_head *sh) | |||
980 | if (failed > 1 && to_read+to_write+written) { | 1003 | if (failed > 1 && to_read+to_write+written) { |
981 | for (i=disks; i--; ) { | 1004 | for (i=disks; i--; ) { |
982 | int bitmap_end = 0; | 1005 | int bitmap_end = 0; |
1006 | |||
1007 | if (test_bit(R5_ReadError, &sh->dev[i].flags)) { | ||
1008 | mdk_rdev_t *rdev = conf->disks[i].rdev; | ||
1009 | if (rdev && rdev->in_sync) | ||
1010 | /* multiple read failures in one stripe */ | ||
1011 | md_error(conf->mddev, rdev); | ||
1012 | } | ||
1013 | |||
983 | spin_lock_irq(&conf->device_lock); | 1014 | spin_lock_irq(&conf->device_lock); |
984 | /* fail all writes first */ | 1015 | /* fail all writes first */ |
985 | bi = sh->dev[i].towrite; | 1016 | bi = sh->dev[i].towrite; |
@@ -1015,7 +1046,8 @@ static void handle_stripe(struct stripe_head *sh) | |||
1015 | } | 1046 | } |
1016 | 1047 | ||
1017 | /* fail any reads if this device is non-operational */ | 1048 | /* fail any reads if this device is non-operational */ |
1018 | if (!test_bit(R5_Insync, &sh->dev[i].flags)) { | 1049 | if (!test_bit(R5_Insync, &sh->dev[i].flags) || |
1050 | test_bit(R5_ReadError, &sh->dev[i].flags)) { | ||
1019 | bi = sh->dev[i].toread; | 1051 | bi = sh->dev[i].toread; |
1020 | sh->dev[i].toread = NULL; | 1052 | sh->dev[i].toread = NULL; |
1021 | if (test_and_clear_bit(R5_Overlap, &sh->dev[i].flags)) | 1053 | if (test_and_clear_bit(R5_Overlap, &sh->dev[i].flags)) |
@@ -1274,7 +1306,26 @@ static void handle_stripe(struct stripe_head *sh) | |||
1274 | md_done_sync(conf->mddev, STRIPE_SECTORS,1); | 1306 | md_done_sync(conf->mddev, STRIPE_SECTORS,1); |
1275 | clear_bit(STRIPE_SYNCING, &sh->state); | 1307 | clear_bit(STRIPE_SYNCING, &sh->state); |
1276 | } | 1308 | } |
1277 | 1309 | ||
1310 | /* If the failed drive is just a ReadError, then we might need to progress | ||
1311 | * the repair/check process | ||
1312 | */ | ||
1313 | if (failed == 1 && test_bit(R5_ReadError, &sh->dev[failed_num].flags) | ||
1314 | && !test_bit(R5_LOCKED, &sh->dev[failed_num].flags) | ||
1315 | && test_bit(R5_UPTODATE, &sh->dev[failed_num].flags) | ||
1316 | ) { | ||
1317 | dev = &sh->dev[failed_num]; | ||
1318 | if (!test_bit(R5_ReWrite, &dev->flags)) { | ||
1319 | set_bit(R5_Wantwrite, &dev->flags); | ||
1320 | set_bit(R5_ReWrite, &dev->flags); | ||
1321 | set_bit(R5_LOCKED, &dev->flags); | ||
1322 | } else { | ||
1323 | /* let's read it back */ | ||
1324 | set_bit(R5_Wantread, &dev->flags); | ||
1325 | set_bit(R5_LOCKED, &dev->flags); | ||
1326 | } | ||
1327 | } | ||
1328 | |||
1278 | spin_unlock(&sh->lock); | 1329 | spin_unlock(&sh->lock); |
1279 | 1330 | ||
1280 | while ((bi=return_bi)) { | 1331 | while ((bi=return_bi)) { |