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/printk.h>
17 #include <linux/sched.h>
19 #ifndef CONFIG_JFFS2_FS_DEBUG
20 #define CONFIG_JFFS2_FS_DEBUG 0
23 #if CONFIG_JFFS2_FS_DEBUG > 0
24 /* Enable "paranoia" checks and dumps */
25 #define JFFS2_DBG_PARANOIA_CHECKS
26 #define JFFS2_DBG_DUMPS
29 * By defining/undefining the below macros one may select debugging messages
30 * fro specific JFFS2 subsystems.
32 #define JFFS2_DBG_READINODE_MESSAGES
33 #define JFFS2_DBG_FRAGTREE_MESSAGES
34 #define JFFS2_DBG_DENTLIST_MESSAGES
35 #define JFFS2_DBG_NODEREF_MESSAGES
36 #define JFFS2_DBG_INOCACHE_MESSAGES
37 #define JFFS2_DBG_SUMMARY_MESSAGES
38 #define JFFS2_DBG_FSBUILD_MESSAGES
41 #if CONFIG_JFFS2_FS_DEBUG > 1
42 #define JFFS2_DBG_FRAGTREE2_MESSAGES
43 #define JFFS2_DBG_READINODE2_MESSAGES
44 #define JFFS2_DBG_MEMALLOC_MESSAGES
47 /* Sanity checks are supposed to be light-weight and enabled by default */
48 #define JFFS2_DBG_SANITY_CHECKS
51 * Dx() are mainly used for debugging messages, they must go away and be
52 * superseded by nicer dbg_xxx() macros...
54 #if CONFIG_JFFS2_FS_DEBUG > 0
61 #if CONFIG_JFFS2_FS_DEBUG > 1
67 #define jffs2_dbg(level, fmt, ...) \
69 if (CONFIG_JFFS2_FS_DEBUG >= level) \
70 pr_debug(fmt, ##__VA_ARGS__); \
73 /* The prefixes of JFFS2 messages */
74 #define JFFS2_DBG KERN_DEBUG
75 #define JFFS2_DBG_PREFIX "[JFFS2 DBG]"
76 #define JFFS2_DBG_MSG_PREFIX JFFS2_DBG JFFS2_DBG_PREFIX
78 /* JFFS2 message macros */
79 #define JFFS2_ERROR(fmt, ...) \
80 pr_err("error: (%d) %s: " fmt, \
81 task_pid_nr(current), __func__, ##__VA_ARGS__)
83 #define JFFS2_WARNING(fmt, ...) \
84 pr_warn("warning: (%d) %s: " fmt, \
85 task_pid_nr(current), __func__, ##__VA_ARGS__)
87 #define JFFS2_NOTICE(fmt, ...) \
88 pr_notice("notice: (%d) %s: " fmt, \
89 task_pid_nr(current), __func__, ##__VA_ARGS__)
91 #define JFFS2_DEBUG(fmt, ...) \
92 printk(KERN_DEBUG "[JFFS2 DBG] (%d) %s: " fmt, \
93 task_pid_nr(current), __func__, ##__VA_ARGS__)
96 * We split our debugging messages on several parts, depending on the JFFS2
97 * subsystem the message belongs to.
99 /* Read inode debugging messages */
100 #ifdef JFFS2_DBG_READINODE_MESSAGES
101 #define dbg_readinode(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
103 #define dbg_readinode(fmt, ...) no_printk(fmt, ##__VA_ARGS__)
105 #ifdef JFFS2_DBG_READINODE2_MESSAGES
106 #define dbg_readinode2(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
108 #define dbg_readinode2(fmt, ...) no_printk(fmt, ##__VA_ARGS__)
111 /* Fragtree build debugging messages */
112 #ifdef JFFS2_DBG_FRAGTREE_MESSAGES
113 #define dbg_fragtree(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
115 #define dbg_fragtree(fmt, ...) no_printk(fmt, ##__VA_ARGS__)
117 #ifdef JFFS2_DBG_FRAGTREE2_MESSAGES
118 #define dbg_fragtree2(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
120 #define dbg_fragtree2(fmt, ...) no_printk(fmt, ##__VA_ARGS__)
123 /* Directory entry list manilulation debugging messages */
124 #ifdef JFFS2_DBG_DENTLIST_MESSAGES
125 #define dbg_dentlist(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
127 #define dbg_dentlist(fmt, ...) no_printk(fmt, ##__VA_ARGS__)
130 /* Print the messages about manipulating node_refs */
131 #ifdef JFFS2_DBG_NODEREF_MESSAGES
132 #define dbg_noderef(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
134 #define dbg_noderef(fmt, ...) no_printk(fmt, ##__VA_ARGS__)
137 /* Manipulations with the list of inodes (JFFS2 inocache) */
138 #ifdef JFFS2_DBG_INOCACHE_MESSAGES
139 #define dbg_inocache(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
141 #define dbg_inocache(fmt, ...) no_printk(fmt, ##__VA_ARGS__)
144 /* Summary debugging messages */
145 #ifdef JFFS2_DBG_SUMMARY_MESSAGES
146 #define dbg_summary(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
148 #define dbg_summary(fmt, ...) no_printk(fmt, ##__VA_ARGS__)
151 /* File system build messages */
152 #ifdef JFFS2_DBG_FSBUILD_MESSAGES
153 #define dbg_fsbuild(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
155 #define dbg_fsbuild(fmt, ...) no_printk(fmt, ##__VA_ARGS__)
158 /* Watch the object allocations */
159 #ifdef JFFS2_DBG_MEMALLOC_MESSAGES
160 #define dbg_memalloc(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
162 #define dbg_memalloc(fmt, ...) no_printk(fmt, ##__VA_ARGS__)
165 /* Watch the XATTR subsystem */
166 #ifdef JFFS2_DBG_XATTR_MESSAGES
167 #define dbg_xattr(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
169 #define dbg_xattr(fmt, ...) no_printk(fmt, ##__VA_ARGS__)
172 /* "Sanity" checks */
174 __jffs2_dbg_acct_sanity_check_nolock(struct jffs2_sb_info
*c
,
175 struct jffs2_eraseblock
*jeb
);
177 __jffs2_dbg_acct_sanity_check(struct jffs2_sb_info
*c
,
178 struct jffs2_eraseblock
*jeb
);
180 /* "Paranoia" checks */
182 __jffs2_dbg_fragtree_paranoia_check(struct jffs2_inode_info
*f
);
184 __jffs2_dbg_fragtree_paranoia_check_nolock(struct jffs2_inode_info
*f
);
186 __jffs2_dbg_acct_paranoia_check(struct jffs2_sb_info
*c
,
187 struct jffs2_eraseblock
*jeb
);
189 __jffs2_dbg_acct_paranoia_check_nolock(struct jffs2_sb_info
*c
,
190 struct jffs2_eraseblock
*jeb
);
192 __jffs2_dbg_prewrite_paranoia_check(struct jffs2_sb_info
*c
,
193 uint32_t ofs
, int len
);
195 /* "Dump" functions */
197 __jffs2_dbg_dump_jeb(struct jffs2_sb_info
*c
, struct jffs2_eraseblock
*jeb
);
199 __jffs2_dbg_dump_jeb_nolock(struct jffs2_eraseblock
*jeb
);
201 __jffs2_dbg_dump_block_lists(struct jffs2_sb_info
*c
);
203 __jffs2_dbg_dump_block_lists_nolock(struct jffs2_sb_info
*c
);
205 __jffs2_dbg_dump_node_refs(struct jffs2_sb_info
*c
,
206 struct jffs2_eraseblock
*jeb
);
208 __jffs2_dbg_dump_node_refs_nolock(struct jffs2_sb_info
*c
,
209 struct jffs2_eraseblock
*jeb
);
211 __jffs2_dbg_dump_fragtree(struct jffs2_inode_info
*f
);
213 __jffs2_dbg_dump_fragtree_nolock(struct jffs2_inode_info
*f
);
215 __jffs2_dbg_dump_buffer(unsigned char *buf
, int len
, uint32_t offs
);
217 __jffs2_dbg_dump_node(struct jffs2_sb_info
*c
, uint32_t ofs
);
219 #ifdef JFFS2_DBG_PARANOIA_CHECKS
220 #define jffs2_dbg_fragtree_paranoia_check(f) \
221 __jffs2_dbg_fragtree_paranoia_check(f)
222 #define jffs2_dbg_fragtree_paranoia_check_nolock(f) \
223 __jffs2_dbg_fragtree_paranoia_check_nolock(f)
224 #define jffs2_dbg_acct_paranoia_check(c, jeb) \
225 __jffs2_dbg_acct_paranoia_check(c,jeb)
226 #define jffs2_dbg_acct_paranoia_check_nolock(c, jeb) \
227 __jffs2_dbg_acct_paranoia_check_nolock(c,jeb)
228 #define jffs2_dbg_prewrite_paranoia_check(c, ofs, len) \
229 __jffs2_dbg_prewrite_paranoia_check(c, ofs, len)
231 #define jffs2_dbg_fragtree_paranoia_check(f)
232 #define jffs2_dbg_fragtree_paranoia_check_nolock(f)
233 #define jffs2_dbg_acct_paranoia_check(c, jeb)
234 #define jffs2_dbg_acct_paranoia_check_nolock(c, jeb)
235 #define jffs2_dbg_prewrite_paranoia_check(c, ofs, len)
236 #endif /* !JFFS2_PARANOIA_CHECKS */
238 #ifdef JFFS2_DBG_DUMPS
239 #define jffs2_dbg_dump_jeb(c, jeb) \
240 __jffs2_dbg_dump_jeb(c, jeb);
241 #define jffs2_dbg_dump_jeb_nolock(jeb) \
242 __jffs2_dbg_dump_jeb_nolock(jeb);
243 #define jffs2_dbg_dump_block_lists(c) \
244 __jffs2_dbg_dump_block_lists(c)
245 #define jffs2_dbg_dump_block_lists_nolock(c) \
246 __jffs2_dbg_dump_block_lists_nolock(c)
247 #define jffs2_dbg_dump_fragtree(f) \
248 __jffs2_dbg_dump_fragtree(f);
249 #define jffs2_dbg_dump_fragtree_nolock(f) \
250 __jffs2_dbg_dump_fragtree_nolock(f);
251 #define jffs2_dbg_dump_buffer(buf, len, offs) \
252 __jffs2_dbg_dump_buffer(*buf, len, offs);
253 #define jffs2_dbg_dump_node(c, ofs) \
254 __jffs2_dbg_dump_node(c, ofs);
256 #define jffs2_dbg_dump_jeb(c, jeb)
257 #define jffs2_dbg_dump_jeb_nolock(jeb)
258 #define jffs2_dbg_dump_block_lists(c)
259 #define jffs2_dbg_dump_block_lists_nolock(c)
260 #define jffs2_dbg_dump_fragtree(f)
261 #define jffs2_dbg_dump_fragtree_nolock(f)
262 #define jffs2_dbg_dump_buffer(buf, len, offs)
263 #define jffs2_dbg_dump_node(c, ofs)
264 #endif /* !JFFS2_DBG_DUMPS */
266 #ifdef JFFS2_DBG_SANITY_CHECKS
267 #define jffs2_dbg_acct_sanity_check(c, jeb) \
268 __jffs2_dbg_acct_sanity_check(c, jeb)
269 #define jffs2_dbg_acct_sanity_check_nolock(c, jeb) \
270 __jffs2_dbg_acct_sanity_check_nolock(c, jeb)
272 #define jffs2_dbg_acct_sanity_check(c, jeb)
273 #define jffs2_dbg_acct_sanity_check_nolock(c, jeb)
274 #endif /* !JFFS2_DBG_SANITY_CHECKS */
276 #endif /* _JFFS2_DEBUG_H_ */