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