Commit b5e98d65 authored by Dan Williams's avatar Dan Williams

md: handle_stripe5 - add request/completion logic for async read ops

When a read bio is attached to the stripe and the corresponding block is
marked R5_UPTODATE, then a read (biofill) operation is scheduled to copy
the data from the stripe cache to the bio buffer.  handle_stripe flags the
blocks to be operated on with the R5_Wantfill flag.  If new read requests
arrive while raid5_run_ops is running they will not be handled until
handle_stripe is scheduled to run again.

Changelog:
* cleanup to_read and to_fill accounting
* do not fail reads that have reached the cache
Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
Acked-By: default avatarNeilBrown <neilb@suse.de>
parent e89f8962
...@@ -2049,9 +2049,12 @@ handle_requests_to_failed_array(raid5_conf_t *conf, struct stripe_head *sh, ...@@ -2049,9 +2049,12 @@ handle_requests_to_failed_array(raid5_conf_t *conf, struct stripe_head *sh,
bi = bi2; bi = bi2;
} }
/* fail any reads if this device is non-operational */ /* fail any reads if this device is non-operational and
if (!test_bit(R5_Insync, &sh->dev[i].flags) || * the data has not reached the cache yet.
test_bit(R5_ReadError, &sh->dev[i].flags)) { */
if (!test_bit(R5_Wantfill, &sh->dev[i].flags) &&
(!test_bit(R5_Insync, &sh->dev[i].flags) ||
test_bit(R5_ReadError, &sh->dev[i].flags))) {
bi = sh->dev[i].toread; bi = sh->dev[i].toread;
sh->dev[i].toread = NULL; sh->dev[i].toread = NULL;
if (test_and_clear_bit(R5_Overlap, &sh->dev[i].flags)) if (test_and_clear_bit(R5_Overlap, &sh->dev[i].flags))
...@@ -2740,37 +2743,27 @@ static void handle_stripe5(struct stripe_head *sh) ...@@ -2740,37 +2743,27 @@ static void handle_stripe5(struct stripe_head *sh)
struct r5dev *dev = &sh->dev[i]; struct r5dev *dev = &sh->dev[i];
clear_bit(R5_Insync, &dev->flags); clear_bit(R5_Insync, &dev->flags);
pr_debug("check %d: state 0x%lx read %p write %p written %p\n", pr_debug("check %d: state 0x%lx toread %p read %p write %p "
i, dev->flags, dev->toread, dev->towrite, dev->written); "written %p\n", i, dev->flags, dev->toread, dev->read,
/* maybe we can reply to a read */ dev->towrite, dev->written);
if (test_bit(R5_UPTODATE, &dev->flags) && dev->toread) {
struct bio *rbi, *rbi2; /* maybe we can request a biofill operation
pr_debug("Return read for disc %d\n", i); *
spin_lock_irq(&conf->device_lock); * new wantfill requests are only permitted while
rbi = dev->toread; * STRIPE_OP_BIOFILL is clear
dev->toread = NULL; */
if (test_and_clear_bit(R5_Overlap, &dev->flags)) if (test_bit(R5_UPTODATE, &dev->flags) && dev->toread &&
wake_up(&conf->wait_for_overlap); !test_bit(STRIPE_OP_BIOFILL, &sh->ops.pending))
spin_unlock_irq(&conf->device_lock); set_bit(R5_Wantfill, &dev->flags);
while (rbi && rbi->bi_sector < dev->sector + STRIPE_SECTORS) {
copy_data(0, rbi, dev->page, dev->sector);
rbi2 = r5_next_bio(rbi, dev->sector);
spin_lock_irq(&conf->device_lock);
if (--rbi->bi_phys_segments == 0) {
rbi->bi_next = return_bi;
return_bi = rbi;
}
spin_unlock_irq(&conf->device_lock);
rbi = rbi2;
}
}
/* now count some things */ /* now count some things */
if (test_bit(R5_LOCKED, &dev->flags)) s.locked++; if (test_bit(R5_LOCKED, &dev->flags)) s.locked++;
if (test_bit(R5_UPTODATE, &dev->flags)) s.uptodate++; if (test_bit(R5_UPTODATE, &dev->flags)) s.uptodate++;
if (test_bit(R5_Wantcompute, &dev->flags)) s.compute++; if (test_bit(R5_Wantcompute, &dev->flags)) s.compute++;
if (dev->toread) if (test_bit(R5_Wantfill, &dev->flags))
s.to_fill++;
else if (dev->toread)
s.to_read++; s.to_read++;
if (dev->towrite) { if (dev->towrite) {
s.to_write++; s.to_write++;
...@@ -2793,6 +2786,10 @@ static void handle_stripe5(struct stripe_head *sh) ...@@ -2793,6 +2786,10 @@ static void handle_stripe5(struct stripe_head *sh)
set_bit(R5_Insync, &dev->flags); set_bit(R5_Insync, &dev->flags);
} }
rcu_read_unlock(); rcu_read_unlock();
if (s.to_fill && !test_and_set_bit(STRIPE_OP_BIOFILL, &sh->ops.pending))
sh->ops.count++;
pr_debug("locked=%d uptodate=%d to_read=%d" pr_debug("locked=%d uptodate=%d to_read=%d"
" to_write=%d failed=%d failed_num=%d\n", " to_write=%d failed=%d failed_num=%d\n",
s.locked, s.uptodate, s.to_read, s.to_write, s.locked, s.uptodate, s.to_read, s.to_write,
......
...@@ -200,7 +200,7 @@ struct stripe_head { ...@@ -200,7 +200,7 @@ struct stripe_head {
struct stripe_head_state { struct stripe_head_state {
int syncing, expanding, expanded; int syncing, expanding, expanded;
int locked, uptodate, to_read, to_write, failed, written; int locked, uptodate, to_read, to_write, failed, written;
int compute, req_compute, non_overwrite; int to_fill, compute, req_compute, non_overwrite;
int failed_num; int failed_num;
}; };
......
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