diff options
author | Slava Pestov <sviatoslavpestov@gmail.com> | 2014-07-02 12:49:36 -0700 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@gmail.com> | 2017-01-18 20:21:14 -0900 |
commit | 5aa59c4718cbb1148d5df379b3b988fadee285c7 (patch) | |
tree | d174721eff90057dc6335bae184f0aec2311c7d1 | |
parent | 4cc90dd11ffdd5a5f5988f6756f662923925c9bf (diff) |
bcache: save bi_idx and bi_bvec_done in bbio
Also add a bch_bbio_reset() function to restore those.
This is needed for resubmitting bbios from their endio function,
which will be used for bch_read()'s handling of the read bucket
invalidate race, as well as in the future, re-reading data and
metadata replicas.
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
-rw-r--r-- | drivers/md/bcache/bcache.h | 7 | ||||
-rw-r--r-- | drivers/md/bcache/io.c | 18 |
2 files changed, 25 insertions, 0 deletions
diff --git a/drivers/md/bcache/bcache.h b/drivers/md/bcache/bcache.h index 8fa4574b1705..17480233880d 100644 --- a/drivers/md/bcache/bcache.h +++ b/drivers/md/bcache/bcache.h @@ -812,6 +812,12 @@ struct cache_set { }; struct bbio { + struct cache_set *c; + + unsigned int bi_idx; /* current index into bvl_vec */ + + unsigned int bi_bvec_done; /* number of bytes completed in + current bvec */ unsigned submit_time_us; struct bkey key; u64 pad; @@ -1012,6 +1018,7 @@ void bch_submit_bbio(struct bbio *, struct cache_set *, struct bkey *, unsigned, bool); void bch_submit_bbio_replicas(struct bio *, struct cache_set *, struct bkey *, unsigned long *, bool); +void bch_bbio_reset(struct bbio *bio); __printf(2, 3) bool bch_cache_set_error(struct cache_set *, const char *, ...); diff --git a/drivers/md/bcache/io.c b/drivers/md/bcache/io.c index 9c2dd7d45d2e..f5f100647fc5 100644 --- a/drivers/md/bcache/io.c +++ b/drivers/md/bcache/io.c @@ -65,8 +65,15 @@ struct bio *bch_bbio_alloc(struct cache_set *c) void bch_bbio_prep(struct bbio *b, struct cache_set *c) { + struct bvec_iter *iter = &b->bio.bi_iter; + + b->c = c; + b->bio.bi_iter.bi_sector = PTR_OFFSET(&b->key, 0); b->bio.bi_bdev = PTR_CACHE(c, &b->key, 0)->bdev; + + b->bi_idx = iter->bi_idx; + b->bi_bvec_done = iter->bi_bvec_done; } void bch_submit_bbio(struct bbio *b, struct cache_set *c, @@ -106,6 +113,17 @@ void bch_submit_bbio_replicas(struct bio *bio_src, struct cache_set *c, bch_submit_bbio(to_bbio(bio_src), c, k, first, punt); } +void bch_bbio_reset(struct bbio *b) +{ + struct bvec_iter *iter = &b->bio.bi_iter; + + bio_reset(&b->bio); + iter->bi_sector = KEY_START(&b->key); + iter->bi_size = KEY_SIZE(&b->key) << 9; + iter->bi_idx = b->bi_idx; + iter->bi_bvec_done = b->bi_bvec_done; +} + /* IO errors */ void bch_count_io_errors(struct cache *ca, int error, const char *m) |