Kent Overstreet | cafe563 | 2013-03-23 16:11:31 -0700 | [diff] [blame] | 1 | #ifndef _BCACHE_DEBUG_H |
| 2 | #define _BCACHE_DEBUG_H |
| 3 | |
| 4 | /* Btree/bkey debug printing */ |
| 5 | |
Kent Overstreet | 85b1492 | 2013-05-14 20:33:16 -0700 | [diff] [blame] | 6 | int bch_bkey_to_text(char *buf, size_t size, const struct bkey *k); |
Kent Overstreet | cafe563 | 2013-03-23 16:11:31 -0700 | [diff] [blame] | 7 | |
| 8 | #ifdef CONFIG_BCACHE_DEBUG |
| 9 | |
| 10 | void bch_btree_verify(struct btree *, struct bset *); |
Kent Overstreet | 220bb38 | 2013-09-10 19:02:45 -0700 | [diff] [blame] | 11 | void bch_data_verify(struct cached_dev *, struct bio *); |
Kent Overstreet | 280481d | 2013-10-24 16:36:03 -0700 | [diff] [blame^] | 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) |
Kent Overstreet | cafe563 | 2013-03-23 16:11:31 -0700 | [diff] [blame] | 19 | |
| 20 | #else /* DEBUG */ |
| 21 | |
| 22 | static inline void bch_btree_verify(struct btree *b, struct bset *i) {} |
Kent Overstreet | 280481d | 2013-10-24 16:36:03 -0700 | [diff] [blame^] | 23 | static inline void bch_data_verify(struct cached_dev *dc, struct bio *bio) {} |
| 24 | static inline int __bch_count_data(struct btree *b) { return -1; } |
| 25 | static inline void __bch_check_keys(struct btree *b, const char *fmt, ...) {} |
| 26 | static inline void bch_btree_iter_next_check(struct btree_iter *iter) {} |
| 27 | |
| 28 | #define EBUG_ON(cond) do { if (cond); } while (0) |
| 29 | #define expensive_debug_checks(c) 0 |
| 30 | #define key_merging_disabled(c) 0 |
Kent Overstreet | cafe563 | 2013-03-23 16:11:31 -0700 | [diff] [blame] | 31 | |
| 32 | #endif |
| 33 | |
Kent Overstreet | 280481d | 2013-10-24 16:36:03 -0700 | [diff] [blame^] | 34 | #define bch_count_data(b) \ |
| 35 | (expensive_debug_checks((b)->c) ? __bch_count_data(b) : -1) |
| 36 | |
| 37 | #define bch_check_keys(b, ...) \ |
| 38 | do { \ |
| 39 | if (expensive_debug_checks((b)->c)) \ |
| 40 | __bch_check_keys(b, __VA_ARGS__); \ |
| 41 | } while (0) |
| 42 | |
Kent Overstreet | cafe563 | 2013-03-23 16:11:31 -0700 | [diff] [blame] | 43 | #ifdef CONFIG_DEBUG_FS |
| 44 | void bch_debug_init_cache_set(struct cache_set *); |
| 45 | #else |
| 46 | static inline void bch_debug_init_cache_set(struct cache_set *c) {} |
| 47 | #endif |
| 48 | |
| 49 | #endif |