diff options
author | Kent Overstreet <kmo@daterainc.com> | 2013-10-24 19:36:03 -0400 |
---|---|---|
committer | Kent Overstreet <kmo@daterainc.com> | 2013-11-11 00:56:34 -0500 |
commit | 280481d06c8a683d9aaa26125476222e76b733c5 (patch) | |
tree | 513b7387da60b3d497a108335f743369106eb7a3 /drivers/md/bcache/debug.h | |
parent | e58ff155034791ed3a5563d24a50fae0a8c1617c (diff) |
bcache: Debug code improvements
Couple changes:
* Consolidate bch_check_keys() and bch_check_key_order(), and move the
checks that only check_key_order() could do to bch_btree_iter_next().
* Get rid of CONFIG_BCACHE_EDEBUG - now, all that code is compiled in
when CONFIG_BCACHE_DEBUG is enabled, and there's now a sysfs file to
flip on the EDEBUG checks at runtime.
* Dropped an old not terribly useful check in rw_unlock(), and
refactored/improved a some of the other debug code.
Signed-off-by: Kent Overstreet <kmo@daterainc.com>
Diffstat (limited to 'drivers/md/bcache/debug.h')
-rw-r--r-- | drivers/md/bcache/debug.h | 46 |
1 files changed, 24 insertions, 22 deletions
diff --git a/drivers/md/bcache/debug.h b/drivers/md/bcache/debug.h index 0f4b3440512c..7914ba0ff316 100644 --- a/drivers/md/bcache/debug.h +++ b/drivers/md/bcache/debug.h | |||
@@ -4,40 +4,42 @@ | |||
4 | /* Btree/bkey debug printing */ | 4 | /* Btree/bkey debug printing */ |
5 | 5 | ||
6 | int bch_bkey_to_text(char *buf, size_t size, const struct bkey *k); | 6 | int bch_bkey_to_text(char *buf, size_t size, const struct bkey *k); |
7 | int bch_btree_to_text(char *buf, size_t size, const struct btree *b); | ||
8 | |||
9 | #ifdef CONFIG_BCACHE_EDEBUG | ||
10 | |||
11 | unsigned bch_count_data(struct btree *); | ||
12 | void bch_check_key_order_msg(struct btree *, struct bset *, const char *, ...); | ||
13 | void bch_check_keys(struct btree *, const char *, ...); | ||
14 | |||
15 | #define bch_check_key_order(b, i) \ | ||
16 | bch_check_key_order_msg(b, i, "keys out of order") | ||
17 | #define EBUG_ON(cond) BUG_ON(cond) | ||
18 | |||
19 | #else /* EDEBUG */ | ||
20 | |||
21 | #define bch_count_data(b) 0 | ||
22 | #define bch_check_key_order(b, i) do {} while (0) | ||
23 | #define bch_check_key_order_msg(b, i, ...) do {} while (0) | ||
24 | #define bch_check_keys(b, ...) do {} while (0) | ||
25 | #define EBUG_ON(cond) do {} while (0) | ||
26 | |||
27 | #endif | ||
28 | 7 | ||
29 | #ifdef CONFIG_BCACHE_DEBUG | 8 | #ifdef CONFIG_BCACHE_DEBUG |
30 | 9 | ||
31 | void bch_btree_verify(struct btree *, struct bset *); | 10 | void bch_btree_verify(struct btree *, struct bset *); |
32 | void bch_data_verify(struct cached_dev *, struct bio *); | 11 | void bch_data_verify(struct cached_dev *, struct bio *); |
12 | int __bch_count_data(struct btree *); | ||
13 | void __bch_check_keys(struct btree *, const char *, ...); | ||
14 | void bch_btree_iter_next_check(struct btree_iter *); | ||
15 | |||
16 | #define EBUG_ON(cond) BUG_ON(cond) | ||
17 | #define expensive_debug_checks(c) ((c)->expensive_debug_checks) | ||
18 | #define key_merging_disabled(c) ((c)->key_merging_disabled) | ||
33 | 19 | ||
34 | #else /* DEBUG */ | 20 | #else /* DEBUG */ |
35 | 21 | ||
36 | static inline void bch_btree_verify(struct btree *b, struct bset *i) {} | 22 | static inline void bch_btree_verify(struct btree *b, struct bset *i) {} |
37 | static inline void bch_data_verify(struct cached_dev *dc, struct bio *bio) {}; | 23 | static inline void bch_data_verify(struct cached_dev *dc, struct bio *bio) {} |
24 | static inline int __bch_count_data(struct btree *b) { return -1; } | ||
25 | static inline void __bch_check_keys(struct btree *b, const char *fmt, ...) {} | ||
26 | static inline void bch_btree_iter_next_check(struct btree_iter *iter) {} | ||
27 | |||
28 | #define EBUG_ON(cond) do { if (cond); } while (0) | ||
29 | #define expensive_debug_checks(c) 0 | ||
30 | #define key_merging_disabled(c) 0 | ||
38 | 31 | ||
39 | #endif | 32 | #endif |
40 | 33 | ||
34 | #define bch_count_data(b) \ | ||
35 | (expensive_debug_checks((b)->c) ? __bch_count_data(b) : -1) | ||
36 | |||
37 | #define bch_check_keys(b, ...) \ | ||
38 | do { \ | ||
39 | if (expensive_debug_checks((b)->c)) \ | ||
40 | __bch_check_keys(b, __VA_ARGS__); \ | ||
41 | } while (0) | ||
42 | |||
41 | #ifdef CONFIG_DEBUG_FS | 43 | #ifdef CONFIG_DEBUG_FS |
42 | void bch_debug_init_cache_set(struct cache_set *); | 44 | void bch_debug_init_cache_set(struct cache_set *); |
43 | #else | 45 | #else |