Skip to content

Commit f908eac

Browse files
author
Kent Overstreet
committed
bcachefs: fix bch2_btree_key_cache_drop()
When evicting, we shouldn't leave a pointer to the key cache entry lying around - that screws up btree path asserts we're adding. Signed-off-by: Kent Overstreet <[email protected]>
1 parent bc6fce7 commit f908eac

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

fs/bcachefs/btree_key_cache.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -613,8 +613,18 @@ void bch2_btree_key_cache_drop(struct btree_trans *trans,
613613
bkey_cached_free(bc, ck);
614614

615615
mark_btree_node_locked(trans, path, 0, BTREE_NODE_UNLOCKED);
616-
btree_path_set_dirty(path, BTREE_ITER_NEED_TRAVERSE);
617-
path->should_be_locked = false;
616+
617+
struct btree_path *path2;
618+
unsigned i;
619+
trans_for_each_path(trans, path2, i)
620+
if (path2->l[0].b == (void *) ck) {
621+
__bch2_btree_path_unlock(trans, path2);
622+
path2->l[0].b = ERR_PTR(-BCH_ERR_no_btree_node_drop);
623+
path2->should_be_locked = false;
624+
btree_path_set_dirty(path2, BTREE_ITER_NEED_TRAVERSE);
625+
}
626+
627+
bch2_trans_verify_locks(trans);
618628
}
619629

620630
static unsigned long bch2_btree_key_cache_scan(struct shrinker *shrink,

0 commit comments

Comments
 (0)