debug.h 1.6 KB

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