diff options
| -rw-r--r-- | drivers/md/raid5.c | 61 | ||||
| -rw-r--r-- | include/linux/raid/raid5.h | 2 |
2 files changed, 58 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)) { |
diff --git a/include/linux/raid/raid5.h b/include/linux/raid/raid5.h index 176fc653c284..f025ba6fb14c 100644 --- a/include/linux/raid/raid5.h +++ b/include/linux/raid/raid5.h | |||
| @@ -154,6 +154,8 @@ struct stripe_head { | |||
| 154 | #define R5_Wantwrite 5 | 154 | #define R5_Wantwrite 5 |
| 155 | #define R5_Syncio 6 /* this io need to be accounted as resync io */ | 155 | #define R5_Syncio 6 /* this io need to be accounted as resync io */ |
| 156 | #define R5_Overlap 7 /* There is a pending overlapping request on this block */ | 156 | #define R5_Overlap 7 /* There is a pending overlapping request on this block */ |
| 157 | #define R5_ReadError 8 /* seen a read error here recently */ | ||
| 158 | #define R5_ReWrite 9 /* have tried to over-write the readerror */ | ||
| 157 | 159 | ||
| 158 | /* | 160 | /* |
| 159 | * Write method | 161 | * Write method |
