bcachefs: fix bch2_btree_key_cache_drop()
authorKent Overstreet <kent.overstreet@linux.dev>
Sat, 21 Dec 2024 09:14:28 +0000 (04:14 -0500)
committerKent Overstreet <kent.overstreet@linux.dev>
Fri, 10 Jan 2025 04:38:41 +0000 (23:38 -0500)
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 <kent.overstreet@linux.dev>
fs/bcachefs/btree_key_cache.c

index 382f99b774b8fd6f499988281948fa143d6a33bc..7636a5e974097dba48b30d60fe9c5171723a03d8 100644 (file)
@@ -613,8 +613,18 @@ void bch2_btree_key_cache_drop(struct btree_trans *trans,
        bkey_cached_free(bc, ck);
 
        mark_btree_node_locked(trans, path, 0, BTREE_NODE_UNLOCKED);
-       btree_path_set_dirty(path, BTREE_ITER_NEED_TRAVERSE);
-       path->should_be_locked = false;
+
+       struct btree_path *path2;
+       unsigned i;
+       trans_for_each_path(trans, path2, i)
+               if (path2->l[0].b == (void *) ck) {
+                       __bch2_btree_path_unlock(trans, path2);
+                       path2->l[0].b = ERR_PTR(-BCH_ERR_no_btree_node_drop);
+                       path2->should_be_locked = false;
+                       btree_path_set_dirty(path2, BTREE_ITER_NEED_TRAVERSE);
+               }
+
+       bch2_trans_verify_locks(trans);
 }
 
 static unsigned long bch2_btree_key_cache_scan(struct shrinker *shrink,