diff options
author | Yuri Tikhonov <yur@emcraft.com> | 2009-08-29 22:13:12 -0400 |
---|---|---|
committer | Dan Williams <dan.j.williams@intel.com> | 2009-08-29 22:13:12 -0400 |
commit | 5599becca4bee7badf605e41fd5bcde76d51f2a4 (patch) | |
tree | c2d231dfb073dc19bd9ac7cdbac20e07280b9fb0 /drivers | |
parent | c0f7bddbe60f43578dccf4ffb8d4bff88f625ea7 (diff) |
md/raid6: asynchronous handle_stripe_fill6
Modify handle_stripe_fill6 to work asynchronously by introducing
fetch_block6 as the raid6 analog of fetch_block5 (schedule compute
operations for missing/out-of-sync disks).
[dan.j.williams@intel.com: compute D+Q in one pass]
Signed-off-by: Yuri Tikhonov <yur@emcraft.com>
Signed-off-by: Ilya Yanok <yanok@emcraft.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/md/raid5.c | 143 |
1 files changed, 93 insertions, 50 deletions
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index a1245cf99957..49da6f74d6d6 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c | |||
@@ -2520,61 +2520,104 @@ static void handle_stripe_fill5(struct stripe_head *sh, | |||
2520 | set_bit(STRIPE_HANDLE, &sh->state); | 2520 | set_bit(STRIPE_HANDLE, &sh->state); |
2521 | } | 2521 | } |
2522 | 2522 | ||
2523 | static void handle_stripe_fill6(struct stripe_head *sh, | 2523 | /* fetch_block6 - checks the given member device to see if its data needs |
2524 | struct stripe_head_state *s, struct r6_state *r6s, | 2524 | * to be read or computed to satisfy a request. |
2525 | int disks) | 2525 | * |
2526 | * Returns 1 when no more member devices need to be checked, otherwise returns | ||
2527 | * 0 to tell the loop in handle_stripe_fill6 to continue | ||
2528 | */ | ||
2529 | static int fetch_block6(struct stripe_head *sh, struct stripe_head_state *s, | ||
2530 | struct r6_state *r6s, int disk_idx, int disks) | ||
2526 | { | 2531 | { |
2527 | int i; | 2532 | struct r5dev *dev = &sh->dev[disk_idx]; |
2528 | for (i = disks; i--; ) { | 2533 | struct r5dev *fdev[2] = { &sh->dev[r6s->failed_num[0]], |
2529 | struct r5dev *dev = &sh->dev[i]; | 2534 | &sh->dev[r6s->failed_num[1]] }; |
2530 | if (!test_bit(R5_LOCKED, &dev->flags) && | 2535 | |
2531 | !test_bit(R5_UPTODATE, &dev->flags) && | 2536 | if (!test_bit(R5_LOCKED, &dev->flags) && |
2532 | (dev->toread || (dev->towrite && | 2537 | !test_bit(R5_UPTODATE, &dev->flags) && |
2533 | !test_bit(R5_OVERWRITE, &dev->flags)) || | 2538 | (dev->toread || |
2534 | s->syncing || s->expanding || | 2539 | (dev->towrite && !test_bit(R5_OVERWRITE, &dev->flags)) || |
2535 | (s->failed >= 1 && | 2540 | s->syncing || s->expanding || |
2536 | (sh->dev[r6s->failed_num[0]].toread || | 2541 | (s->failed >= 1 && |
2537 | s->to_write)) || | 2542 | (fdev[0]->toread || s->to_write)) || |
2538 | (s->failed >= 2 && | 2543 | (s->failed >= 2 && |
2539 | (sh->dev[r6s->failed_num[1]].toread || | 2544 | (fdev[1]->toread || s->to_write)))) { |
2540 | s->to_write)))) { | 2545 | /* we would like to get this block, possibly by computing it, |
2541 | /* we would like to get this block, possibly | 2546 | * otherwise read it if the backing disk is insync |
2542 | * by computing it, but we might not be able to | 2547 | */ |
2548 | BUG_ON(test_bit(R5_Wantcompute, &dev->flags)); | ||
2549 | BUG_ON(test_bit(R5_Wantread, &dev->flags)); | ||
2550 | if ((s->uptodate == disks - 1) && | ||
2551 | (s->failed && (disk_idx == r6s->failed_num[0] || | ||
2552 | disk_idx == r6s->failed_num[1]))) { | ||
2553 | /* have disk failed, and we're requested to fetch it; | ||
2554 | * do compute it | ||
2543 | */ | 2555 | */ |
2544 | if ((s->uptodate == disks - 1) && | 2556 | pr_debug("Computing stripe %llu block %d\n", |
2545 | (s->failed && (i == r6s->failed_num[0] || | 2557 | (unsigned long long)sh->sector, disk_idx); |
2546 | i == r6s->failed_num[1]))) { | 2558 | set_bit(STRIPE_COMPUTE_RUN, &sh->state); |
2547 | pr_debug("Computing stripe %llu block %d\n", | 2559 | set_bit(STRIPE_OP_COMPUTE_BLK, &s->ops_request); |
2548 | (unsigned long long)sh->sector, i); | 2560 | set_bit(R5_Wantcompute, &dev->flags); |
2549 | compute_block_1(sh, i, 0); | 2561 | sh->ops.target = disk_idx; |
2550 | s->uptodate++; | 2562 | sh->ops.target2 = -1; /* no 2nd target */ |
2551 | } else if ( s->uptodate == disks-2 && s->failed >= 2 ) { | 2563 | s->req_compute = 1; |
2552 | /* Computing 2-failure is *very* expensive; only | 2564 | s->uptodate++; |
2553 | * do it if failed >= 2 | 2565 | return 1; |
2554 | */ | 2566 | } else if (s->uptodate == disks-2 && s->failed >= 2) { |
2555 | int other; | 2567 | /* Computing 2-failure is *very* expensive; only |
2556 | for (other = disks; other--; ) { | 2568 | * do it if failed >= 2 |
2557 | if (other == i) | 2569 | */ |
2558 | continue; | 2570 | int other; |
2559 | if (!test_bit(R5_UPTODATE, | 2571 | for (other = disks; other--; ) { |
2560 | &sh->dev[other].flags)) | 2572 | if (other == disk_idx) |
2561 | break; | 2573 | continue; |
2562 | } | 2574 | if (!test_bit(R5_UPTODATE, |
2563 | BUG_ON(other < 0); | 2575 | &sh->dev[other].flags)) |
2564 | pr_debug("Computing stripe %llu blocks %d,%d\n", | 2576 | break; |
2565 | (unsigned long long)sh->sector, | ||
2566 | i, other); | ||
2567 | compute_block_2(sh, i, other); | ||
2568 | s->uptodate += 2; | ||
2569 | } else if (test_bit(R5_Insync, &dev->flags)) { | ||
2570 | set_bit(R5_LOCKED, &dev->flags); | ||
2571 | set_bit(R5_Wantread, &dev->flags); | ||
2572 | s->locked++; | ||
2573 | pr_debug("Reading block %d (sync=%d)\n", | ||
2574 | i, s->syncing); | ||
2575 | } | 2577 | } |
2578 | BUG_ON(other < 0); | ||
2579 | pr_debug("Computing stripe %llu blocks %d,%d\n", | ||
2580 | (unsigned long long)sh->sector, | ||
2581 | disk_idx, other); | ||
2582 | set_bit(STRIPE_COMPUTE_RUN, &sh->state); | ||
2583 | set_bit(STRIPE_OP_COMPUTE_BLK, &s->ops_request); | ||
2584 | set_bit(R5_Wantcompute, &sh->dev[disk_idx].flags); | ||
2585 | set_bit(R5_Wantcompute, &sh->dev[other].flags); | ||
2586 | sh->ops.target = disk_idx; | ||
2587 | sh->ops.target2 = other; | ||
2588 | s->uptodate += 2; | ||
2589 | s->req_compute = 1; | ||
2590 | return 1; | ||
2591 | } else if (test_bit(R5_Insync, &dev->flags)) { | ||
2592 | set_bit(R5_LOCKED, &dev->flags); | ||
2593 | set_bit(R5_Wantread, &dev->flags); | ||
2594 | s->locked++; | ||
2595 | pr_debug("Reading block %d (sync=%d)\n", | ||
2596 | disk_idx, s->syncing); | ||
2576 | } | 2597 | } |
2577 | } | 2598 | } |
2599 | |||
2600 | return 0; | ||
2601 | } | ||
2602 | |||
2603 | /** | ||
2604 | * handle_stripe_fill6 - read or compute data to satisfy pending requests. | ||
2605 | */ | ||
2606 | static void handle_stripe_fill6(struct stripe_head *sh, | ||
2607 | struct stripe_head_state *s, struct r6_state *r6s, | ||
2608 | int disks) | ||
2609 | { | ||
2610 | int i; | ||
2611 | |||
2612 | /* look for blocks to read/compute, skip this if a compute | ||
2613 | * is already in flight, or if the stripe contents are in the | ||
2614 | * midst of changing due to a write | ||
2615 | */ | ||
2616 | if (!test_bit(STRIPE_COMPUTE_RUN, &sh->state) && !sh->check_state && | ||
2617 | !sh->reconstruct_state) | ||
2618 | for (i = disks; i--; ) | ||
2619 | if (fetch_block6(sh, s, r6s, i, disks)) | ||
2620 | break; | ||
2578 | set_bit(STRIPE_HANDLE, &sh->state); | 2621 | set_bit(STRIPE_HANDLE, &sh->state); |
2579 | } | 2622 | } |
2580 | 2623 | ||