2 * JFFS2 -- Journalling Flash File System, Version 2.
4 * Copyright (C) 2001-2003 Red Hat, Inc.
6 * Created by David Woodhouse <dwmw2@infradead.org>
8 * For licensing information, see the file 'LICENCE' in this directory.
10 * $Id: debug.h,v 1.14 2005/08/17 13:48:59 dedekind Exp $
13 #ifndef _JFFS2_DEBUG_H_
14 #define _JFFS2_DEBUG_H_
16 #include <linux/config.h>
18 #ifndef CONFIG_JFFS2_FS_DEBUG
19 #define CONFIG_JFFS2_FS_DEBUG 0
22 #if CONFIG_JFFS2_FS_DEBUG == 1
23 /* Enable "paranoia" checks and dumps */
24 #define JFFS2_DBG_PARANOIA_CHECKS
25 #define JFFS2_DBG_DUMPS
26 #define JFFS2_DBG_READINODE_MESSAGES
27 #define JFFS2_DBG_FRAGTREE_MESSAGES
28 #define JFFS2_DBG_DENTLIST_MESSAGES
29 #define JFFS2_DBG_NODEREF_MESSAGES
30 #define JFFS2_DBG_INOCACHE_MESSAGES
33 #if CONFIG_JFFS2_FS_DEBUG == 2
34 #define JFFS2_DBG_FRAGTREE2_MESSAGES
37 /* Sanity checks are supposed to be light-weight and enabled by default */
38 #define JFFS2_DBG_SANITY_CHECKS
41 * Dx() are mainly used for debugging messages, they must go away and be
42 * superseded by nicer JFFS2_DBG_XXX() macros...
44 #if CONFIG_JFFS2_FS_DEBUG > 0
50 #if CONFIG_JFFS2_FS_DEBUG > 1
56 /* The prefixes of JFFS2 messages */
57 #define JFFS2_DBG_MSG_PREFIX "[JFFS2 DBG]"
58 #define JFFS2_ERR_MSG_PREFIX "JFFS2 error:"
59 #define JFFS2_WARN_MSG_PREFIX "JFFS2 warning:"
60 #define JFFS2_NOTICE_MSG_PREFIX "JFFS2 notice:"
62 #define JFFS2_ERR_LVL KERN_ERR
63 #define JFFS2_WARN_LVL KERN_WARNING
64 #define JFFS2_NOTICE_LVL KERN_NOTICE
65 #define JFFS2_DBG_LVL KERN_DEBUG
67 /* JFFS2 message macros */
68 #define JFFS2_ERROR(fmt, ...) \
70 printk(JFFS2_ERR_LVL JFFS2_ERR_MSG_PREFIX \
71 " (%d) %s: " fmt, current->pid, \
72 __FUNCTION__, ##__VA_ARGS__); \
75 #define JFFS2_WARNING(fmt, ...) \
77 printk(JFFS2_WARN_LVL JFFS2_WARN_MSG_PREFIX \
78 " (%d) %s: " fmt, current->pid, \
79 __FUNCTION__, ##__VA_ARGS__); \
82 #define JFFS2_NOTICE(fmt, ...) \
84 printk(JFFS2_NOTICE_LVL JFFS2_NOTICE_MSG_PREFIX \
85 " (%d) %s: " fmt, current->pid, \
86 __FUNCTION__, ##__VA_ARGS__); \
89 #define JFFS2_DEBUG(fmt, ...) \
91 printk(JFFS2_DBG_LVL JFFS2_DBG_MSG_PREFIX \
92 " (%d) %s: " fmt, current->pid, \
93 __FUNCTION__, ##__VA_ARGS__); \
97 * We split our debugging messages on several parts, depending on the JFFS2
98 * subsystem the message belongs to.
100 /* Read inode debugging messages */
101 #ifdef JFFS2_DBG_READINODE_MESSAGES
102 #define JFFS2_DBG_READINODE(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
104 #define JFFS2_DBG_READINODE(fmt, ...)
107 /* Fragtree build debugging messages */
108 #ifdef JFFS2_DBG_FRAGTREE_MESSAGES
109 #define JFFS2_DBG_FRAGTREE(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
111 #define JFFS2_DBG_FRAGTREE(fmt, ...)
113 #ifdef JFFS2_DBG_FRAGTREE2_MESSAGES
114 #define JFFS2_DBG_FRAGTREE2(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
116 #define JFFS2_DBG_FRAGTREE2(fmt, ...)
119 /* Directory entry list manilulation debugging messages */
120 #ifdef JFFS2_DBG_DENTLIST_MESSAGES
121 #define JFFS2_DBG_DENTLIST(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
123 #define JFFS2_DBG_DENTLIST(fmt, ...)
126 /* Print the messages about manipulating node_refs */
127 #ifdef JFFS2_DBG_NODEREF_MESSAGES
128 #define JFFS2_DBG_NODEREF(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
130 #define JFFS2_DBG_NODEREF(fmt, ...)
133 /* Manipulations with the list of inodes (JFFS2 inocache) */
134 #ifdef JFFS2_DBG_INOCACHE_MESSAGES
135 #define JFFS2_DBG_INOCACHE(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
137 #define JFFS2_DBG_INOCACHE(fmt, ...)
140 /* Watch the object allocations */
141 #ifdef JFFS2_DBG_MEMALLOC_MESSAGES
142 #define JFFS2_DBG_MEMALLOC(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
144 #define JFFS2_DBG_MEMALLOC(fmt, ...)
148 /* "Sanity" checks */
150 __jffs2_dbg_acct_sanity_check_nolock(struct jffs2_sb_info *c,
151 struct jffs2_eraseblock *jeb);
153 __jffs2_dbg_acct_sanity_check(struct jffs2_sb_info *c,
154 struct jffs2_eraseblock *jeb);
156 /* "Paranoia" checks */
158 __jffs2_dbg_fragtree_paranoia_check(struct jffs2_inode_info *f);
160 __jffs2_dbg_fragtree_paranoia_check_nolock(struct jffs2_inode_info *f);
162 __jffs2_dbg_acct_paranoia_check(struct jffs2_sb_info *c,
163 struct jffs2_eraseblock *jeb);
165 __jffs2_dbg_acct_paranoia_check_nolock(struct jffs2_sb_info *c,
166 struct jffs2_eraseblock *jeb);
168 __jffs2_dbg_prewrite_paranoia_check(struct jffs2_sb_info *c,
169 uint32_t ofs, int len);
171 /* "Dump" functions */
173 __jffs2_dbg_dump_jeb(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb);
175 __jffs2_dbg_dump_jeb_nolock(struct jffs2_eraseblock *jeb);
177 __jffs2_dbg_dump_block_lists(struct jffs2_sb_info *c);
179 __jffs2_dbg_dump_block_lists_nolock(struct jffs2_sb_info *c);
181 __jffs2_dbg_dump_node_refs(struct jffs2_sb_info *c,
182 struct jffs2_eraseblock *jeb);
184 __jffs2_dbg_dump_node_refs_nolock(struct jffs2_sb_info *c,
185 struct jffs2_eraseblock *jeb);
187 __jffs2_dbg_dump_fragtree(struct jffs2_inode_info *f);
189 __jffs2_dbg_dump_fragtree_nolock(struct jffs2_inode_info *f);
191 __jffs2_dbg_dump_buffer(unsigned char *buf, int len, uint32_t offs);
193 __jffs2_dbg_dump_node(struct jffs2_sb_info *c, uint32_t ofs);
195 #ifdef JFFS2_DBG_PARANOIA_CHECKS
196 #define jffs2_dbg_fragtree_paranoia_check(f) \
197 __jffs2_dbg_fragtree_paranoia_check(f)
198 #define jffs2_dbg_fragtree_paranoia_check_nolock(f) \
199 __jffs2_dbg_fragtree_paranoia_check_nolock(f)
200 #define jffs2_dbg_acct_paranoia_check(c, jeb) \
201 __jffs2_dbg_acct_paranoia_check(c,jeb)
202 #define jffs2_dbg_acct_paranoia_check_nolock(c, jeb) \
203 __jffs2_dbg_acct_paranoia_check_nolock(c,jeb)
204 #define jffs2_dbg_prewrite_paranoia_check(c, ofs, len) \
205 __jffs2_dbg_prewrite_paranoia_check(c, ofs, len)
207 #define jffs2_dbg_fragtree_paranoia_check(f)
208 #define jffs2_dbg_fragtree_paranoia_check_nolock(f)
209 #define jffs2_dbg_acct_paranoia_check(c, jeb)
210 #define jffs2_dbg_acct_paranoia_check_nolock(c, jeb)
211 #define jffs2_dbg_prewrite_paranoia_check(c, ofs, len)
212 #endif /* !JFFS2_PARANOIA_CHECKS */
214 #ifdef JFFS2_DBG_DUMPS
215 #define jffs2_dbg_dump_jeb(c, jeb) \
216 __jffs2_dbg_dump_jeb(c, jeb);
217 #define jffs2_dbg_dump_jeb_nolock(jeb) \
218 __jffs2_dbg_dump_jeb_nolock(jeb);
219 #define jffs2_dbg_dump_block_lists(c) \
220 __jffs2_dbg_dump_block_lists(c)
221 #define jffs2_dbg_dump_block_lists_nolock(c) \
222 __jffs2_dbg_dump_block_lists_nolock(c)
223 #define jffs2_dbg_dump_fragtree(f) \
224 __jffs2_dbg_dump_fragtree(f);
225 #define jffs2_dbg_dump_fragtree_nolock(f) \
226 __jffs2_dbg_dump_fragtree_nolock(f);
227 #define jffs2_dbg_dump_buffer(buf, len, offs) \
228 __jffs2_dbg_dump_buffer(*buf, len, offs);
229 #define jffs2_dbg_dump_node(c, ofs) \
230 __jffs2_dbg_dump_node(c, ofs);
232 #define jffs2_dbg_dump_jeb(c, jeb)
233 #define jffs2_dbg_dump_jeb_nolock(jeb)
234 #define jffs2_dbg_dump_block_lists(c)
235 #define jffs2_dbg_dump_block_lists_nolock(c)
236 #define jffs2_dbg_dump_fragtree(f)
237 #define jffs2_dbg_dump_fragtree_nolock(f)
238 #define jffs2_dbg_dump_buffer(buf, len, offs)
239 #define jffs2_dbg_dump_node(c, ofs)
240 #endif /* !JFFS2_DBG_DUMPS */
242 #ifdef JFFS2_DBG_SANITY_CHECKS
243 #define jffs2_dbg_acct_sanity_check(c, jeb) \
244 __jffs2_dbg_acct_sanity_check(c, jeb)
245 #define jffs2_dbg_acct_sanity_check_nolock(c, jeb) \
246 __jffs2_dbg_acct_sanity_check_nolock(c, jeb)
248 #define jffs2_dbg_acct_sanity_check(c, jeb)
249 #define jffs2_dbg_acct_sanity_check_nolock(c, jeb)
250 #endif /* !JFFS2_DBG_SANITY_CHECKS */
252 #endif /* _JFFS2_DEBUG_H_ */