diff options
-rw-r--r-- | drivers/md/bcache/io.c | 19 | ||||
-rw-r--r-- | drivers/md/bcache/io_types.h | 2 | ||||
-rw-r--r-- | drivers/md/bcache/keylist.c | 7 | ||||
-rw-r--r-- | drivers/md/bcache/keylist.h | 5 |
4 files changed, 26 insertions, 7 deletions
diff --git a/drivers/md/bcache/io.c b/drivers/md/bcache/io.c index 34697d0b5596..7c72823a553f 100644 --- a/drivers/md/bcache/io.c +++ b/drivers/md/bcache/io.c @@ -413,6 +413,17 @@ static void bch_write_done(struct closure *cl) closure_return(cl); } +static u64 keylist_sectors(struct keylist *keys) +{ + struct bkey_i *k; + u64 ret = 0; + + for_each_keylist_key(keys, k) + ret += k->k.size; + + return ret; +} + /** * bch_write_index - after a write, update index to point to new data */ @@ -420,11 +431,15 @@ static void bch_write_index(struct closure *cl) { struct bch_write_op *op = container_of(cl, struct bch_write_op, cl); unsigned i; + u64 sectors_start = keylist_sectors(&op->insert_keys); int ret; ret = bch_btree_insert(op->c, BTREE_ID_EXTENTS, &op->insert_keys, op->replace ? &op->replace_info : NULL, op_journal_seq(op), BTREE_INSERT_NOFAIL); + + op->written += sectors_start - keylist_sectors(&op->insert_keys); + if (ret) { __bcache_io_error(op->c, "btree IO error"); op->error = ret; @@ -813,7 +828,8 @@ static void __bch_write(struct closure *cl) do { struct bkey_i *k; - BUG_ON(bio_sectors(bio) != op->insert_key.k.size); + BUG_ON(bio_sectors(bio) != op->insert_key.k.size); + BUG_ON(bio_end_sector(bio) != op->insert_key.k.p.offset); if (open_bucket_nr == ARRAY_SIZE(op->open_buckets)) continue_at(cl, bch_write_index, @@ -1043,6 +1059,7 @@ void bch_write_op_init(struct bch_write_op *op, struct cache_set *c, op->c = c; op->io_wq = NULL; op->bio = bio; + op->written = 0; op->error = 0; op->flags = 0; op->check_enospc = (flags & BCH_WRITE_CHECK_ENOSPC) != 0; diff --git a/drivers/md/bcache/io_types.h b/drivers/md/bcache/io_types.h index c473867ebc5b..e2c7ed099358 100644 --- a/drivers/md/bcache/io_types.h +++ b/drivers/md/bcache/io_types.h @@ -70,6 +70,8 @@ struct bch_write_op { struct workqueue_struct *io_wq; struct bch_write_bio *bio; + unsigned written; /* sectors */ + short error; union { diff --git a/drivers/md/bcache/keylist.c b/drivers/md/bcache/keylist.c index d6a766512f39..a30055f69a93 100644 --- a/drivers/md/bcache/keylist.c +++ b/drivers/md/bcache/keylist.c @@ -173,11 +173,6 @@ void bch_scan_keylist_resize(struct scan_keylist *kl, mutex_unlock(&kl->lock); } -#define keylist_for_each(k, l) \ -for (k = ACCESS_ONCE((l)->bot); \ - k != (l)->top; \ - k = __bch_keylist_next(l, k)) - /** * bch_keylist_recalc_oldest_gens - update oldest_gen pointers from keylist keys * @@ -205,7 +200,7 @@ void bch_keylist_recalc_oldest_gens(struct cache_set *c, mutex_lock(&kl->lock); - keylist_for_each(k, &kl->list) + for_each_keylist_key(&kl->list, k) bch_btree_key_recalc_oldest_gen(c, bkey_i_to_s_c(k)); mutex_unlock(&kl->lock); diff --git a/drivers/md/bcache/keylist.h b/drivers/md/bcache/keylist.h index 5e760003cb0a..4be552a27954 100644 --- a/drivers/md/bcache/keylist.h +++ b/drivers/md/bcache/keylist.h @@ -47,6 +47,11 @@ static inline struct bkey_i *__bch_keylist_next(struct keylist *l, return k; } +#define for_each_keylist_key(_keys, _k) \ + for (_k = ACCESS_ONCE((_keys)->bot); \ + _k != (_keys)->top; \ + _k = __bch_keylist_next(_keys, _k)) + static inline void bch_keylist_enqueue(struct keylist *l) { BUG_ON(!bch_keylist_fits(l, l->top->k.u64s)); |