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 *); 12280481d0SKent Overstreet int __bch_count_data(struct btree *); 13280481d0SKent Overstreet void __bch_check_keys(struct btree *, const char *, ...); 14280481d0SKent Overstreet void bch_btree_iter_next_check(struct btree_iter *); 15280481d0SKent Overstreet 16280481d0SKent Overstreet #define EBUG_ON(cond) BUG_ON(cond) 17280481d0SKent Overstreet #define expensive_debug_checks(c) ((c)->expensive_debug_checks) 18280481d0SKent Overstreet #define key_merging_disabled(c) ((c)->key_merging_disabled) 19*5ceaaad7SKent Overstreet #define bypass_torture_test(d) ((d)->bypass_torture_test) 20cafe5635SKent Overstreet 21cafe5635SKent Overstreet #else /* DEBUG */ 22cafe5635SKent Overstreet 23cafe5635SKent Overstreet static inline void bch_btree_verify(struct btree *b, struct bset *i) {} 24280481d0SKent Overstreet static inline void bch_data_verify(struct cached_dev *dc, struct bio *bio) {} 25280481d0SKent Overstreet static inline int __bch_count_data(struct btree *b) { return -1; } 26280481d0SKent Overstreet static inline void __bch_check_keys(struct btree *b, const char *fmt, ...) {} 27280481d0SKent Overstreet static inline void bch_btree_iter_next_check(struct btree_iter *iter) {} 28280481d0SKent Overstreet 29280481d0SKent Overstreet #define EBUG_ON(cond) do { if (cond); } while (0) 30280481d0SKent Overstreet #define expensive_debug_checks(c) 0 31280481d0SKent Overstreet #define key_merging_disabled(c) 0 32*5ceaaad7SKent Overstreet #define bypass_torture_test(d) 0 33cafe5635SKent Overstreet 34cafe5635SKent Overstreet #endif 35cafe5635SKent Overstreet 36280481d0SKent Overstreet #define bch_count_data(b) \ 37280481d0SKent Overstreet (expensive_debug_checks((b)->c) ? __bch_count_data(b) : -1) 38280481d0SKent Overstreet 39280481d0SKent Overstreet #define bch_check_keys(b, ...) \ 40280481d0SKent Overstreet do { \ 41280481d0SKent Overstreet if (expensive_debug_checks((b)->c)) \ 42280481d0SKent Overstreet __bch_check_keys(b, __VA_ARGS__); \ 43280481d0SKent Overstreet } while (0) 44280481d0SKent Overstreet 45cafe5635SKent Overstreet #ifdef CONFIG_DEBUG_FS 46cafe5635SKent Overstreet void bch_debug_init_cache_set(struct cache_set *); 47cafe5635SKent Overstreet #else 48cafe5635SKent Overstreet static inline void bch_debug_init_cache_set(struct cache_set *c) {} 49cafe5635SKent Overstreet #endif 50cafe5635SKent Overstreet 51cafe5635SKent Overstreet #endif 52