bcachefs: delete faulty fastpath in bch2_btree_path_traverse_cached()
authorKent Overstreet <kent.overstreet@linux.dev>
Wed, 14 Aug 2024 02:40:39 +0000 (22:40 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Wed, 14 Aug 2024 02:56:50 +0000 (22:56 -0400)
bch2_btree_path_traverse_cached() was previously checking if it could
just relock the path, which is a common idiom in path traversal.

However, it was using btree_node_relock(), not btree_path_relock();
btree_path_relock() only succeeds if the path was in state
BTREE_ITER_NEED_RELOCK.

If the path was in state BTREE_ITER_NEED_TRAVERSE a full traversal is
needed; this led to a null ptr deref in
bch2_btree_path_traverse_cached().

And the short circuit check here isn't needed, since it was already done
in the main bch2_btree_path_traverse_one().

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/btree_key_cache.c

index f2f2e525460b578b33f592c492c8bab89971ef63..79954490627ccaa7416a27950482f1f8d5347a9f 100644 (file)
@@ -497,11 +497,6 @@ int bch2_btree_path_traverse_cached(struct btree_trans *trans, struct btree_path
 
        path->l[1].b = NULL;
 
-       if (bch2_btree_node_relock_notrace(trans, path, 0)) {
-               path->uptodate = BTREE_ITER_UPTODATE;
-               return 0;
-       }
-
        int ret;
        do {
                ret = btree_path_traverse_cached_fast(trans, path);