]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
bcachefs: Avoid calling bch2_btree_iter_relock() in bch2_btree_iter_traverse()
authorKent Overstreet <kent.overstreet@gmail.com>
Mon, 4 Nov 2019 20:56:04 +0000 (15:56 -0500)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:08:31 +0000 (17:08 -0400)
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/btree_iter.c

index f849120fcbcefa0390ea32579082cc27903a3ef4..f05a5e718181060ee7a6f597e34544019f90511c 100644 (file)
@@ -294,9 +294,7 @@ void bch2_btree_trans_verify_locks(struct btree_trans *trans)
 __flatten
 static bool bch2_btree_iter_relock(struct btree_iter *iter, bool trace)
 {
-       return iter->uptodate >= BTREE_ITER_NEED_RELOCK
-               ? btree_iter_get_locks(iter, false, trace)
-               : true;
+       return btree_iter_get_locks(iter, false, trace);
 }
 
 bool __bch2_btree_iter_upgrade(struct btree_iter *iter,
@@ -1098,7 +1096,15 @@ static int btree_iter_traverse_one(struct btree_iter *iter)
        if (unlikely(iter->level >= BTREE_MAX_DEPTH))
                return 0;
 
-       if (bch2_btree_iter_relock(iter, false))
+       /*
+        * if we need interior nodes locked, call btree_iter_relock() to make
+        * sure we walk back up enough that we lock them:
+        */
+       if (iter->uptodate == BTREE_ITER_NEED_RELOCK ||
+           iter->locks_want > 1)
+               bch2_btree_iter_relock(iter, false);
+
+       if (iter->uptodate < BTREE_ITER_NEED_RELOCK)
                return 0;
 
        /*