fixup bcachefs: Deadlock cycle detector
authorKent Overstreet <kent.overstreet@linux.dev>
Fri, 20 Jan 2023 20:35:07 +0000 (15:35 -0500)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:09:43 +0000 (17:09 -0400)
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/btree_locking.c

index 76a532f98c72c06dfec9096dcc171126aef6d0f8..5e9424fbc3beaab84b453a13920aa7d0fafe0e94 100644 (file)
@@ -226,6 +226,10 @@ static int lock_graph_descend(struct lock_graph *g, struct btree_trans *trans,
 
                while (g->nr)
                        lock_graph_up(g);
+
+               if (cycle)
+                       return 0;
+
                trace_and_count(trans->c, trans_restart_would_deadlock_recursion_limit, trans, _RET_IP_);
                return btree_trans_restart(orig_trans, BCH_ERR_transaction_restart_deadlock_recursion_limit);
        }
@@ -248,6 +252,9 @@ int bch2_check_for_deadlock(struct btree_trans *trans, struct printbuf *cycle)
        int ret;
 
        if (trans->lock_must_abort) {
+               if (cycle)
+                       return -1;
+
                trace_and_count(trans->c, trans_restart_would_deadlock, trans, _RET_IP_);
                return btree_trans_restart(trans, BCH_ERR_transaction_restart_would_deadlock);
        }