summaryrefslogtreecommitdiff
path: root/drivers/md/bcache/journal.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/md/bcache/journal.c')
-rw-r--r--drivers/md/bcache/journal.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/drivers/md/bcache/journal.c b/drivers/md/bcache/journal.c
index 5abe5d5fc183..1bdefdb1fa71 100644
--- a/drivers/md/bcache/journal.c
+++ b/drivers/md/bcache/journal.c
@@ -713,7 +713,7 @@ void bch_journal(struct closure *cl)
struct btree_op *op = container_of(cl, struct btree_op, cl);
struct cache_set *c = op->c;
struct journal_write *w;
- size_t b, n = ((uint64_t *) op->keys.top) - op->keys.list;
+ size_t sectors, nkeys;
if (op->type != BTREE_INSERT ||
!CACHE_SYNC(&c->sb))
@@ -741,10 +741,12 @@ void bch_journal(struct closure *cl)
}
w = c->journal.cur;
- b = __set_blocks(w->data, w->data->keys + n, c);
+ nkeys = w->data->keys + bch_keylist_nkeys(&op->keys);
+ sectors = __set_blocks(w->data, nkeys, c) * c->sb.block_size;
- if (b * c->sb.block_size > PAGE_SECTORS << JSET_BITS ||
- b > c->journal.blocks_free) {
+ if (sectors > min_t(size_t,
+ c->journal.blocks_free * c->sb.block_size,
+ PAGE_SECTORS << JSET_BITS)) {
trace_bcache_journal_entry_full(c);
/*
@@ -760,8 +762,8 @@ void bch_journal(struct closure *cl)
continue_at(cl, bch_journal, bcache_wq);
}
- memcpy(end(w->data), op->keys.list, n * sizeof(uint64_t));
- w->data->keys += n;
+ memcpy(end(w->data), op->keys.keys, bch_keylist_bytes(&op->keys));
+ w->data->keys += bch_keylist_nkeys(&op->keys);
op->journal = &fifo_back(&c->journal.pin);
atomic_inc(op->journal);