diff options
author | Kent Overstreet <kmo@daterainc.com> | 2014-01-09 00:22:02 -0500 |
---|---|---|
committer | Kent Overstreet <kmo@daterainc.com> | 2014-03-18 15:22:36 -0400 |
commit | c13f3af9247db929fe1be86c0442ef161e615ac4 (patch) | |
tree | 4af0f4811f92718230992a19f97f41df6f3c59ca | |
parent | 15754020524a56517df082799f07de880f4b29e2 (diff) |
bcache: Add bch_keylist_init_single()
This will potentially save us an allocation when we've got inode/dirent bkeys
that don't fit in the keylist's inline keys.
Signed-off-by: Kent Overstreet <kmo@daterainc.com>
-rw-r--r-- | drivers/md/bcache/bset.h | 6 | ||||
-rw-r--r-- | drivers/md/bcache/journal.c | 5 |
2 files changed, 7 insertions, 4 deletions
diff --git a/drivers/md/bcache/bset.h b/drivers/md/bcache/bset.h index 003260f4ddf6..5f6728d5d4dd 100644 --- a/drivers/md/bcache/bset.h +++ b/drivers/md/bcache/bset.h | |||
@@ -478,6 +478,12 @@ static inline void bch_keylist_init(struct keylist *l) | |||
478 | l->top_p = l->keys_p = l->inline_keys; | 478 | l->top_p = l->keys_p = l->inline_keys; |
479 | } | 479 | } |
480 | 480 | ||
481 | static inline void bch_keylist_init_single(struct keylist *l, struct bkey *k) | ||
482 | { | ||
483 | l->keys = k; | ||
484 | l->top = bkey_next(k); | ||
485 | } | ||
486 | |||
481 | static inline void bch_keylist_push(struct keylist *l) | 487 | static inline void bch_keylist_push(struct keylist *l) |
482 | { | 488 | { |
483 | l->top = bkey_next(l->top); | 489 | l->top = bkey_next(l->top); |
diff --git a/drivers/md/bcache/journal.c b/drivers/md/bcache/journal.c index cf8e0932aad2..c8bfc28cd2bd 100644 --- a/drivers/md/bcache/journal.c +++ b/drivers/md/bcache/journal.c | |||
@@ -313,8 +313,6 @@ int bch_journal_replay(struct cache_set *s, struct list_head *list) | |||
313 | uint64_t start = i->j.last_seq, end = i->j.seq, n = start; | 313 | uint64_t start = i->j.last_seq, end = i->j.seq, n = start; |
314 | struct keylist keylist; | 314 | struct keylist keylist; |
315 | 315 | ||
316 | bch_keylist_init(&keylist); | ||
317 | |||
318 | list_for_each_entry(i, list, list) { | 316 | list_for_each_entry(i, list, list) { |
319 | BUG_ON(i->pin && atomic_read(i->pin) != 1); | 317 | BUG_ON(i->pin && atomic_read(i->pin) != 1); |
320 | 318 | ||
@@ -327,8 +325,7 @@ int bch_journal_replay(struct cache_set *s, struct list_head *list) | |||
327 | k = bkey_next(k)) { | 325 | k = bkey_next(k)) { |
328 | trace_bcache_journal_replay_key(k); | 326 | trace_bcache_journal_replay_key(k); |
329 | 327 | ||
330 | bkey_copy(keylist.top, k); | 328 | bch_keylist_init_single(&keylist, k); |
331 | bch_keylist_push(&keylist); | ||
332 | 329 | ||
333 | ret = bch_btree_insert(s, &keylist, i->pin, NULL); | 330 | ret = bch_btree_insert(s, &keylist, i->pin, NULL); |
334 | if (ret) | 331 | if (ret) |