diff options
Diffstat (limited to 'fs/jffs2/debug.h')
-rw-r--r-- | fs/jffs2/debug.h | 279 |
1 files changed, 279 insertions, 0 deletions
diff --git a/fs/jffs2/debug.h b/fs/jffs2/debug.h new file mode 100644 index 000000000000..f193d43a8a59 --- /dev/null +++ b/fs/jffs2/debug.h | |||
@@ -0,0 +1,279 @@ | |||
1 | /* | ||
2 | * JFFS2 -- Journalling Flash File System, Version 2. | ||
3 | * | ||
4 | * Copyright (C) 2001-2003 Red Hat, Inc. | ||
5 | * | ||
6 | * Created by David Woodhouse <dwmw2@infradead.org> | ||
7 | * | ||
8 | * For licensing information, see the file 'LICENCE' in this directory. | ||
9 | * | ||
10 | * $Id: debug.h,v 1.21 2005/11/07 11:14:39 gleixner Exp $ | ||
11 | * | ||
12 | */ | ||
13 | #ifndef _JFFS2_DEBUG_H_ | ||
14 | #define _JFFS2_DEBUG_H_ | ||
15 | |||
16 | #include <linux/config.h> | ||
17 | |||
18 | #ifndef CONFIG_JFFS2_FS_DEBUG | ||
19 | #define CONFIG_JFFS2_FS_DEBUG 0 | ||
20 | #endif | ||
21 | |||
22 | #if CONFIG_JFFS2_FS_DEBUG > 0 | ||
23 | /* Enable "paranoia" checks and dumps */ | ||
24 | #define JFFS2_DBG_PARANOIA_CHECKS | ||
25 | #define JFFS2_DBG_DUMPS | ||
26 | |||
27 | /* | ||
28 | * By defining/undefining the below macros one may select debugging messages | ||
29 | * fro specific JFFS2 subsystems. | ||
30 | */ | ||
31 | #define JFFS2_DBG_READINODE_MESSAGES | ||
32 | #define JFFS2_DBG_FRAGTREE_MESSAGES | ||
33 | #define JFFS2_DBG_DENTLIST_MESSAGES | ||
34 | #define JFFS2_DBG_NODEREF_MESSAGES | ||
35 | #define JFFS2_DBG_INOCACHE_MESSAGES | ||
36 | #define JFFS2_DBG_SUMMARY_MESSAGES | ||
37 | #define JFFS2_DBG_FSBUILD_MESSAGES | ||
38 | #endif | ||
39 | |||
40 | #if CONFIG_JFFS2_FS_DEBUG > 1 | ||
41 | #define JFFS2_DBG_FRAGTREE2_MESSAGES | ||
42 | #define JFFS2_DBG_MEMALLOC_MESSAGES | ||
43 | #endif | ||
44 | |||
45 | /* Sanity checks are supposed to be light-weight and enabled by default */ | ||
46 | #define JFFS2_DBG_SANITY_CHECKS | ||
47 | |||
48 | /* | ||
49 | * Dx() are mainly used for debugging messages, they must go away and be | ||
50 | * superseded by nicer dbg_xxx() macros... | ||
51 | */ | ||
52 | #if CONFIG_JFFS2_FS_DEBUG > 0 | ||
53 | #define D1(x) x | ||
54 | #else | ||
55 | #define D1(x) | ||
56 | #endif | ||
57 | |||
58 | #if CONFIG_JFFS2_FS_DEBUG > 1 | ||
59 | #define D2(x) x | ||
60 | #else | ||
61 | #define D2(x) | ||
62 | #endif | ||
63 | |||
64 | /* The prefixes of JFFS2 messages */ | ||
65 | #define JFFS2_DBG_PREFIX "[JFFS2 DBG]" | ||
66 | #define JFFS2_ERR_PREFIX "JFFS2 error:" | ||
67 | #define JFFS2_WARN_PREFIX "JFFS2 warning:" | ||
68 | #define JFFS2_NOTICE_PREFIX "JFFS2 notice:" | ||
69 | |||
70 | #define JFFS2_ERR KERN_ERR | ||
71 | #define JFFS2_WARN KERN_WARNING | ||
72 | #define JFFS2_NOT KERN_NOTICE | ||
73 | #define JFFS2_DBG KERN_DEBUG | ||
74 | |||
75 | #define JFFS2_DBG_MSG_PREFIX JFFS2_DBG JFFS2_DBG_PREFIX | ||
76 | #define JFFS2_ERR_MSG_PREFIX JFFS2_ERR JFFS2_ERR_PREFIX | ||
77 | #define JFFS2_WARN_MSG_PREFIX JFFS2_WARN JFFS2_WARN_PREFIX | ||
78 | #define JFFS2_NOTICE_MSG_PREFIX JFFS2_NOT JFFS2_NOTICE_PREFIX | ||
79 | |||
80 | /* JFFS2 message macros */ | ||
81 | #define JFFS2_ERROR(fmt, ...) \ | ||
82 | do { \ | ||
83 | printk(JFFS2_ERR_MSG_PREFIX \ | ||
84 | " (%d) %s: " fmt, current->pid, \ | ||
85 | __FUNCTION__, ##__VA_ARGS__); \ | ||
86 | } while(0) | ||
87 | |||
88 | #define JFFS2_WARNING(fmt, ...) \ | ||
89 | do { \ | ||
90 | printk(JFFS2_WARN_MSG_PREFIX \ | ||
91 | " (%d) %s: " fmt, current->pid, \ | ||
92 | __FUNCTION__, ##__VA_ARGS__); \ | ||
93 | } while(0) | ||
94 | |||
95 | #define JFFS2_NOTICE(fmt, ...) \ | ||
96 | do { \ | ||
97 | printk(JFFS2_NOTICE_MSG_PREFIX \ | ||
98 | " (%d) %s: " fmt, current->pid, \ | ||
99 | __FUNCTION__, ##__VA_ARGS__); \ | ||
100 | } while(0) | ||
101 | |||
102 | #define JFFS2_DEBUG(fmt, ...) \ | ||
103 | do { \ | ||
104 | printk(JFFS2_DBG_MSG_PREFIX \ | ||
105 | " (%d) %s: " fmt, current->pid, \ | ||
106 | __FUNCTION__, ##__VA_ARGS__); \ | ||
107 | } while(0) | ||
108 | |||
109 | /* | ||
110 | * We split our debugging messages on several parts, depending on the JFFS2 | ||
111 | * subsystem the message belongs to. | ||
112 | */ | ||
113 | /* Read inode debugging messages */ | ||
114 | #ifdef JFFS2_DBG_READINODE_MESSAGES | ||
115 | #define dbg_readinode(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__) | ||
116 | #else | ||
117 | #define dbg_readinode(fmt, ...) | ||
118 | #endif | ||
119 | |||
120 | /* Fragtree build debugging messages */ | ||
121 | #ifdef JFFS2_DBG_FRAGTREE_MESSAGES | ||
122 | #define dbg_fragtree(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__) | ||
123 | #else | ||
124 | #define dbg_fragtree(fmt, ...) | ||
125 | #endif | ||
126 | #ifdef JFFS2_DBG_FRAGTREE2_MESSAGES | ||
127 | #define dbg_fragtree2(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__) | ||
128 | #else | ||
129 | #define dbg_fragtree2(fmt, ...) | ||
130 | #endif | ||
131 | |||
132 | /* Directory entry list manilulation debugging messages */ | ||
133 | #ifdef JFFS2_DBG_DENTLIST_MESSAGES | ||
134 | #define dbg_dentlist(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__) | ||
135 | #else | ||
136 | #define dbg_dentlist(fmt, ...) | ||
137 | #endif | ||
138 | |||
139 | /* Print the messages about manipulating node_refs */ | ||
140 | #ifdef JFFS2_DBG_NODEREF_MESSAGES | ||
141 | #define dbg_noderef(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__) | ||
142 | #else | ||
143 | #define dbg_noderef(fmt, ...) | ||
144 | #endif | ||
145 | |||
146 | /* Manipulations with the list of inodes (JFFS2 inocache) */ | ||
147 | #ifdef JFFS2_DBG_INOCACHE_MESSAGES | ||
148 | #define dbg_inocache(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__) | ||
149 | #else | ||
150 | #define dbg_inocache(fmt, ...) | ||
151 | #endif | ||
152 | |||
153 | /* Summary debugging messages */ | ||
154 | #ifdef JFFS2_DBG_SUMMARY_MESSAGES | ||
155 | #define dbg_summary(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__) | ||
156 | #else | ||
157 | #define dbg_summary(fmt, ...) | ||
158 | #endif | ||
159 | |||
160 | /* File system build messages */ | ||
161 | #ifdef JFFS2_DBG_FSBUILD_MESSAGES | ||
162 | #define dbg_fsbuild(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__) | ||
163 | #else | ||
164 | #define dbg_fsbuild(fmt, ...) | ||
165 | #endif | ||
166 | |||
167 | /* Watch the object allocations */ | ||
168 | #ifdef JFFS2_DBG_MEMALLOC_MESSAGES | ||
169 | #define dbg_memalloc(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__) | ||
170 | #else | ||
171 | #define dbg_memalloc(fmt, ...) | ||
172 | #endif | ||
173 | |||
174 | |||
175 | /* "Sanity" checks */ | ||
176 | void | ||
177 | __jffs2_dbg_acct_sanity_check_nolock(struct jffs2_sb_info *c, | ||
178 | struct jffs2_eraseblock *jeb); | ||
179 | void | ||
180 | __jffs2_dbg_acct_sanity_check(struct jffs2_sb_info *c, | ||
181 | struct jffs2_eraseblock *jeb); | ||
182 | |||
183 | /* "Paranoia" checks */ | ||
184 | void | ||
185 | __jffs2_dbg_fragtree_paranoia_check(struct jffs2_inode_info *f); | ||
186 | void | ||
187 | __jffs2_dbg_fragtree_paranoia_check_nolock(struct jffs2_inode_info *f); | ||
188 | void | ||
189 | __jffs2_dbg_acct_paranoia_check(struct jffs2_sb_info *c, | ||
190 | struct jffs2_eraseblock *jeb); | ||
191 | void | ||
192 | __jffs2_dbg_acct_paranoia_check_nolock(struct jffs2_sb_info *c, | ||
193 | struct jffs2_eraseblock *jeb); | ||
194 | void | ||
195 | __jffs2_dbg_prewrite_paranoia_check(struct jffs2_sb_info *c, | ||
196 | uint32_t ofs, int len); | ||
197 | |||
198 | /* "Dump" functions */ | ||
199 | void | ||
200 | __jffs2_dbg_dump_jeb(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb); | ||
201 | void | ||
202 | __jffs2_dbg_dump_jeb_nolock(struct jffs2_eraseblock *jeb); | ||
203 | void | ||
204 | __jffs2_dbg_dump_block_lists(struct jffs2_sb_info *c); | ||
205 | void | ||
206 | __jffs2_dbg_dump_block_lists_nolock(struct jffs2_sb_info *c); | ||
207 | void | ||
208 | __jffs2_dbg_dump_node_refs(struct jffs2_sb_info *c, | ||
209 | struct jffs2_eraseblock *jeb); | ||
210 | void | ||
211 | __jffs2_dbg_dump_node_refs_nolock(struct jffs2_sb_info *c, | ||
212 | struct jffs2_eraseblock *jeb); | ||
213 | void | ||
214 | __jffs2_dbg_dump_fragtree(struct jffs2_inode_info *f); | ||
215 | void | ||
216 | __jffs2_dbg_dump_fragtree_nolock(struct jffs2_inode_info *f); | ||
217 | void | ||
218 | __jffs2_dbg_dump_buffer(unsigned char *buf, int len, uint32_t offs); | ||
219 | void | ||
220 | __jffs2_dbg_dump_node(struct jffs2_sb_info *c, uint32_t ofs); | ||
221 | |||
222 | #ifdef JFFS2_DBG_PARANOIA_CHECKS | ||
223 | #define jffs2_dbg_fragtree_paranoia_check(f) \ | ||
224 | __jffs2_dbg_fragtree_paranoia_check(f) | ||
225 | #define jffs2_dbg_fragtree_paranoia_check_nolock(f) \ | ||
226 | __jffs2_dbg_fragtree_paranoia_check_nolock(f) | ||
227 | #define jffs2_dbg_acct_paranoia_check(c, jeb) \ | ||
228 | __jffs2_dbg_acct_paranoia_check(c,jeb) | ||
229 | #define jffs2_dbg_acct_paranoia_check_nolock(c, jeb) \ | ||
230 | __jffs2_dbg_acct_paranoia_check_nolock(c,jeb) | ||
231 | #define jffs2_dbg_prewrite_paranoia_check(c, ofs, len) \ | ||
232 | __jffs2_dbg_prewrite_paranoia_check(c, ofs, len) | ||
233 | #else | ||
234 | #define jffs2_dbg_fragtree_paranoia_check(f) | ||
235 | #define jffs2_dbg_fragtree_paranoia_check_nolock(f) | ||
236 | #define jffs2_dbg_acct_paranoia_check(c, jeb) | ||
237 | #define jffs2_dbg_acct_paranoia_check_nolock(c, jeb) | ||
238 | #define jffs2_dbg_prewrite_paranoia_check(c, ofs, len) | ||
239 | #endif /* !JFFS2_PARANOIA_CHECKS */ | ||
240 | |||
241 | #ifdef JFFS2_DBG_DUMPS | ||
242 | #define jffs2_dbg_dump_jeb(c, jeb) \ | ||
243 | __jffs2_dbg_dump_jeb(c, jeb); | ||
244 | #define jffs2_dbg_dump_jeb_nolock(jeb) \ | ||
245 | __jffs2_dbg_dump_jeb_nolock(jeb); | ||
246 | #define jffs2_dbg_dump_block_lists(c) \ | ||
247 | __jffs2_dbg_dump_block_lists(c) | ||
248 | #define jffs2_dbg_dump_block_lists_nolock(c) \ | ||
249 | __jffs2_dbg_dump_block_lists_nolock(c) | ||
250 | #define jffs2_dbg_dump_fragtree(f) \ | ||
251 | __jffs2_dbg_dump_fragtree(f); | ||
252 | #define jffs2_dbg_dump_fragtree_nolock(f) \ | ||
253 | __jffs2_dbg_dump_fragtree_nolock(f); | ||
254 | #define jffs2_dbg_dump_buffer(buf, len, offs) \ | ||
255 | __jffs2_dbg_dump_buffer(*buf, len, offs); | ||
256 | #define jffs2_dbg_dump_node(c, ofs) \ | ||
257 | __jffs2_dbg_dump_node(c, ofs); | ||
258 | #else | ||
259 | #define jffs2_dbg_dump_jeb(c, jeb) | ||
260 | #define jffs2_dbg_dump_jeb_nolock(jeb) | ||
261 | #define jffs2_dbg_dump_block_lists(c) | ||
262 | #define jffs2_dbg_dump_block_lists_nolock(c) | ||
263 | #define jffs2_dbg_dump_fragtree(f) | ||
264 | #define jffs2_dbg_dump_fragtree_nolock(f) | ||
265 | #define jffs2_dbg_dump_buffer(buf, len, offs) | ||
266 | #define jffs2_dbg_dump_node(c, ofs) | ||
267 | #endif /* !JFFS2_DBG_DUMPS */ | ||
268 | |||
269 | #ifdef JFFS2_DBG_SANITY_CHECKS | ||
270 | #define jffs2_dbg_acct_sanity_check(c, jeb) \ | ||
271 | __jffs2_dbg_acct_sanity_check(c, jeb) | ||
272 | #define jffs2_dbg_acct_sanity_check_nolock(c, jeb) \ | ||
273 | __jffs2_dbg_acct_sanity_check_nolock(c, jeb) | ||
274 | #else | ||
275 | #define jffs2_dbg_acct_sanity_check(c, jeb) | ||
276 | #define jffs2_dbg_acct_sanity_check_nolock(c, jeb) | ||
277 | #endif /* !JFFS2_DBG_SANITY_CHECKS */ | ||
278 | |||
279 | #endif /* _JFFS2_DEBUG_H_ */ | ||