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) {
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: */
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);