Skip to content

Commit 8835c12

Browse files
author
Kent Overstreet
committed
bcache: Add make_btree_freeing_key()
Refactoring, prep work for incremental garbage collection. Signed-off-by: Kent Overstreet <kmo@daterainc.com>
1 parent f269af5 commit 8835c12

1 file changed

Lines changed: 18 additions & 13 deletions

File tree

‎drivers/md/bcache/btree.c‎

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1107,6 +1107,22 @@ static struct btree *btree_node_alloc_replacement(struct btree *b)
11071107
return n;
11081108
}
11091109

1110+
static void make_btree_freeing_key(struct btree *b, struct bkey *k)
1111+
{
1112+
unsigned i;
1113+
1114+
bkey_copy(k, &b->key);
1115+
bkey_copy_key(k, &ZERO_KEY);
1116+
1117+
for (i = 0; i < KEY_PTRS(k); i++) {
1118+
uint8_t g = PTR_BUCKET(b->c, k, i)->gen + 1;
1119+
1120+
SET_PTR_GEN(k, i, g);
1121+
}
1122+
1123+
atomic_inc(&b->c->prio_blocked);
1124+
}
1125+
11101126
/* Garbage collection */
11111127

11121128
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,
20302046
closure_sync(&cl);
20312047
bch_btree_set_root(n1);
20322048
} else {
2033-
unsigned i;
2034-
2035-
bkey_copy(parent_keys->top, &b->key);
2036-
bkey_copy_key(parent_keys->top, &ZERO_KEY);
2037-
2038-
for (i = 0; i < KEY_PTRS(&b->key); i++) {
2039-
uint8_t g = PTR_BUCKET(b->c, &b->key, i)->gen + 1;
2040-
2041-
SET_PTR_GEN(parent_keys->top, i, g);
2042-
}
2043-
2044-
bch_keylist_push(parent_keys);
20452049
closure_sync(&cl);
2046-
atomic_inc(&b->c->prio_blocked);
2050+
make_btree_freeing_key(b, parent_keys->top);
2051+
bch_keylist_push(parent_keys);
20472052
}
20482053

20492054
rw_unlock(true, n1);

0 commit comments

Comments
 (0)