]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
bcache: Add make_btree_freeing_key()
authorKent Overstreet <kmo@daterainc.com>
Thu, 25 Jul 2013 06:18:05 +0000 (23:18 -0700)
committerKent Overstreet <kmo@daterainc.com>
Wed, 11 Sep 2013 02:06:21 +0000 (19:06 -0700)
Refactoring, prep work for incremental garbage collection.

Signed-off-by: Kent Overstreet <kmo@daterainc.com>
drivers/md/bcache/btree.c

index c15b863a6c0bdbfb9d16c6e7f74f872c92ee692c..2cf8dd1bc9461b8e25b48b2acec3440cb30a7848 100644 (file)
@@ -1098,6 +1098,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)
@@ -2018,20 +2034,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);