]> git.sesse.net Git - bcachefs-tools-debian/blob - libbcachefs/debug.h
b5de1a7072d4904fcd17bbb95af792de5939b0c2
[bcachefs-tools-debian] / libbcachefs / debug.h
1 #ifndef _BCACHEFS_DEBUG_H
2 #define _BCACHEFS_DEBUG_H
3
4 #include "bcachefs.h"
5
6 struct bio;
7 struct btree;
8 struct bch_fs;
9
10 #define BCH_DEBUG_PARAM(name, description) extern bool bch2_##name;
11 BCH_DEBUG_PARAMS()
12 #undef BCH_DEBUG_PARAM
13
14 #define BCH_DEBUG_PARAM(name, description)                              \
15         static inline bool name(struct bch_fs *c)                       \
16         { return bch2_##name || c->name;        }
17 BCH_DEBUG_PARAMS_ALWAYS()
18 #undef BCH_DEBUG_PARAM
19
20 #ifdef CONFIG_BCACHEFS_DEBUG
21
22 #define BCH_DEBUG_PARAM(name, description)                              \
23         static inline bool name(struct bch_fs *c)                       \
24         { return bch2_##name || c->name;        }
25 BCH_DEBUG_PARAMS_DEBUG()
26 #undef BCH_DEBUG_PARAM
27
28 void __bch2_btree_verify(struct bch_fs *, struct btree *);
29
30 #define bypass_torture_test(d)          ((d)->bypass_torture_test)
31
32 #else /* DEBUG */
33
34 #define BCH_DEBUG_PARAM(name, description)                              \
35         static inline bool name(struct bch_fs *c) { return false; }
36 BCH_DEBUG_PARAMS_DEBUG()
37 #undef BCH_DEBUG_PARAM
38
39 static inline void __bch2_btree_verify(struct bch_fs *c, struct btree *b) {}
40
41 #define bypass_torture_test(d)          0
42
43 #endif
44
45 static inline void bch2_btree_verify(struct bch_fs *c, struct btree *b)
46 {
47         if (verify_btree_ondisk(c))
48                 __bch2_btree_verify(c, b);
49 }
50
51 #ifdef CONFIG_DEBUG_FS
52 void bch2_fs_debug_exit(struct bch_fs *);
53 void bch2_fs_debug_init(struct bch_fs *);
54 #else
55 static inline void bch2_fs_debug_exit(struct bch_fs *c) {}
56 static inline void bch2_fs_debug_init(struct bch_fs *c) {}
57 #endif
58
59 void bch2_debug_exit(void);
60 int bch2_debug_init(void);
61
62 #endif /* _BCACHEFS_DEBUG_H */