xref: /linux-6.15/drivers/md/bcache/debug.h (revision cafe5635)
1*cafe5635SKent Overstreet #ifndef _BCACHE_DEBUG_H
2*cafe5635SKent Overstreet #define _BCACHE_DEBUG_H
3*cafe5635SKent Overstreet 
4*cafe5635SKent Overstreet /* Btree/bkey debug printing */
5*cafe5635SKent Overstreet 
6*cafe5635SKent Overstreet #define KEYHACK_SIZE 80
7*cafe5635SKent Overstreet struct keyprint_hack {
8*cafe5635SKent Overstreet 	char s[KEYHACK_SIZE];
9*cafe5635SKent Overstreet };
10*cafe5635SKent Overstreet 
11*cafe5635SKent Overstreet struct keyprint_hack bch_pkey(const struct bkey *k);
12*cafe5635SKent Overstreet struct keyprint_hack bch_pbtree(const struct btree *b);
13*cafe5635SKent Overstreet #define pkey(k)		(&bch_pkey(k).s[0])
14*cafe5635SKent Overstreet #define pbtree(b)	(&bch_pbtree(b).s[0])
15*cafe5635SKent Overstreet 
16*cafe5635SKent Overstreet #ifdef CONFIG_BCACHE_EDEBUG
17*cafe5635SKent Overstreet 
18*cafe5635SKent Overstreet unsigned bch_count_data(struct btree *);
19*cafe5635SKent Overstreet void bch_check_key_order_msg(struct btree *, struct bset *, const char *, ...);
20*cafe5635SKent Overstreet void bch_check_keys(struct btree *, const char *, ...);
21*cafe5635SKent Overstreet 
22*cafe5635SKent Overstreet #define bch_check_key_order(b, i)			\
23*cafe5635SKent Overstreet 	bch_check_key_order_msg(b, i, "keys out of order")
24*cafe5635SKent Overstreet #define EBUG_ON(cond)		BUG_ON(cond)
25*cafe5635SKent Overstreet 
26*cafe5635SKent Overstreet #else /* EDEBUG */
27*cafe5635SKent Overstreet 
28*cafe5635SKent Overstreet #define bch_count_data(b)				0
29*cafe5635SKent Overstreet #define bch_check_key_order(b, i)			do {} while (0)
30*cafe5635SKent Overstreet #define bch_check_key_order_msg(b, i, ...)		do {} while (0)
31*cafe5635SKent Overstreet #define bch_check_keys(b, ...)				do {} while (0)
32*cafe5635SKent Overstreet #define EBUG_ON(cond)					do {} while (0)
33*cafe5635SKent Overstreet 
34*cafe5635SKent Overstreet #endif
35*cafe5635SKent Overstreet 
36*cafe5635SKent Overstreet #ifdef CONFIG_BCACHE_DEBUG
37*cafe5635SKent Overstreet 
38*cafe5635SKent Overstreet void bch_btree_verify(struct btree *, struct bset *);
39*cafe5635SKent Overstreet void bch_data_verify(struct search *);
40*cafe5635SKent Overstreet 
41*cafe5635SKent Overstreet #else /* DEBUG */
42*cafe5635SKent Overstreet 
43*cafe5635SKent Overstreet static inline void bch_btree_verify(struct btree *b, struct bset *i) {}
44*cafe5635SKent Overstreet static inline void bch_data_verify(struct search *s) {};
45*cafe5635SKent Overstreet 
46*cafe5635SKent Overstreet #endif
47*cafe5635SKent Overstreet 
48*cafe5635SKent Overstreet #ifdef CONFIG_DEBUG_FS
49*cafe5635SKent Overstreet void bch_debug_init_cache_set(struct cache_set *);
50*cafe5635SKent Overstreet #else
51*cafe5635SKent Overstreet static inline void bch_debug_init_cache_set(struct cache_set *c) {}
52*cafe5635SKent Overstreet #endif
53*cafe5635SKent Overstreet 
54*cafe5635SKent Overstreet #endif
55