diff options
author | Kent Overstreet <kmo@daterainc.com> | 2013-07-24 23:18:05 -0700 |
---|---|---|
committer | Kent Overstreet <kmo@daterainc.com> | 2013-11-10 21:56:37 -0800 |
commit | 8835c1234dd9a838993a2d5cb7572f57992ebbee (patch) | |
tree | eb8e1d198b8f4dd683dc8fb1236dcccd1419e77f /drivers/md/bcache | |
parent | f269af5a078302712de8ee70d273eba2eb4485ca (diff) | |
download | linux-8835c1234dd9a838993a2d5cb7572f57992ebbee.tar.gz linux-8835c1234dd9a838993a2d5cb7572f57992ebbee.tar.bz2 linux-8835c1234dd9a838993a2d5cb7572f57992ebbee.zip |
bcache: Add make_btree_freeing_key()
Refactoring, prep work for incremental garbage collection.
Signed-off-by: Kent Overstreet <kmo@daterainc.com>
Diffstat (limited to 'drivers/md/bcache')
-rw-r--r-- | drivers/md/bcache/btree.c | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/drivers/md/bcache/btree.c b/drivers/md/bcache/btree.c index 7d6204c41840..a3f8ca4ee6e0 100644 --- a/drivers/md/bcache/btree.c +++ b/drivers/md/bcache/btree.c @@ -1107,6 +1107,22 @@ static struct btree *btree_node_alloc_replacement(struct btree *b) return n; } +static void make_btree_freeing_key(struct btree *b, struct bkey *k) +{ + unsigned i; + + bkey_copy(k, &b->key); + bkey_copy_key(k, &ZERO_KEY); + + for (i = 0; i < KEY_PTRS(k); i++) { + uint8_t g = PTR_BUCKET(b->c, k, i)->gen + 1; + + SET_PTR_GEN(k, i, g); + } + + atomic_inc(&b->c->prio_blocked); +} + /* Garbage collection */ uint8_t __bch_btree_mark_key(struct cache_set *c, int level, struct bkey *k) @@ -2030,20 +2046,9 @@ static int btree_split(struct btree *b, struct btree_op *op, closure_sync(&cl); bch_btree_set_root(n1); } else { - unsigned i; - - bkey_copy(parent_keys->top, &b->key); - bkey_copy_key(parent_keys->top, &ZERO_KEY); - - for (i = 0; i < KEY_PTRS(&b->key); i++) { - uint8_t g = PTR_BUCKET(b->c, &b->key, i)->gen + 1; - - SET_PTR_GEN(parent_keys->top, i, g); - } - - bch_keylist_push(parent_keys); closure_sync(&cl); - atomic_inc(&b->c->prio_blocked); + make_btree_freeing_key(b, parent_keys->top); + bch_keylist_push(parent_keys); } rw_unlock(true, n1); |