diff options
Diffstat (limited to 'libbcachefs/btree_cache.h')
-rw-r--r-- | libbcachefs/btree_cache.h | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/libbcachefs/btree_cache.h b/libbcachefs/btree_cache.h index ca3c1b14..035b2cb2 100644 --- a/libbcachefs/btree_cache.h +++ b/libbcachefs/btree_cache.h @@ -30,6 +30,7 @@ void bch2_btree_node_update_key_early(struct btree_trans *, enum btree_id, unsig void bch2_btree_cache_cannibalize_unlock(struct btree_trans *); int bch2_btree_cache_cannibalize_lock(struct btree_trans *, struct closure *); +void __btree_node_data_free(struct btree *); struct btree *__bch2_btree_node_mem_alloc(struct bch_fs *); struct btree *bch2_btree_node_mem_alloc(struct btree_trans *, bool); @@ -143,6 +144,14 @@ static inline struct btree *btree_node_root(struct bch_fs *c, struct btree *b) return r ? r->b : NULL; } +static inline bool btree_node_is_root(struct bch_fs *c, struct btree *b) +{ + struct btree *root = btree_node_root(c, b); + + BUG_ON(b != root && b->c.level >= root->c.level); + return b == root; +} + const char *bch2_btree_id_str(enum btree_id); /* avoid */ void bch2_btree_id_to_text(struct printbuf *, enum btree_id); void bch2_btree_id_level_to_text(struct printbuf *, enum btree_id, unsigned); @@ -153,4 +162,15 @@ void bch2_btree_pos_to_text(struct printbuf *, struct bch_fs *, const struct btr void bch2_btree_node_to_text(struct printbuf *, struct bch_fs *, const struct btree *); void bch2_btree_cache_to_text(struct printbuf *, const struct btree_cache *); +#define trace_btree_node(_c, _b, event) \ +do { \ + if (trace_##event##_enabled()) { \ + CLASS(printbuf, buf)(); \ + printbuf_indent_add(&buf, 2); \ + bch2_btree_pos_to_text(&buf, c, b); \ + trace_##event(c, buf.buf); \ + } \ + count_event(c, event); \ +} while (0); + #endif /* _BCACHEFS_BTREE_CACHE_H */ |