diff options
-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) |