diff options
Diffstat (limited to 'fs/fscache/internal.h')
-rw-r--r-- | fs/fscache/internal.h | 165 |
1 files changed, 165 insertions, 0 deletions
diff --git a/fs/fscache/internal.h b/fs/fscache/internal.h new file mode 100644 index 000000000000..95dc92da7152 --- /dev/null +++ b/fs/fscache/internal.h | |||
@@ -0,0 +1,165 @@ | |||
1 | /* Internal definitions for FS-Cache | ||
2 | * | ||
3 | * Copyright (C) 2004-2007 Red Hat, Inc. All Rights Reserved. | ||
4 | * Written by David Howells (dhowells@redhat.com) | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU General Public License | ||
8 | * as published by the Free Software Foundation; either version | ||
9 | * 2 of the License, or (at your option) any later version. | ||
10 | */ | ||
11 | |||
12 | /* | ||
13 | * Lock order, in the order in which multiple locks should be obtained: | ||
14 | * - fscache_addremove_sem | ||
15 | * - cookie->lock | ||
16 | * - cookie->parent->lock | ||
17 | * - cache->object_list_lock | ||
18 | * - object->lock | ||
19 | * - object->parent->lock | ||
20 | * - fscache_thread_lock | ||
21 | * | ||
22 | */ | ||
23 | |||
24 | #include <linux/fscache-cache.h> | ||
25 | #include <linux/sched.h> | ||
26 | |||
27 | #define FSCACHE_MIN_THREADS 4 | ||
28 | #define FSCACHE_MAX_THREADS 32 | ||
29 | |||
30 | /* | ||
31 | * fsc-main.c | ||
32 | */ | ||
33 | extern unsigned fscache_defer_lookup; | ||
34 | extern unsigned fscache_defer_create; | ||
35 | extern unsigned fscache_debug; | ||
36 | extern struct kobject *fscache_root; | ||
37 | |||
38 | /*****************************************************************************/ | ||
39 | /* | ||
40 | * debug tracing | ||
41 | */ | ||
42 | #define dbgprintk(FMT, ...) \ | ||
43 | printk(KERN_DEBUG "[%-6.6s] "FMT"\n", current->comm, ##__VA_ARGS__) | ||
44 | |||
45 | /* make sure we maintain the format strings, even when debugging is disabled */ | ||
46 | static inline __attribute__((format(printf, 1, 2))) | ||
47 | void _dbprintk(const char *fmt, ...) | ||
48 | { | ||
49 | } | ||
50 | |||
51 | #define kenter(FMT, ...) dbgprintk("==> %s("FMT")", __func__, ##__VA_ARGS__) | ||
52 | #define kleave(FMT, ...) dbgprintk("<== %s()"FMT"", __func__, ##__VA_ARGS__) | ||
53 | #define kdebug(FMT, ...) dbgprintk(FMT, ##__VA_ARGS__) | ||
54 | |||
55 | #define kjournal(FMT, ...) _dbprintk(FMT, ##__VA_ARGS__) | ||
56 | |||
57 | #ifdef __KDEBUG | ||
58 | #define _enter(FMT, ...) kenter(FMT, ##__VA_ARGS__) | ||
59 | #define _leave(FMT, ...) kleave(FMT, ##__VA_ARGS__) | ||
60 | #define _debug(FMT, ...) kdebug(FMT, ##__VA_ARGS__) | ||
61 | |||
62 | #elif defined(CONFIG_FSCACHE_DEBUG) | ||
63 | #define _enter(FMT, ...) \ | ||
64 | do { \ | ||
65 | if (__do_kdebug(ENTER)) \ | ||
66 | kenter(FMT, ##__VA_ARGS__); \ | ||
67 | } while (0) | ||
68 | |||
69 | #define _leave(FMT, ...) \ | ||
70 | do { \ | ||
71 | if (__do_kdebug(LEAVE)) \ | ||
72 | kleave(FMT, ##__VA_ARGS__); \ | ||
73 | } while (0) | ||
74 | |||
75 | #define _debug(FMT, ...) \ | ||
76 | do { \ | ||
77 | if (__do_kdebug(DEBUG)) \ | ||
78 | kdebug(FMT, ##__VA_ARGS__); \ | ||
79 | } while (0) | ||
80 | |||
81 | #else | ||
82 | #define _enter(FMT, ...) _dbprintk("==> %s("FMT")", __func__, ##__VA_ARGS__) | ||
83 | #define _leave(FMT, ...) _dbprintk("<== %s()"FMT"", __func__, ##__VA_ARGS__) | ||
84 | #define _debug(FMT, ...) _dbprintk(FMT, ##__VA_ARGS__) | ||
85 | #endif | ||
86 | |||
87 | /* | ||
88 | * determine whether a particular optional debugging point should be logged | ||
89 | * - we need to go through three steps to persuade cpp to correctly join the | ||
90 | * shorthand in FSCACHE_DEBUG_LEVEL with its prefix | ||
91 | */ | ||
92 | #define ____do_kdebug(LEVEL, POINT) \ | ||
93 | unlikely((fscache_debug & \ | ||
94 | (FSCACHE_POINT_##POINT << (FSCACHE_DEBUG_ ## LEVEL * 3)))) | ||
95 | #define ___do_kdebug(LEVEL, POINT) \ | ||
96 | ____do_kdebug(LEVEL, POINT) | ||
97 | #define __do_kdebug(POINT) \ | ||
98 | ___do_kdebug(FSCACHE_DEBUG_LEVEL, POINT) | ||
99 | |||
100 | #define FSCACHE_DEBUG_CACHE 0 | ||
101 | #define FSCACHE_DEBUG_COOKIE 1 | ||
102 | #define FSCACHE_DEBUG_PAGE 2 | ||
103 | #define FSCACHE_DEBUG_OPERATION 3 | ||
104 | |||
105 | #define FSCACHE_POINT_ENTER 1 | ||
106 | #define FSCACHE_POINT_LEAVE 2 | ||
107 | #define FSCACHE_POINT_DEBUG 4 | ||
108 | |||
109 | #ifndef FSCACHE_DEBUG_LEVEL | ||
110 | #define FSCACHE_DEBUG_LEVEL CACHE | ||
111 | #endif | ||
112 | |||
113 | /* | ||
114 | * assertions | ||
115 | */ | ||
116 | #if 1 /* defined(__KDEBUGALL) */ | ||
117 | |||
118 | #define ASSERT(X) \ | ||
119 | do { \ | ||
120 | if (unlikely(!(X))) { \ | ||
121 | printk(KERN_ERR "\n"); \ | ||
122 | printk(KERN_ERR "FS-Cache: Assertion failed\n"); \ | ||
123 | BUG(); \ | ||
124 | } \ | ||
125 | } while (0) | ||
126 | |||
127 | #define ASSERTCMP(X, OP, Y) \ | ||
128 | do { \ | ||
129 | if (unlikely(!((X) OP (Y)))) { \ | ||
130 | printk(KERN_ERR "\n"); \ | ||
131 | printk(KERN_ERR "FS-Cache: Assertion failed\n"); \ | ||
132 | printk(KERN_ERR "%lx " #OP " %lx is false\n", \ | ||
133 | (unsigned long)(X), (unsigned long)(Y)); \ | ||
134 | BUG(); \ | ||
135 | } \ | ||
136 | } while (0) | ||
137 | |||
138 | #define ASSERTIF(C, X) \ | ||
139 | do { \ | ||
140 | if (unlikely((C) && !(X))) { \ | ||
141 | printk(KERN_ERR "\n"); \ | ||
142 | printk(KERN_ERR "FS-Cache: Assertion failed\n"); \ | ||
143 | BUG(); \ | ||
144 | } \ | ||
145 | } while (0) | ||
146 | |||
147 | #define ASSERTIFCMP(C, X, OP, Y) \ | ||
148 | do { \ | ||
149 | if (unlikely((C) && !((X) OP (Y)))) { \ | ||
150 | printk(KERN_ERR "\n"); \ | ||
151 | printk(KERN_ERR "FS-Cache: Assertion failed\n"); \ | ||
152 | printk(KERN_ERR "%lx " #OP " %lx is false\n", \ | ||
153 | (unsigned long)(X), (unsigned long)(Y)); \ | ||
154 | BUG(); \ | ||
155 | } \ | ||
156 | } while (0) | ||
157 | |||
158 | #else | ||
159 | |||
160 | #define ASSERT(X) do {} while (0) | ||
161 | #define ASSERTCMP(X, OP, Y) do {} while (0) | ||
162 | #define ASSERTIF(C, X) do {} while (0) | ||
163 | #define ASSERTIFCMP(C, X, OP, Y) do {} while (0) | ||
164 | |||
165 | #endif /* assert or not */ | ||