aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/raid5.c
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2011-07-26 21:00:36 -0400
committerNeilBrown <neilb@suse.de>2011-07-26 21:00:36 -0400
commitc5a3100062cf277d3edd4e6f4a1f1e403524b464 (patch)
treeccc8f2ae6491497cd8ad172a3bbc0165f86edcdf /drivers/md/raid5.c
parent3687c061886dd0bfec07e131ad12f916ef0abc62 (diff)
md/raid5: move more code into common handle_stripe
The difference between the RAID5 and RAID6 code here is easily resolved using conf->max_degraded. Signed-off-by: NeilBrown <neilb@suse.de> Reviewed-by: Namhyung Kim <namhyung@gmail.com>
Diffstat (limited to 'drivers/md/raid5.c')
-rw-r--r--drivers/md/raid5.c90
1 files changed, 32 insertions, 58 deletions
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index cd6f04f145e6..74a575bbd25c 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -3176,34 +3176,6 @@ static int handle_stripe5(struct stripe_head *sh, struct stripe_head_state *s)
3176 !test_bit(STRIPE_COMPUTE_RUN, &sh->state) && 3176 !test_bit(STRIPE_COMPUTE_RUN, &sh->state) &&
3177 !test_bit(STRIPE_INSYNC, &sh->state))) 3177 !test_bit(STRIPE_INSYNC, &sh->state)))
3178 handle_parity_checks5(conf, sh, s, disks); 3178 handle_parity_checks5(conf, sh, s, disks);
3179
3180 if (s->syncing && s->locked == 0
3181 && test_bit(STRIPE_INSYNC, &sh->state)) {
3182 md_done_sync(conf->mddev, STRIPE_SECTORS,1);
3183 clear_bit(STRIPE_SYNCING, &sh->state);
3184 }
3185
3186 /* If the failed drive is just a ReadError, then we might need to progress
3187 * the repair/check process
3188 */
3189 if (s->failed == 1 && !conf->mddev->ro &&
3190 test_bit(R5_ReadError, &sh->dev[s->failed_num[0]].flags)
3191 && !test_bit(R5_LOCKED, &sh->dev[s->failed_num[0]].flags)
3192 && test_bit(R5_UPTODATE, &sh->dev[s->failed_num[0]].flags)
3193 ) {
3194 dev = &sh->dev[s->failed_num[0]];
3195 if (!test_bit(R5_ReWrite, &dev->flags)) {
3196 set_bit(R5_Wantwrite, &dev->flags);
3197 set_bit(R5_ReWrite, &dev->flags);
3198 set_bit(R5_LOCKED, &dev->flags);
3199 s->locked++;
3200 } else {
3201 /* let's read it back */
3202 set_bit(R5_Wantread, &dev->flags);
3203 set_bit(R5_LOCKED, &dev->flags);
3204 s->locked++;
3205 }
3206 }
3207 return 0; 3179 return 0;
3208} 3180}
3209 3181
@@ -3393,36 +3365,6 @@ static int handle_stripe6(struct stripe_head *sh, struct stripe_head_state *s)
3393 !test_bit(STRIPE_COMPUTE_RUN, &sh->state) && 3365 !test_bit(STRIPE_COMPUTE_RUN, &sh->state) &&
3394 !test_bit(STRIPE_INSYNC, &sh->state))) 3366 !test_bit(STRIPE_INSYNC, &sh->state)))
3395 handle_parity_checks6(conf, sh, s, disks); 3367 handle_parity_checks6(conf, sh, s, disks);
3396
3397 if (s->syncing && s->locked == 0
3398 && test_bit(STRIPE_INSYNC, &sh->state)) {
3399 md_done_sync(conf->mddev, STRIPE_SECTORS,1);
3400 clear_bit(STRIPE_SYNCING, &sh->state);
3401 }
3402
3403 /* If the failed drives are just a ReadError, then we might need
3404 * to progress the repair/check process
3405 */
3406 if (s->failed <= 2 && !conf->mddev->ro)
3407 for (i = 0; i < s->failed; i++) {
3408 dev = &sh->dev[s->failed_num[i]];
3409 if (test_bit(R5_ReadError, &dev->flags)
3410 && !test_bit(R5_LOCKED, &dev->flags)
3411 && test_bit(R5_UPTODATE, &dev->flags)
3412 ) {
3413 if (!test_bit(R5_ReWrite, &dev->flags)) {
3414 set_bit(R5_Wantwrite, &dev->flags);
3415 set_bit(R5_ReWrite, &dev->flags);
3416 set_bit(R5_LOCKED, &dev->flags);
3417 s->locked++;
3418 } else {
3419 /* let's read it back */
3420 set_bit(R5_Wantread, &dev->flags);
3421 set_bit(R5_LOCKED, &dev->flags);
3422 s->locked++;
3423 }
3424 }
3425 }
3426 return 0; 3368 return 0;
3427} 3369}
3428 3370
@@ -3465,6 +3407,38 @@ static void handle_stripe(struct stripe_head *sh)
3465 3407
3466 if (done) 3408 if (done)
3467 goto finish; 3409 goto finish;
3410
3411
3412 if (s.syncing && s.locked == 0 && test_bit(STRIPE_INSYNC, &sh->state)) {
3413 md_done_sync(conf->mddev, STRIPE_SECTORS, 1);
3414 clear_bit(STRIPE_SYNCING, &sh->state);
3415 }
3416
3417 /* If the failed drives are just a ReadError, then we might need
3418 * to progress the repair/check process
3419 */
3420 if (s.failed <= conf->max_degraded && !conf->mddev->ro)
3421 for (i = 0; i < s.failed; i++) {
3422 struct r5dev *dev = &sh->dev[s.failed_num[i]];
3423 if (test_bit(R5_ReadError, &dev->flags)
3424 && !test_bit(R5_LOCKED, &dev->flags)
3425 && test_bit(R5_UPTODATE, &dev->flags)
3426 ) {
3427 if (!test_bit(R5_ReWrite, &dev->flags)) {
3428 set_bit(R5_Wantwrite, &dev->flags);
3429 set_bit(R5_ReWrite, &dev->flags);
3430 set_bit(R5_LOCKED, &dev->flags);
3431 s.locked++;
3432 } else {
3433 /* let's read it back */
3434 set_bit(R5_Wantread, &dev->flags);
3435 set_bit(R5_LOCKED, &dev->flags);
3436 s.locked++;
3437 }
3438 }
3439 }
3440
3441
3468 /* Finish reconstruct operations initiated by the expansion process */ 3442 /* Finish reconstruct operations initiated by the expansion process */
3469 if (sh->reconstruct_state == reconstruct_state_result) { 3443 if (sh->reconstruct_state == reconstruct_state_result) {
3470 struct stripe_head *sh_src 3444 struct stripe_head *sh_src