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