bcachefs: Fix redundant transaction restart
authorKent Overstreet <kent.overstreet@linux.dev>
Sun, 4 Sep 2022 05:28:51 +0000 (01:28 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:09:40 +0000 (17:09 -0400)
Little bit of tidying up, this makes the counters a little bit clearer
as to what's happening.

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

index bfe9780aea3ae0f71e733a704de7d0e4a4b1da67..08dbc799bb35b6ce3ad3bba1d06469feb8f09a88 100644 (file)
@@ -413,14 +413,13 @@ int bch2_trans_relock(struct btree_trans *trans)
        struct btree_path *path;
 
        if (unlikely(trans->restarted))
-               return -BCH_ERR_transaction_restart_relock;
+               return - ((int) trans->restarted);
 
        trans_for_each_path(trans, path)
                if (path->should_be_locked &&
-                   bch2_btree_path_relock(trans, path, _RET_IP_)) {
+                   !bch2_btree_path_relock_norestart(trans, path, _RET_IP_)) {
                        trace_and_count(trans->c, trans_restart_relock, trans, _RET_IP_, path);
-                       BUG_ON(!trans->restarted);
-                       return -BCH_ERR_transaction_restart_relock;
+                       return btree_trans_restart(trans, BCH_ERR_transaction_restart_relock);
                }
        return 0;
 }