diff options
Diffstat (limited to 'libbcachefs/btree_locking.c')
-rw-r--r-- | libbcachefs/btree_locking.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/libbcachefs/btree_locking.c b/libbcachefs/btree_locking.c index 27b725f9..0032d0eb 100644 --- a/libbcachefs/btree_locking.c +++ b/libbcachefs/btree_locking.c @@ -4,7 +4,19 @@ #include "btree_locking.h" #include "btree_types.h" -struct lock_class_key bch2_btree_node_lock_key; +static struct lock_class_key bch2_btree_node_lock_key; + +void bch2_btree_lock_init(struct btree_bkey_cached_common *b) +{ + __six_lock_init(&b->lock, "b->c.lock", &bch2_btree_node_lock_key); +} + +#ifdef CONFIG_LOCKDEP +void bch2_assert_btree_nodes_not_locked(void) +{ + BUG_ON(lock_class_is_held(&bch2_btree_node_lock_key)); +} +#endif /* Btree node locking: */ @@ -684,8 +696,8 @@ void bch2_trans_unlock(struct btree_trans *trans) * bch2_gc_btree_init_recurse() doesn't use btree iterators for walking * btree nodes, it implements its own walking: */ - EBUG_ON(!trans->is_initial_gc && - lock_class_is_held(&bch2_btree_node_lock_key)); + if (!trans->is_initial_gc) + bch2_assert_btree_nodes_not_locked(); } bool bch2_trans_locked(struct btree_trans *trans) |