mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-05 16:54:27 +00:00
bcachefs: Inject transaction restarts in debug mode
In CONFIG_BCACHEFS_DEBUG mode, we'll now randomly issue transaction restarts - with a decaying probability based on the number of restarts we've already had, to ensure that transactions eventually make forward progress. This should help shake out some bugs. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
parent
549d173c1b
commit
a0cb8d784f
2 changed files with 17 additions and 0 deletions
|
@ -17,6 +17,7 @@
|
|||
#include "subvolume.h"
|
||||
#include "trace.h"
|
||||
|
||||
#include <linux/random.h>
|
||||
#include <linux/prefetch.h>
|
||||
|
||||
static inline void btree_path_list_remove(struct btree_trans *, struct btree_path *);
|
||||
|
@ -1660,6 +1661,16 @@ out:
|
|||
int __must_check bch2_btree_path_traverse(struct btree_trans *trans,
|
||||
struct btree_path *path, unsigned flags)
|
||||
{
|
||||
if (IS_ENABLED(CONFIG_BCACHEFS_DEBUG)) {
|
||||
unsigned restart_probability_bits = 4 << min(trans->restart_count, 32U);
|
||||
u64 max = ~(~0ULL << restart_probability_bits);
|
||||
|
||||
if (!get_random_u32_below(max)) {
|
||||
trace_transaction_restart_injected(trans->fn, _RET_IP_);
|
||||
return btree_trans_restart(trans, BCH_ERR_transaction_restart_fault_inject);
|
||||
}
|
||||
}
|
||||
|
||||
if (path->uptodate < BTREE_ITER_NEED_RELOCK)
|
||||
return 0;
|
||||
|
||||
|
|
|
@ -707,6 +707,12 @@ DEFINE_EVENT(transaction_event, transaction_restart_ip,
|
|||
TP_ARGS(trans_fn, caller_ip)
|
||||
);
|
||||
|
||||
DEFINE_EVENT(transaction_event, transaction_restart_injected,
|
||||
TP_PROTO(const char *trans_fn,
|
||||
unsigned long caller_ip),
|
||||
TP_ARGS(trans_fn, caller_ip)
|
||||
);
|
||||
|
||||
DEFINE_EVENT(transaction_event, trans_blocked_journal_reclaim,
|
||||
TP_PROTO(const char *trans_fn,
|
||||
unsigned long caller_ip),
|
||||
|
|
Loading…
Add table
Reference in a new issue