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