From: Kent Overstreet <kent.overstreet@linux.dev>
To: linux-bcachefs@vger.kernel.org
Cc: Kent Overstreet <kent.overstreet@linux.dev>
Subject: [PATCH 2/9] bcachefs: Better in_restart error
Date: Sat, 26 Oct 2024 20:51:31 -0400 [thread overview]
Message-ID: <20241027005141.2337634-3-kent.overstreet@linux.dev> (raw)
In-Reply-To: <20241027005141.2337634-1-kent.overstreet@linux.dev>
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: Kent Overstreet <kent.overstreet@linux.dev>
---
fs/bcachefs/btree_iter.c | 12 ++++++++++++
fs/bcachefs/btree_iter.h | 4 ++++
fs/bcachefs/btree_types.h | 3 +++
3 files changed, 19 insertions(+)
diff --git a/fs/bcachefs/btree_iter.c b/fs/bcachefs/btree_iter.c
index b36ee4e511fa..15ac72b1af51 100644
--- a/fs/bcachefs/btree_iter.c
+++ b/fs/bcachefs/btree_iter.c
@@ -1414,9 +1414,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)
@@ -3274,6 +3282,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;
diff --git a/fs/bcachefs/btree_iter.h b/fs/bcachefs/btree_iter.h
index dda07a320488..36899c6b134e 100644
--- a/fs/bcachefs/btree_iter.h
+++ b/fs/bcachefs/btree_iter.h
@@ -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;
}
diff --git a/fs/bcachefs/btree_types.h b/fs/bcachefs/btree_types.h
index 4568a41fefaf..baab5288ecc9 100644
--- a/fs/bcachefs/btree_types.h
+++ b/fs/bcachefs/btree_types.h
@@ -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;
--
2.45.2
next prev parent reply other threads:[~2024-10-27 0:51 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-27 0:51 [PATCH 0/9] transaction restarts and other iterator work Kent Overstreet
2024-10-27 0:51 ` [PATCH 1/9] bcachefs: Assert we're not in a restart in bch2_trans_put() Kent Overstreet
2024-10-27 0:51 ` Kent Overstreet [this message]
2024-10-27 0:51 ` [PATCH 3/9] bcachefs: CONFIG_BCACHEFS_INJECT_TRANSACTION_RESTARTS Kent Overstreet
2024-10-27 0:51 ` [PATCH 4/9] bcachefs: Assert that we're not violating key cache coherency rules Kent Overstreet
2024-10-27 0:51 ` [PATCH 5/9] bcachefs: Rename btree_iter_peek_upto() -> btree_iter_peek_max() Kent Overstreet
2024-10-27 0:51 ` [PATCH 6/9] bcachefs: Simplify btree_iter_peek() filter_snapshots Kent Overstreet
2024-10-27 0:51 ` [PATCH 7/9] bcachefs: Kill unnecessary iter_rewind() in bkey_get_empty_slot() Kent Overstreet
2024-10-27 0:51 ` [PATCH 8/9] bcachefs: Implement bch2_btree_iter_prev_min() Kent Overstreet
2024-10-27 0:51 ` [PATCH 9/9] bcachefs: peek_prev_min(): Search forwards for extents, snapshots Kent Overstreet
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241027005141.2337634-3-kent.overstreet@linux.dev \
--to=kent.overstreet@linux.dev \
--cc=linux-bcachefs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox