Skip to content

Commit 0b4fd56

Browse files
author
Kent Overstreet
committed
bcachefs: btree_trans_restart_foreign_task()
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>
1 parent f4a584f commit 0b4fd56

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

fs/bcachefs/btree_iter.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,13 +335,20 @@ static inline void bch2_trans_verify_not_unlocked_or_in_restart(struct btree_tra
335335
}
336336

337337
__always_inline
338-
static int btree_trans_restart_ip(struct btree_trans *trans, int err, unsigned long ip)
338+
static int btree_trans_restart_foreign_task(struct btree_trans *trans, int err, unsigned long ip)
339339
{
340340
BUG_ON(err <= 0);
341341
BUG_ON(!bch2_err_matches(-err, BCH_ERR_transaction_restart));
342342

343343
trans->restarted = err;
344344
trans->last_restarted_ip = ip;
345+
return -err;
346+
}
347+
348+
__always_inline
349+
static int btree_trans_restart_ip(struct btree_trans *trans, int err, unsigned long ip)
350+
{
351+
btree_trans_restart_foreign_task(trans, err, ip);
345352
#ifdef CONFIG_BCACHEFS_DEBUG
346353
darray_exit(&trans->last_restarted_trace);
347354
bch2_save_backtrace(&trans->last_restarted_trace, current, 0, GFP_NOWAIT);

fs/bcachefs/btree_locking.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,9 @@ static int abort_lock(struct lock_graph *g, struct trans_waiting_for_lock *i)
172172
{
173173
if (i == g->g) {
174174
trace_would_deadlock(g, i->trans);
175-
return btree_trans_restart(i->trans, BCH_ERR_transaction_restart_would_deadlock);
175+
return btree_trans_restart_foreign_task(i->trans,
176+
BCH_ERR_transaction_restart_would_deadlock,
177+
_THIS_IP_);
176178
} else {
177179
i->trans->lock_must_abort = true;
178180
wake_up_process(i->trans->locking_wait.task);

0 commit comments

Comments
 (0)