]> pilppa.org Git - linux-2.6-omap-h63xx.git/blob - fs/jffs2/debug.h
[JFFS2] Debug message format clean up
[linux-2.6-omap-h63xx.git] / fs / jffs2 / debug.h
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.16 2005/09/14 16:57:32 dedekind 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 == 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
31 #define JFFS2_DBG_SUMMARY_MESSAGES
32 #endif
33
34 #if CONFIG_JFFS2_FS_DEBUG == 2
35 #define JFFS2_DBG_FRAGTREE2_MESSAGES
36 #endif
37
38 /* Sanity checks are supposed to be light-weight and enabled by default */
39 #define JFFS2_DBG_SANITY_CHECKS
40
41 /* 
42  * Dx() are mainly used for debugging messages, they must go away and be
43  * superseded by nicer JFFS2_DBG_XXX() macros...
44  */
45 #if CONFIG_JFFS2_FS_DEBUG > 0
46 #define D1(x) x
47 #else
48 #define D1(x)
49 #endif
50
51 #if CONFIG_JFFS2_FS_DEBUG > 1
52 #define D2(x) x
53 #else
54 #define D2(x)
55 #endif
56
57 /* The prefixes of JFFS2 messages */
58 #define JFFS2_DBG_PREFIX        "[JFFS2 DBG]"
59 #define JFFS2_ERR_PREFIX        "JFFS2 error:"
60 #define JFFS2_WARN_PREFIX       "JFFS2 warning:"
61 #define JFFS2_NOTICE_PREFIX     "JFFS2 notice:"
62
63 #define JFFS2_ERR       KERN_ERR
64 #define JFFS2_WARN      KERN_WARNING
65 #define JFFS2_NOT       KERN_NOTICE
66 #define JFFS2_DBG       KERN_DEBUG
67
68 #define JFFS2_DBG_MSG_PREFIX    JFFS2_DBG JFFS2_DBG_PREFIX
69 #define JFFS2_ERR_MSG_PREFIX    JFFS2_ERR JFFS2_ERR_PREFIX
70 #define JFFS2_WARN_MSG_PREFIX   JFFS2_WARN JFFS2_WARN_PREFIX
71 #define JFFS2_NOTICE_MSG_PREFIX JFFS2_NOT JFFS2_NOTICE_PREFIX
72
73 /* JFFS2 message macros */
74 #define JFFS2_ERROR(fmt, ...)                                           \
75         do {                                                            \
76                 printk(JFFS2_ERR_MSG_PREFIX                             \
77                         " (%d) %s: " fmt, current->pid,                 \
78                         __FUNCTION__, ##__VA_ARGS__);                   \
79         } while(0)
80
81 #define JFFS2_WARNING(fmt, ...)                                         \
82         do {                                                            \
83                 printk(JFFS2_WARN_MSG_PREFIX                            \
84                         " (%d) %s: " fmt, current->pid,                 \
85                         __FUNCTION__, ##__VA_ARGS__);                   \
86         } while(0)
87                         
88 #define JFFS2_NOTICE(fmt, ...)                                          \
89         do {                                                            \
90                 printk(JFFS2_NOTICE_MSG_PREFIX                          \
91                         " (%d) %s: " fmt, current->pid,                 \
92                         __FUNCTION__, ##__VA_ARGS__);                   \
93         } while(0)
94
95 #define JFFS2_DEBUG(fmt, ...)                                           \
96         do {                                                            \
97                 printk(JFFS2_DBG_MSG_PREFIX                             \
98                         " (%d) %s: " fmt, current->pid,                 \
99                         __FUNCTION__, ##__VA_ARGS__);                   \
100         } while(0)
101
102 /* 
103  * We split our debugging messages on several parts, depending on the JFFS2
104  * subsystem the message belongs to.
105  */
106 /* Read inode debugging messages */
107 #ifdef JFFS2_DBG_READINODE_MESSAGES
108 #define JFFS2_DBG_READINODE(fmt, ...)   JFFS2_DEBUG(fmt, ##__VA_ARGS__)
109 #else
110 #define JFFS2_DBG_READINODE(fmt, ...)
111 #endif
112
113 /* Fragtree build debugging messages */
114 #ifdef JFFS2_DBG_FRAGTREE_MESSAGES
115 #define JFFS2_DBG_FRAGTREE(fmt, ...)    JFFS2_DEBUG(fmt, ##__VA_ARGS__)
116 #else
117 #define JFFS2_DBG_FRAGTREE(fmt, ...)
118 #endif
119 #ifdef JFFS2_DBG_FRAGTREE2_MESSAGES
120 #define JFFS2_DBG_FRAGTREE2(fmt, ...)   JFFS2_DEBUG(fmt, ##__VA_ARGS__)
121 #else
122 #define JFFS2_DBG_FRAGTREE2(fmt, ...)
123 #endif
124
125 /* Directory entry list manilulation debugging messages */
126 #ifdef JFFS2_DBG_DENTLIST_MESSAGES
127 #define JFFS2_DBG_DENTLIST(fmt, ...)    JFFS2_DEBUG(fmt, ##__VA_ARGS__)
128 #else
129 #define JFFS2_DBG_DENTLIST(fmt, ...)
130 #endif
131
132 /* Print the messages about manipulating node_refs */
133 #ifdef JFFS2_DBG_NODEREF_MESSAGES
134 #define JFFS2_DBG_NODEREF(fmt, ...)     JFFS2_DEBUG(fmt, ##__VA_ARGS__)
135 #else
136 #define JFFS2_DBG_NODEREF(fmt, ...)
137 #endif
138
139 /* Manipulations with the list of inodes (JFFS2 inocache) */
140 #ifdef JFFS2_DBG_INOCACHE_MESSAGES
141 #define JFFS2_DBG_INOCACHE(fmt, ...)    JFFS2_DEBUG(fmt, ##__VA_ARGS__)
142 #else
143 #define JFFS2_DBG_INOCACHE(fmt, ...)
144 #endif
145
146 /* Summary debugging messages */
147 #ifdef JFFS2_DBG_SUMMARY_MESSAGES
148 #define JFFS2_DBG_SUMMARY(fmt, ...)     JFFS2_DEBUG(fmt, ##__VA_ARGS__)
149 #else
150 #define JFFS2_DBG_SUMMARY(fmt, ...)
151 #endif
152
153 /* Watch the object allocations */
154 #ifdef JFFS2_DBG_MEMALLOC_MESSAGES
155 #define JFFS2_DBG_MEMALLOC(fmt, ...)    JFFS2_DEBUG(fmt, ##__VA_ARGS__)
156 #else
157 #define JFFS2_DBG_MEMALLOC(fmt, ...)
158 #endif
159
160
161 /* "Sanity" checks */
162 void
163 __jffs2_dbg_acct_sanity_check_nolock(struct jffs2_sb_info *c,
164                                      struct jffs2_eraseblock *jeb);
165 void
166 __jffs2_dbg_acct_sanity_check(struct jffs2_sb_info *c,
167                               struct jffs2_eraseblock *jeb);
168
169 /* "Paranoia" checks */
170 void
171 __jffs2_dbg_fragtree_paranoia_check(struct jffs2_inode_info *f);
172 void
173 __jffs2_dbg_fragtree_paranoia_check_nolock(struct jffs2_inode_info *f);
174 void
175 __jffs2_dbg_acct_paranoia_check(struct jffs2_sb_info *c,
176                                 struct jffs2_eraseblock *jeb);
177 void
178 __jffs2_dbg_acct_paranoia_check_nolock(struct jffs2_sb_info *c,
179                                        struct jffs2_eraseblock *jeb);
180 void
181 __jffs2_dbg_prewrite_paranoia_check(struct jffs2_sb_info *c,
182                                     uint32_t ofs, int len);
183
184 /* "Dump" functions */
185 void
186 __jffs2_dbg_dump_jeb(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb);
187 void
188 __jffs2_dbg_dump_jeb_nolock(struct jffs2_eraseblock *jeb);
189 void
190 __jffs2_dbg_dump_block_lists(struct jffs2_sb_info *c);
191 void
192 __jffs2_dbg_dump_block_lists_nolock(struct jffs2_sb_info *c);
193 void
194 __jffs2_dbg_dump_node_refs(struct jffs2_sb_info *c,
195                            struct jffs2_eraseblock *jeb);
196 void
197 __jffs2_dbg_dump_node_refs_nolock(struct jffs2_sb_info *c,
198                                   struct jffs2_eraseblock *jeb);
199 void
200 __jffs2_dbg_dump_fragtree(struct jffs2_inode_info *f);
201 void
202 __jffs2_dbg_dump_fragtree_nolock(struct jffs2_inode_info *f);
203 void
204 __jffs2_dbg_dump_buffer(unsigned char *buf, int len, uint32_t offs);
205 void
206 __jffs2_dbg_dump_node(struct jffs2_sb_info *c, uint32_t ofs);
207
208 #ifdef JFFS2_DBG_PARANOIA_CHECKS
209 #define jffs2_dbg_fragtree_paranoia_check(f)                    \
210         __jffs2_dbg_fragtree_paranoia_check(f)
211 #define jffs2_dbg_fragtree_paranoia_check_nolock(f)             \
212         __jffs2_dbg_fragtree_paranoia_check_nolock(f)
213 #define jffs2_dbg_acct_paranoia_check(c, jeb)                   \
214         __jffs2_dbg_acct_paranoia_check(c,jeb)
215 #define jffs2_dbg_acct_paranoia_check_nolock(c, jeb)            \
216         __jffs2_dbg_acct_paranoia_check_nolock(c,jeb)
217 #define jffs2_dbg_prewrite_paranoia_check(c, ofs, len)          \
218         __jffs2_dbg_prewrite_paranoia_check(c, ofs, len)
219 #else
220 #define jffs2_dbg_fragtree_paranoia_check(f)
221 #define jffs2_dbg_fragtree_paranoia_check_nolock(f)
222 #define jffs2_dbg_acct_paranoia_check(c, jeb)
223 #define jffs2_dbg_acct_paranoia_check_nolock(c, jeb)
224 #define jffs2_dbg_prewrite_paranoia_check(c, ofs, len)
225 #endif /* !JFFS2_PARANOIA_CHECKS */
226
227 #ifdef JFFS2_DBG_DUMPS
228 #define jffs2_dbg_dump_jeb(c, jeb)                              \
229         __jffs2_dbg_dump_jeb(c, jeb);
230 #define jffs2_dbg_dump_jeb_nolock(jeb)                          \
231         __jffs2_dbg_dump_jeb_nolock(jeb);
232 #define jffs2_dbg_dump_block_lists(c)                           \
233         __jffs2_dbg_dump_block_lists(c)
234 #define jffs2_dbg_dump_block_lists_nolock(c)                    \
235         __jffs2_dbg_dump_block_lists_nolock(c)
236 #define jffs2_dbg_dump_fragtree(f)                              \
237         __jffs2_dbg_dump_fragtree(f);
238 #define jffs2_dbg_dump_fragtree_nolock(f)                       \
239         __jffs2_dbg_dump_fragtree_nolock(f);
240 #define jffs2_dbg_dump_buffer(buf, len, offs)                   \
241         __jffs2_dbg_dump_buffer(*buf, len, offs);
242 #define jffs2_dbg_dump_node(c, ofs)                             \
243         __jffs2_dbg_dump_node(c, ofs);
244 #else
245 #define jffs2_dbg_dump_jeb(c, jeb)
246 #define jffs2_dbg_dump_jeb_nolock(jeb)
247 #define jffs2_dbg_dump_block_lists(c)
248 #define jffs2_dbg_dump_block_lists_nolock(c)
249 #define jffs2_dbg_dump_fragtree(f)
250 #define jffs2_dbg_dump_fragtree_nolock(f)
251 #define jffs2_dbg_dump_buffer(buf, len, offs)
252 #define jffs2_dbg_dump_node(c, ofs)
253 #endif /* !JFFS2_DBG_DUMPS */
254
255 #ifdef JFFS2_DBG_SANITY_CHECKS
256 #define jffs2_dbg_acct_sanity_check(c, jeb)                     \
257         __jffs2_dbg_acct_sanity_check(c, jeb)
258 #define jffs2_dbg_acct_sanity_check_nolock(c, jeb)              \
259         __jffs2_dbg_acct_sanity_check_nolock(c, jeb)
260 #else
261 #define jffs2_dbg_acct_sanity_check(c, jeb)
262 #define jffs2_dbg_acct_sanity_check_nolock(c, jeb)
263 #endif /* !JFFS2_DBG_SANITY_CHECKS */
264
265 #endif /* _JFFS2_DEBUG_H_ */