Commit | Line | Data |
---|---|---|
cafe5635 KO |
1 | #ifndef _BCACHE_DEBUG_H |
2 | #define _BCACHE_DEBUG_H | |
3 | ||
4 | /* Btree/bkey debug printing */ | |
5 | ||
85b1492e | 6 | int bch_bkey_to_text(char *buf, size_t size, const struct bkey *k); |
cafe5635 KO |
7 | |
8 | #ifdef CONFIG_BCACHE_DEBUG | |
9 | ||
10 | void bch_btree_verify(struct btree *, struct bset *); | |
220bb38c | 11 | void bch_data_verify(struct cached_dev *, struct bio *); |
280481d0 KO |
12 | int __bch_count_data(struct btree *); |
13 | void __bch_check_keys(struct btree *, const char *, ...); | |
14 | void bch_btree_iter_next_check(struct btree_iter *); | |
15 | ||
16 | #define EBUG_ON(cond) BUG_ON(cond) | |
17 | #define expensive_debug_checks(c) ((c)->expensive_debug_checks) | |
18 | #define key_merging_disabled(c) ((c)->key_merging_disabled) | |
5ceaaad7 | 19 | #define bypass_torture_test(d) ((d)->bypass_torture_test) |
cafe5635 KO |
20 | |
21 | #else /* DEBUG */ | |
22 | ||
23 | static inline void bch_btree_verify(struct btree *b, struct bset *i) {} | |
280481d0 KO |
24 | static inline void bch_data_verify(struct cached_dev *dc, struct bio *bio) {} |
25 | static inline int __bch_count_data(struct btree *b) { return -1; } | |
26 | static inline void __bch_check_keys(struct btree *b, const char *fmt, ...) {} | |
27 | static inline void bch_btree_iter_next_check(struct btree_iter *iter) {} | |
28 | ||
29 | #define EBUG_ON(cond) do { if (cond); } while (0) | |
30 | #define expensive_debug_checks(c) 0 | |
31 | #define key_merging_disabled(c) 0 | |
5ceaaad7 | 32 | #define bypass_torture_test(d) 0 |
cafe5635 KO |
33 | |
34 | #endif | |
35 | ||
280481d0 KO |
36 | #define bch_count_data(b) \ |
37 | (expensive_debug_checks((b)->c) ? __bch_count_data(b) : -1) | |
38 | ||
39 | #define bch_check_keys(b, ...) \ | |
40 | do { \ | |
41 | if (expensive_debug_checks((b)->c)) \ | |
42 | __bch_check_keys(b, __VA_ARGS__); \ | |
43 | } while (0) | |
44 | ||
cafe5635 KO |
45 | #ifdef CONFIG_DEBUG_FS |
46 | void bch_debug_init_cache_set(struct cache_set *); | |
47 | #else | |
48 | static inline void bch_debug_init_cache_set(struct cache_set *c) {} | |
49 | #endif | |
50 | ||
51 | #endif |