diff options
author | Kent Overstreet <kmo@daterainc.com> | 2013-11-11 21:20:51 -0500 |
---|---|---|
committer | Kent Overstreet <kmo@daterainc.com> | 2014-01-08 16:05:11 -0500 |
commit | 085d2a3dd4d65b7bce1dead987c647dbbc014281 (patch) | |
tree | 89cfb6a71e0c4ea7ae4ff8eb4c148b75a9f14128 /drivers/md/bcache/bset.c | |
parent | 9a02b7eeeb446a0418ec83afc80eb38bc188f5c8 (diff) |
bcache: Make bch_keylist_realloc() take u64s, not nptrs
Getting away from KEY_PTRS and moving toward KEY_U64s - and getting rid of magic
2s
Also - split out the part that checks against journal entry size so as to avoid
a dependancy on struct cache_set in bset.c
Signed-off-by: Kent Overstreet <kmo@daterainc.com>
Diffstat (limited to 'drivers/md/bcache/bset.c')
-rw-r--r-- | drivers/md/bcache/bset.c | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/drivers/md/bcache/bset.c b/drivers/md/bcache/bset.c index e6882659afb9..f91347a55c41 100644 --- a/drivers/md/bcache/bset.c +++ b/drivers/md/bcache/bset.c | |||
@@ -14,21 +14,13 @@ | |||
14 | 14 | ||
15 | /* Keylists */ | 15 | /* Keylists */ |
16 | 16 | ||
17 | int bch_keylist_realloc(struct keylist *l, int nptrs, struct cache_set *c) | 17 | int __bch_keylist_realloc(struct keylist *l, unsigned u64s) |
18 | { | 18 | { |
19 | size_t oldsize = bch_keylist_nkeys(l); | 19 | size_t oldsize = bch_keylist_nkeys(l); |
20 | size_t newsize = oldsize + 2 + nptrs; | 20 | size_t newsize = oldsize + u64s; |
21 | uint64_t *old_keys = l->keys_p == l->inline_keys ? NULL : l->keys_p; | 21 | uint64_t *old_keys = l->keys_p == l->inline_keys ? NULL : l->keys_p; |
22 | uint64_t *new_keys; | 22 | uint64_t *new_keys; |
23 | 23 | ||
24 | /* The journalling code doesn't handle the case where the keys to insert | ||
25 | * is bigger than an empty write: If we just return -ENOMEM here, | ||
26 | * bio_insert() and bio_invalidate() will insert the keys created so far | ||
27 | * and finish the rest when the keylist is empty. | ||
28 | */ | ||
29 | if (newsize * sizeof(uint64_t) > block_bytes(c) - sizeof(struct jset)) | ||
30 | return -ENOMEM; | ||
31 | |||
32 | newsize = roundup_pow_of_two(newsize); | 24 | newsize = roundup_pow_of_two(newsize); |
33 | 25 | ||
34 | if (newsize <= KEYLIST_INLINE || | 26 | if (newsize <= KEYLIST_INLINE || |