Commit cab8e233 authored by Kent Overstreet's avatar Kent Overstreet Committed by Kent Overstreet

bcachefs: Add an assertion for removing btree nodes from cache

Chasing a bug that has something to do with the btree node cache.
Signed-off-by: default avatarKent Overstreet <kent.overstreet@gmail.com>
parent f21566f1
...@@ -129,7 +129,8 @@ struct btree *__bch2_btree_node_mem_alloc(struct bch_fs *c) ...@@ -129,7 +129,8 @@ struct btree *__bch2_btree_node_mem_alloc(struct bch_fs *c)
void bch2_btree_node_hash_remove(struct btree_cache *bc, struct btree *b) void bch2_btree_node_hash_remove(struct btree_cache *bc, struct btree *b)
{ {
rhashtable_remove_fast(&bc->table, &b->hash, bch_btree_cache_params); int ret = rhashtable_remove_fast(&bc->table, &b->hash, bch_btree_cache_params);
BUG_ON(ret);
/* Cause future lookups for this node to fail: */ /* Cause future lookups for this node to fail: */
b->hash_val = 0; b->hash_val = 0;
......
...@@ -153,8 +153,6 @@ static void __btree_node_free(struct bch_fs *c, struct btree *b) ...@@ -153,8 +153,6 @@ static void __btree_node_free(struct bch_fs *c, struct btree *b)
clear_btree_node_noevict(b); clear_btree_node_noevict(b);
bch2_btree_node_hash_remove(&c->btree_cache, b);
mutex_lock(&c->btree_cache.lock); mutex_lock(&c->btree_cache.lock);
list_move(&b->list, &c->btree_cache.freeable); list_move(&b->list, &c->btree_cache.freeable);
mutex_unlock(&c->btree_cache.lock); mutex_unlock(&c->btree_cache.lock);
...@@ -170,7 +168,10 @@ static void bch2_btree_node_free_inmem(struct btree_trans *trans, ...@@ -170,7 +168,10 @@ static void bch2_btree_node_free_inmem(struct btree_trans *trans,
BUG_ON(iter->l[b->c.level].b == b); BUG_ON(iter->l[b->c.level].b == b);
six_lock_write(&b->c.lock, NULL, NULL); six_lock_write(&b->c.lock, NULL, NULL);
bch2_btree_node_hash_remove(&c->btree_cache, b);
__btree_node_free(c, b); __btree_node_free(c, b);
six_unlock_write(&b->c.lock); six_unlock_write(&b->c.lock);
six_unlock_intent(&b->c.lock); six_unlock_intent(&b->c.lock);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment