]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
bcachefs: btree_trans_restart_foreign_task()
authorKent Overstreet <kent.overstreet@linux.dev>
Fri, 21 Mar 2025 18:22:39 +0000 (14:22 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Mon, 24 Mar 2025 13:50:37 +0000 (09:50 -0400)
In debug mode, we save the call stack on transaction restart - but
there's no locking, so we can't touch it if we're issuing the restart
from another thread.

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

index b96157f3dc9c746f6f625cd8598d30be333ec4f8..8823eec6b284e38b9f1f9395e2b51208dd3e9a29 100644 (file)
@@ -335,13 +335,20 @@ static inline void bch2_trans_verify_not_unlocked_or_in_restart(struct btree_tra
 }
 
 __always_inline
-static int btree_trans_restart_ip(struct btree_trans *trans, int err, unsigned long ip)
+static int btree_trans_restart_foreign_task(struct btree_trans *trans, int err, unsigned long ip)
 {
        BUG_ON(err <= 0);
        BUG_ON(!bch2_err_matches(-err, BCH_ERR_transaction_restart));
 
        trans->restarted = err;
        trans->last_restarted_ip = ip;
+       return -err;
+}
+
+__always_inline
+static int btree_trans_restart_ip(struct btree_trans *trans, int err, unsigned long ip)
+{
+       btree_trans_restart_foreign_task(trans, err, ip);
 #ifdef CONFIG_BCACHEFS_DEBUG
        darray_exit(&trans->last_restarted_trace);
        bch2_save_backtrace(&trans->last_restarted_trace, current, 0, GFP_NOWAIT);
index caef65adeae4951df96aa17bb5db6d34d45a5af3..b18fbf6f6226cc30bc7053be3b7e727df2288c31 100644 (file)
@@ -172,7 +172,9 @@ static int abort_lock(struct lock_graph *g, struct trans_waiting_for_lock *i)
 {
        if (i == g->g) {
                trace_would_deadlock(g, i->trans);
-               return btree_trans_restart(i->trans, BCH_ERR_transaction_restart_would_deadlock);
+               return btree_trans_restart_foreign_task(i->trans,
+                                       BCH_ERR_transaction_restart_would_deadlock,
+                                       _THIS_IP_);
        } else {
                i->trans->lock_must_abort = true;
                wake_up_process(i->trans->locking_wait.task);