]> git.sesse.net Git - bcachefs-tools-debian/blob - libbcache/debug.h
bcache in userspace; userspace fsck
[bcachefs-tools-debian] / libbcache / debug.h
1 #ifndef _BCACHE_DEBUG_H
2 #define _BCACHE_DEBUG_H
3
4 #include "bcache.h"
5
6 struct bio;
7 struct btree;
8 struct cached_dev;
9 struct cache_set;
10
11 #define BCH_DEBUG_PARAM(name, description) extern bool bch_##name;
12 BCH_DEBUG_PARAMS()
13 #undef BCH_DEBUG_PARAM
14
15 #define BCH_DEBUG_PARAM(name, description)                              \
16         static inline bool name(struct cache_set *c)                    \
17         { return bch_##name || c->name; }
18 BCH_DEBUG_PARAMS_ALWAYS()
19 #undef BCH_DEBUG_PARAM
20
21 #ifdef CONFIG_BCACHE_DEBUG
22
23 #define BCH_DEBUG_PARAM(name, description)                              \
24         static inline bool name(struct cache_set *c)                    \
25         { return bch_##name || c->name; }
26 BCH_DEBUG_PARAMS_DEBUG()
27 #undef BCH_DEBUG_PARAM
28
29 void __bch_btree_verify(struct cache_set *, struct btree *);
30 void bch_data_verify(struct cached_dev *, struct bio *);
31
32 #define bypass_torture_test(d)          ((d)->bypass_torture_test)
33
34 #else /* DEBUG */
35
36 #define BCH_DEBUG_PARAM(name, description)                              \
37         static inline bool name(struct cache_set *c) { return false; }
38 BCH_DEBUG_PARAMS_DEBUG()
39 #undef BCH_DEBUG_PARAM
40
41 static inline void __bch_btree_verify(struct cache_set *c, struct btree *b) {}
42 static inline void bch_data_verify(struct cached_dev *dc, struct bio *bio) {}
43
44 #define bypass_torture_test(d)          0
45
46 #endif
47
48 static inline void bch_btree_verify(struct cache_set *c, struct btree *b)
49 {
50         if (verify_btree_ondisk(c))
51                 __bch_btree_verify(c, b);
52 }
53
54 #ifdef CONFIG_DEBUG_FS
55 void bch_debug_exit_cache_set(struct cache_set *);
56 void bch_debug_init_cache_set(struct cache_set *);
57 #else
58 static inline void bch_debug_exit_cache_set(struct cache_set *c) {}
59 static inline void bch_debug_init_cache_set(struct cache_set *c) {}
60 #endif
61
62 void bch_debug_exit(void);
63 int bch_debug_init(void);
64
65 #endif