mirror of
https://github.com/torvalds/linux.git
synced 2024-11-26 14:12:06 +00:00
bcachefs: Move btree lock debugging to slowpath fn
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
parent
24db24c749
commit
acb3b26e76
@ -246,6 +246,7 @@ bool __bch2_btree_node_lock(struct btree *b, struct bpos pos,
|
||||
struct btree_iter *linked, *deadlock_iter = NULL;
|
||||
u64 start_time = local_clock();
|
||||
unsigned reason = 9;
|
||||
bool ret;
|
||||
|
||||
/* Check if it's safe to block: */
|
||||
trans_for_each_iter(trans, linked) {
|
||||
@ -354,12 +355,23 @@ bool __bch2_btree_node_lock(struct btree *b, struct bpos pos,
|
||||
if (six_trylock_type(&b->c.lock, type))
|
||||
return true;
|
||||
|
||||
if (six_lock_type(&b->c.lock, type, should_sleep_fn, p))
|
||||
return false;
|
||||
#ifdef CONFIG_BCACHEFS_DEBUG
|
||||
trans->locking_iter_idx = iter->idx;
|
||||
trans->locking_pos = pos;
|
||||
trans->locking_btree_id = iter->btree_id;
|
||||
trans->locking_level = level;
|
||||
trans->locking = b;
|
||||
#endif
|
||||
|
||||
bch2_time_stats_update(&trans->c->times[lock_to_time_stat(type)],
|
||||
start_time);
|
||||
return true;
|
||||
ret = six_lock_type(&b->c.lock, type, should_sleep_fn, p) == 0;
|
||||
|
||||
#ifdef CONFIG_BCACHEFS_DEBUG
|
||||
trans->locking = NULL;
|
||||
#endif
|
||||
if (ret)
|
||||
bch2_time_stats_update(&trans->c->times[lock_to_time_stat(type)],
|
||||
start_time);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Btree iterator locking: */
|
||||
|
@ -186,27 +186,14 @@ static inline bool btree_node_lock(struct btree *b,
|
||||
unsigned long ip)
|
||||
{
|
||||
struct btree_trans *trans = iter->trans;
|
||||
bool ret;
|
||||
|
||||
EBUG_ON(level >= BTREE_MAX_DEPTH);
|
||||
EBUG_ON(!(trans->iters_linked & (1ULL << iter->idx)));
|
||||
|
||||
#ifdef CONFIG_BCACHEFS_DEBUG
|
||||
trans->locking = b;
|
||||
trans->locking_iter_idx = iter->idx;
|
||||
trans->locking_pos = pos;
|
||||
trans->locking_btree_id = iter->btree_id;
|
||||
trans->locking_level = level;
|
||||
#endif
|
||||
ret = likely(six_trylock_type(&b->c.lock, type)) ||
|
||||
return likely(six_trylock_type(&b->c.lock, type)) ||
|
||||
btree_node_lock_increment(trans, b, level, type) ||
|
||||
__bch2_btree_node_lock(b, pos, level, iter, type,
|
||||
should_sleep_fn, p, ip);
|
||||
|
||||
#ifdef CONFIG_BCACHEFS_DEBUG
|
||||
trans->locking = NULL;
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool __bch2_btree_node_relock(struct btree_iter *, unsigned);
|
||||
|
Loading…
Reference in New Issue
Block a user