Commit 5599becc authored by Yuri Tikhonov's avatar Yuri Tikhonov Committed by Dan Williams

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: default avatarYuri Tikhonov <yur@emcraft.com>
Signed-off-by: default avatarIlya Yanok <yanok@emcraft.com>
Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
parent c0f7bddb
...@@ -2520,41 +2520,56 @@ static void handle_stripe_fill5(struct stripe_head *sh, ...@@ -2520,41 +2520,56 @@ static void handle_stripe_fill5(struct stripe_head *sh,
set_bit(STRIPE_HANDLE, &sh->state); set_bit(STRIPE_HANDLE, &sh->state);
} }
static void handle_stripe_fill6(struct stripe_head *sh, /* fetch_block6 - checks the given member device to see if its data needs
struct stripe_head_state *s, struct r6_state *r6s, * to be read or computed to satisfy a request.
int disks) *
* Returns 1 when no more member devices need to be checked, otherwise returns
* 0 to tell the loop in handle_stripe_fill6 to continue
*/
static int fetch_block6(struct stripe_head *sh, struct stripe_head_state *s,
struct r6_state *r6s, int disk_idx, int disks)
{ {
int i; struct r5dev *dev = &sh->dev[disk_idx];
for (i = disks; i--; ) { struct r5dev *fdev[2] = { &sh->dev[r6s->failed_num[0]],
struct r5dev *dev = &sh->dev[i]; &sh->dev[r6s->failed_num[1]] };
if (!test_bit(R5_LOCKED, &dev->flags) && if (!test_bit(R5_LOCKED, &dev->flags) &&
!test_bit(R5_UPTODATE, &dev->flags) && !test_bit(R5_UPTODATE, &dev->flags) &&
(dev->toread || (dev->towrite && (dev->toread ||
!test_bit(R5_OVERWRITE, &dev->flags)) || (dev->towrite && !test_bit(R5_OVERWRITE, &dev->flags)) ||
s->syncing || s->expanding || s->syncing || s->expanding ||
(s->failed >= 1 && (s->failed >= 1 &&
(sh->dev[r6s->failed_num[0]].toread || (fdev[0]->toread || s->to_write)) ||
s->to_write)) ||
(s->failed >= 2 && (s->failed >= 2 &&
(sh->dev[r6s->failed_num[1]].toread || (fdev[1]->toread || s->to_write)))) {
s->to_write)))) { /* we would like to get this block, possibly by computing it,
/* we would like to get this block, possibly * otherwise read it if the backing disk is insync
* by computing it, but we might not be able to
*/ */
BUG_ON(test_bit(R5_Wantcompute, &dev->flags));
BUG_ON(test_bit(R5_Wantread, &dev->flags));
if ((s->uptodate == disks - 1) && if ((s->uptodate == disks - 1) &&
(s->failed && (i == r6s->failed_num[0] || (s->failed && (disk_idx == r6s->failed_num[0] ||
i == r6s->failed_num[1]))) { disk_idx == r6s->failed_num[1]))) {
/* have disk failed, and we're requested to fetch it;
* do compute it
*/
pr_debug("Computing stripe %llu block %d\n", pr_debug("Computing stripe %llu block %d\n",
(unsigned long long)sh->sector, i); (unsigned long long)sh->sector, disk_idx);
compute_block_1(sh, i, 0); set_bit(STRIPE_COMPUTE_RUN, &sh->state);
set_bit(STRIPE_OP_COMPUTE_BLK, &s->ops_request);
set_bit(R5_Wantcompute, &dev->flags);
sh->ops.target = disk_idx;
sh->ops.target2 = -1; /* no 2nd target */
s->req_compute = 1;
s->uptodate++; s->uptodate++;
} else if ( s->uptodate == disks-2 && s->failed >= 2 ) { return 1;
} else if (s->uptodate == disks-2 && s->failed >= 2) {
/* Computing 2-failure is *very* expensive; only /* Computing 2-failure is *very* expensive; only
* do it if failed >= 2 * do it if failed >= 2
*/ */
int other; int other;
for (other = disks; other--; ) { for (other = disks; other--; ) {
if (other == i) if (other == disk_idx)
continue; continue;
if (!test_bit(R5_UPTODATE, if (!test_bit(R5_UPTODATE,
&sh->dev[other].flags)) &sh->dev[other].flags))
...@@ -2563,18 +2578,46 @@ static void handle_stripe_fill6(struct stripe_head *sh, ...@@ -2563,18 +2578,46 @@ static void handle_stripe_fill6(struct stripe_head *sh,
BUG_ON(other < 0); BUG_ON(other < 0);
pr_debug("Computing stripe %llu blocks %d,%d\n", pr_debug("Computing stripe %llu blocks %d,%d\n",
(unsigned long long)sh->sector, (unsigned long long)sh->sector,
i, other); disk_idx, other);
compute_block_2(sh, i, other); set_bit(STRIPE_COMPUTE_RUN, &sh->state);
set_bit(STRIPE_OP_COMPUTE_BLK, &s->ops_request);
set_bit(R5_Wantcompute, &sh->dev[disk_idx].flags);
set_bit(R5_Wantcompute, &sh->dev[other].flags);
sh->ops.target = disk_idx;
sh->ops.target2 = other;
s->uptodate += 2; s->uptodate += 2;
s->req_compute = 1;
return 1;
} else if (test_bit(R5_Insync, &dev->flags)) { } else if (test_bit(R5_Insync, &dev->flags)) {
set_bit(R5_LOCKED, &dev->flags); set_bit(R5_LOCKED, &dev->flags);
set_bit(R5_Wantread, &dev->flags); set_bit(R5_Wantread, &dev->flags);
s->locked++; s->locked++;
pr_debug("Reading block %d (sync=%d)\n", pr_debug("Reading block %d (sync=%d)\n",
i, s->syncing); disk_idx, s->syncing);
}
} }
} }
return 0;
}
/**
* handle_stripe_fill6 - read or compute data to satisfy pending requests.
*/
static void handle_stripe_fill6(struct stripe_head *sh,
struct stripe_head_state *s, struct r6_state *r6s,
int disks)
{
int i;
/* look for blocks to read/compute, skip this if a compute
* is already in flight, or if the stripe contents are in the
* midst of changing due to a write
*/
if (!test_bit(STRIPE_COMPUTE_RUN, &sh->state) && !sh->check_state &&
!sh->reconstruct_state)
for (i = disks; i--; )
if (fetch_block6(sh, s, r6s, i, disks))
break;
set_bit(STRIPE_HANDLE, &sh->state); set_bit(STRIPE_HANDLE, &sh->state);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment