summaryrefslogtreecommitdiff
path: root/libbcache/debug.h
blob: d34a95a023c2c231674cd59519ac943ea30c6c2f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#ifndef _BCACHE_DEBUG_H
#define _BCACHE_DEBUG_H

#include "bcache.h"

struct bio;
struct btree;
struct cached_dev;
struct cache_set;

#define BCH_DEBUG_PARAM(name, description) extern bool bch_##name;
BCH_DEBUG_PARAMS()
#undef BCH_DEBUG_PARAM

#define BCH_DEBUG_PARAM(name, description)				\
	static inline bool name(struct cache_set *c)			\
	{ return bch_##name || c->name;	}
BCH_DEBUG_PARAMS_ALWAYS()
#undef BCH_DEBUG_PARAM

#ifdef CONFIG_BCACHE_DEBUG

#define BCH_DEBUG_PARAM(name, description)				\
	static inline bool name(struct cache_set *c)			\
	{ return bch_##name || c->name;	}
BCH_DEBUG_PARAMS_DEBUG()
#undef BCH_DEBUG_PARAM

void __bch_btree_verify(struct cache_set *, struct btree *);
void bch_data_verify(struct cached_dev *, struct bio *);

#define bypass_torture_test(d)		((d)->bypass_torture_test)

#else /* DEBUG */

#define BCH_DEBUG_PARAM(name, description)				\
	static inline bool name(struct cache_set *c) { return false; }
BCH_DEBUG_PARAMS_DEBUG()
#undef BCH_DEBUG_PARAM

static inline void __bch_btree_verify(struct cache_set *c, struct btree *b) {}
static inline void bch_data_verify(struct cached_dev *dc, struct bio *bio) {}

#define bypass_torture_test(d)		0

#endif

static inline void bch_btree_verify(struct cache_set *c, struct btree *b)
{
	if (verify_btree_ondisk(c))
		__bch_btree_verify(c, b);
}

#ifdef CONFIG_DEBUG_FS
void bch_fs_debug_exit(struct cache_set *);
void bch_fs_debug_init(struct cache_set *);
#else
static inline void bch_fs_debug_exit(struct cache_set *c) {}
static inline void bch_fs_debug_init(struct cache_set *c) {}
#endif

void bch_debug_exit(void);
int bch_debug_init(void);

#endif