Commit a71a1fac authored by Kent Overstreet's avatar Kent Overstreet
Browse files

bcachefs: Better in_restart error



We're ramping up on checking transaction restart handling correctness -
so, in debug mode we now save a backtrace for where the restart was
emitted, which makes it much easier to track down the incorrect
handling.

Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 2434fc38
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -1427,9 +1427,17 @@ void __noreturn bch2_trans_restart_error(struct btree_trans *trans, u32 restart_

void __noreturn bch2_trans_in_restart_error(struct btree_trans *trans)
{
#ifdef CONFIG_BCACHEFS_DEBUG
	struct printbuf buf = PRINTBUF;
	bch2_prt_backtrace(&buf, &trans->last_restarted_trace);
	panic("in transaction restart: %s, last restarted by\n%s",
	      bch2_err_str(trans->restarted),
	      buf.buf);
#else
	panic("in transaction restart: %s, last restarted by %pS\n",
	      bch2_err_str(trans->restarted),
	      (void *) trans->last_restarted_ip);
#endif
}

void __noreturn bch2_trans_unlocked_error(struct btree_trans *trans)
@@ -3287,6 +3295,10 @@ void bch2_trans_put(struct btree_trans *trans)
	closure_return_sync(&trans->ref);
	trans->locking_wait.task = NULL;

#ifdef CONFIG_BCACHEFS_DEBUG
	darray_exit(&trans->last_restarted_trace);
#endif

	unsigned long *paths_allocated = trans->paths_allocated;
	trans->paths_allocated	= NULL;
	trans->paths		= NULL;
+4 −0
Original line number Diff line number Diff line
@@ -350,6 +350,10 @@ static int btree_trans_restart_ip(struct btree_trans *trans, int err, unsigned l

	trans->restarted = err;
	trans->last_restarted_ip = ip;
#ifdef CONFIG_BCACHEFS_DEBUG
	darray_exit(&trans->last_restarted_trace);
	bch2_save_backtrace(&trans->last_restarted_trace, current, 0, GFP_NOWAIT);
#endif
	return -err;
}

+3 −0
Original line number Diff line number Diff line
@@ -513,6 +513,9 @@ struct btree_trans {
	u64			last_begin_time;
	unsigned long		last_begin_ip;
	unsigned long		last_restarted_ip;
#ifdef CONFIG_BCACHEFS_DEBUG
	bch_stacktrace		last_restarted_trace;
#endif
	unsigned long		last_unlock_ip;
	unsigned long		srcu_lock_time;