bcachefs: Fix btree_iter_next_node() for new locking asserts
authorKent Overstreet <kent.overstreet@linux.dev>
Sat, 24 May 2025 00:11:43 +0000 (20:11 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sat, 24 May 2025 02:00:07 +0000 (22:00 -0400)
We can't unlock a should_be_locked path unless we're in a transaction
restart.

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

index 97f3faac8067e5cee04e4f6fdd5b29b6112497bd..b4bf4217a3fa676ff0934c3241ec5edad9e0092f 100644 (file)
@@ -1991,12 +1991,12 @@ struct btree *bch2_btree_iter_next_node(struct btree_trans *trans, struct btree_
        bch2_btree_path_downgrade(trans, path);
 
        if (!bch2_btree_node_relock(trans, path, path->level + 1)) {
+               trace_and_count(trans->c, trans_restart_relock_next_node, trans, _THIS_IP_, path);
+               ret = btree_trans_restart(trans, BCH_ERR_transaction_restart_relock);
                __bch2_btree_path_unlock(trans, path);
                path->l[path->level].b          = ERR_PTR(-BCH_ERR_no_btree_node_relock);
                path->l[path->level + 1].b      = ERR_PTR(-BCH_ERR_no_btree_node_relock);
                btree_path_set_dirty(trans, path, BTREE_ITER_NEED_TRAVERSE);
-               trace_and_count(trans->c, trans_restart_relock_next_node, trans, _THIS_IP_, path);
-               ret = btree_trans_restart(trans, BCH_ERR_transaction_restart_relock);
                goto err;
        }