]> git.sesse.net Git - bcachefs-tools-debian/blobdiff - libbcachefs/btree_locking.c
Update bcachefs sources to 2272c5f5b7 bcachefs: Mark stripe buckets with correct...
[bcachefs-tools-debian] / libbcachefs / btree_locking.c
index 27b725f943cd6146b609ccf0b130a2c0c30df758..0032d0eb05a59c15a520467b86b7d971a2005785 100644 (file)
@@ -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)