md/raid456: When readed error and raid was degraded,it try to set badsector, not ejecting the rdev.
PATCH 1/2 md/raid456: When readed error and raid was degraded,it try to set badsector, not ejecting the rdev.
In order to prevent the degraded raid from becaming fail,we should first set badsector instead of ejecting the rdev when read fail.
Signed-off-by majianpeng <[email protected]>
--- drivers/md/raid5.c | 10 ++++++++-- 1 files changed, 8 insertions(+), 2 deletions(-)
drivers/md/raid5.c +8 -2
@@ -1737,6 +1737,7 @@ static void raid5_end_read_request(struct bio * bi, int error) }else {const char *bdn =bdevname (rdev->bdev, b);int retry =0 ; +int set_bad =0 ;clear_bit (R5_UPTODATE , &sh->dev[i].flags);atomic_inc (&rdev->read_errors);
@@ -1748,7 +1749,8 @@ static void raid5_end_read_request(struct bio * bi, int error)mdname (conf->mddev), (unsigned long long )s, bdn); - else if (conf->mddev->degraded >= conf->max_degraded) + else if (conf->mddev->degraded >= conf->max_degraded) { + set_bad =1 ;printk_ratelimited (KERN_WARNING "md/raid:%s: read error not correctable "
@@ -1756,6 +1758,7 @@ static void raid5_end_read_request(struct bio * bi, int error)mdname (conf->mddev), (unsigned long long )s, bdn); + }else if (test_bit (R5_ReWrite, &sh->dev[i].flags))/* Oh, no!!! */ printk_ratelimited(
@@ -1777,7 +1780,10 @@ static void raid5_end_read_request(struct bio * bi, int error)else {clear_bit (R5_ReadError, &sh->dev[i].flags);clear_bit (R5_ReWrite, &sh->dev[i].flags); -md_error (conf->mddev, rdev); +if (!(set_bad &&test_bit (In_sync, &rdev->flags) + &&rdev_set_badblocks (rdev, + sh->sector,STRIPE_SECTORS ,0 ))) +md_error (conf->mddev, rdev); } }rdev_dec_pending (rdev, conf->mddev);
Signature · 6 lines
1.7.5.4 -------------- majianpeng 2012-05-26