aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/bcache/journal.c
diff options
context:
space:
mode:
authorKent Overstreet <kmo@daterainc.com>2013-07-24 17:24:25 -0700
committerKent Overstreet <kmo@daterainc.com>2013-11-10 21:56:00 -0800
commitc2f95ae2ebbe1ab61b1d4437f5923fdf720d4d4d (patch)
tree67da94194f87693f7c280176cfc5a13c6162eea0 /drivers/md/bcache/journal.c
parentbcache: Add explicit keylist arg to btree_insert() (diff)
downloadlinux-dev-c2f95ae2ebbe1ab61b1d4437f5923fdf720d4d4d.tar.xz
linux-dev-c2f95ae2ebbe1ab61b1d4437f5923fdf720d4d4d.zip
bcache: Clean up keylist code
More random refactoring. Signed-off-by: Kent Overstreet <kmo@daterainc.com>
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);