mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-01-20 08:47:59 -05:00
bcachefs: bch2_trans_in_restart_error()
This replaces various BUG_ON() assertions with panics that tell us where the restart was done and the restart type. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
@@ -1224,7 +1224,7 @@ __bch2_btree_path_set_pos(struct btree_trans *trans,
|
||||
{
|
||||
unsigned level = path->level;
|
||||
|
||||
EBUG_ON(trans->restarted);
|
||||
bch2_trans_verify_not_in_restart(trans);
|
||||
EBUG_ON(!path->ref);
|
||||
|
||||
path = bch2_btree_path_make_mut(trans, path, intent, ip);
|
||||
@@ -1353,6 +1353,20 @@ static void bch2_path_put_nokeep(struct btree_trans *trans, struct btree_path *p
|
||||
__bch2_path_free(trans, path);
|
||||
}
|
||||
|
||||
void __noreturn bch2_trans_restart_error(struct btree_trans *trans, u32 restart_count)
|
||||
{
|
||||
panic("trans->restart_count %u, should be %u, last restarted by %pS\n",
|
||||
trans->restart_count, restart_count,
|
||||
(void *) trans->last_restarted_ip);
|
||||
}
|
||||
|
||||
void __noreturn bch2_trans_in_restart_error(struct btree_trans *trans)
|
||||
{
|
||||
panic("in transaction restart: %s, last restarted by %pS\n",
|
||||
bch2_err_str(trans->restarted),
|
||||
(void *) trans->last_restarted_ip);
|
||||
}
|
||||
|
||||
noinline __cold
|
||||
void bch2_trans_updates_to_text(struct printbuf *buf, struct btree_trans *trans)
|
||||
{
|
||||
@@ -1519,7 +1533,7 @@ struct btree_path *bch2_path_get(struct btree_trans *trans,
|
||||
bool intent = flags & BTREE_ITER_INTENT;
|
||||
int i;
|
||||
|
||||
EBUG_ON(trans->restarted);
|
||||
bch2_trans_verify_not_in_restart(trans);
|
||||
bch2_trans_verify_locks(trans);
|
||||
|
||||
btree_trans_sort_paths(trans);
|
||||
@@ -1695,7 +1709,7 @@ struct btree *bch2_btree_iter_next_node(struct btree_iter *iter)
|
||||
struct btree *b = NULL;
|
||||
int ret;
|
||||
|
||||
BUG_ON(trans->restarted);
|
||||
bch2_trans_verify_not_in_restart(trans);
|
||||
EBUG_ON(iter->path->cached);
|
||||
bch2_btree_iter_verify(iter);
|
||||
|
||||
@@ -2833,14 +2847,6 @@ u32 bch2_trans_begin(struct btree_trans *trans)
|
||||
return trans->restart_count;
|
||||
}
|
||||
|
||||
void bch2_trans_verify_not_restarted(struct btree_trans *trans, u32 restart_count)
|
||||
{
|
||||
if (trans_was_restarted(trans, restart_count))
|
||||
panic("trans->restart_count %u, should be %u, last restarted by %pS\n",
|
||||
trans->restart_count, restart_count,
|
||||
(void *) trans->last_restarted_ip);
|
||||
}
|
||||
|
||||
static void bch2_trans_alloc_paths(struct btree_trans *trans, struct bch_fs *c)
|
||||
{
|
||||
size_t paths_bytes = sizeof(struct btree_path) * BTREE_ITER_MAX;
|
||||
|
||||
@@ -227,7 +227,22 @@ static inline bool trans_was_restarted(struct btree_trans *trans, u32 restart_co
|
||||
return restart_count != trans->restart_count;
|
||||
}
|
||||
|
||||
void bch2_trans_verify_not_restarted(struct btree_trans *, u32);
|
||||
void __noreturn bch2_trans_restart_error(struct btree_trans *, u32);
|
||||
|
||||
static inline void bch2_trans_verify_not_restarted(struct btree_trans *trans,
|
||||
u32 restart_count)
|
||||
{
|
||||
if (trans_was_restarted(trans, restart_count))
|
||||
bch2_trans_restart_error(trans, restart_count);
|
||||
}
|
||||
|
||||
void __noreturn bch2_trans_in_restart_error(struct btree_trans *);
|
||||
|
||||
static inline void bch2_trans_verify_not_in_restart(struct btree_trans *trans)
|
||||
{
|
||||
if (trans->restarted)
|
||||
bch2_trans_in_restart_error(trans);
|
||||
}
|
||||
|
||||
__always_inline
|
||||
static inline int btree_trans_restart_nounlock(struct btree_trans *trans, int err)
|
||||
|
||||
@@ -1098,7 +1098,7 @@ int __bch2_trans_commit(struct btree_trans *trans)
|
||||
goto err;
|
||||
}
|
||||
retry:
|
||||
EBUG_ON(trans->restarted);
|
||||
bch2_trans_verify_not_in_restart(trans);
|
||||
memset(&trans->journal_res, 0, sizeof(trans->journal_res));
|
||||
|
||||
ret = do_bch2_trans_commit(trans, &i, _RET_IP_);
|
||||
|
||||
Reference in New Issue
Block a user