diff options
author | NeilBrown <neilb@suse.de> | 2005-11-09 00:39:31 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-11-09 10:56:38 -0500 |
commit | ba22dcbf106338a5c46d6979f9b19564faae3d49 (patch) | |
tree | 4caae4532cda0412d2446eca8b036d4e0df447f8 /drivers | |
parent | 007583c9253fed363a0bd71b039e9b40a0f6855e (diff) |
[PATCH] md: improvements to raid5 handling of read errors
Two refinements to the 'attempt-overwrite-on-read-error' mechanism.
1/ If the array is read-only, don't attempt an over-write.
2/ If there are more than max_nr_stripes read errors on a device with
no success, fail the drive. This will make sure a dead
drive will be eventually kicked even when we aren't trying
to rewrite (which would normally kick a dead drive more quickly.
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/md.c | 1 | ||||
-rw-r--r-- | drivers/md/raid5.c | 25 |
2 files changed, 18 insertions, 8 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c index 3db5c3513072..3fb80397f8aa 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c | |||
@@ -1582,6 +1582,7 @@ static mdk_rdev_t *md_import_device(dev_t newdev, int super_format, int super_mi | |||
1582 | rdev->in_sync = 0; | 1582 | rdev->in_sync = 0; |
1583 | rdev->data_offset = 0; | 1583 | rdev->data_offset = 0; |
1584 | atomic_set(&rdev->nr_pending, 0); | 1584 | atomic_set(&rdev->nr_pending, 0); |
1585 | atomic_set(&rdev->read_errors, 0); | ||
1585 | 1586 | ||
1586 | size = rdev->bdev->bd_inode->i_size >> BLOCK_SIZE_BITS; | 1587 | size = rdev->bdev->bd_inode->i_size >> BLOCK_SIZE_BITS; |
1587 | if (!size) { | 1588 | if (!size) { |
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index 08a1620b9f8c..77610b98d4e0 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c | |||
@@ -420,21 +420,29 @@ static int raid5_end_read_request(struct bio * bi, unsigned int bytes_done, | |||
420 | clear_bit(R5_ReadError, &sh->dev[i].flags); | 420 | clear_bit(R5_ReadError, &sh->dev[i].flags); |
421 | clear_bit(R5_ReWrite, &sh->dev[i].flags); | 421 | clear_bit(R5_ReWrite, &sh->dev[i].flags); |
422 | } | 422 | } |
423 | if (atomic_read(&conf->disks[i].rdev->read_errors)) | ||
424 | atomic_set(&conf->disks[i].rdev->read_errors, 0); | ||
423 | } else { | 425 | } else { |
426 | int retry = 0; | ||
424 | clear_bit(R5_UPTODATE, &sh->dev[i].flags); | 427 | clear_bit(R5_UPTODATE, &sh->dev[i].flags); |
425 | if (conf->mddev->degraded) { | 428 | atomic_inc(&conf->disks[i].rdev->read_errors); |
429 | if (conf->mddev->degraded) | ||
426 | printk("R5: read error not correctable.\n"); | 430 | printk("R5: read error not correctable.\n"); |
427 | clear_bit(R5_ReadError, &sh->dev[i].flags); | 431 | else if (test_bit(R5_ReWrite, &sh->dev[i].flags)) |
428 | clear_bit(R5_ReWrite, &sh->dev[i].flags); | ||
429 | md_error(conf->mddev, conf->disks[i].rdev); | ||
430 | } else if (test_bit(R5_ReWrite, &sh->dev[i].flags)) { | ||
431 | /* Oh, no!!! */ | 432 | /* Oh, no!!! */ |
432 | printk("R5: read error NOT corrected!!\n"); | 433 | printk("R5: read error NOT corrected!!\n"); |
434 | else if (atomic_read(&conf->disks[i].rdev->read_errors) | ||
435 | > conf->max_nr_stripes) | ||
436 | printk("raid5: Too many read errors, failing device.\n"); | ||
437 | else | ||
438 | retry = 1; | ||
439 | if (retry) | ||
440 | set_bit(R5_ReadError, &sh->dev[i].flags); | ||
441 | else { | ||
433 | clear_bit(R5_ReadError, &sh->dev[i].flags); | 442 | clear_bit(R5_ReadError, &sh->dev[i].flags); |
434 | clear_bit(R5_ReWrite, &sh->dev[i].flags); | 443 | clear_bit(R5_ReWrite, &sh->dev[i].flags); |
435 | md_error(conf->mddev, conf->disks[i].rdev); | 444 | md_error(conf->mddev, conf->disks[i].rdev); |
436 | } else | 445 | } |
437 | set_bit(R5_ReadError, &sh->dev[i].flags); | ||
438 | } | 446 | } |
439 | rdev_dec_pending(conf->disks[i].rdev, conf->mddev); | 447 | rdev_dec_pending(conf->disks[i].rdev, conf->mddev); |
440 | #if 0 | 448 | #if 0 |
@@ -1328,7 +1336,8 @@ static void handle_stripe(struct stripe_head *sh) | |||
1328 | /* If the failed drive is just a ReadError, then we might need to progress | 1336 | /* If the failed drive is just a ReadError, then we might need to progress |
1329 | * the repair/check process | 1337 | * the repair/check process |
1330 | */ | 1338 | */ |
1331 | if (failed == 1 && test_bit(R5_ReadError, &sh->dev[failed_num].flags) | 1339 | if (failed == 1 && ! conf->mddev->ro && |
1340 | test_bit(R5_ReadError, &sh->dev[failed_num].flags) | ||
1332 | && !test_bit(R5_LOCKED, &sh->dev[failed_num].flags) | 1341 | && !test_bit(R5_LOCKED, &sh->dev[failed_num].flags) |
1333 | && test_bit(R5_UPTODATE, &sh->dev[failed_num].flags) | 1342 | && test_bit(R5_UPTODATE, &sh->dev[failed_num].flags) |
1334 | ) { | 1343 | ) { |