sh: convert /proc/cpu/aligmnent, /proc/cpu/kernel_alignment to seq_file
[safe/jmp/linux-2.6] / fs / jffs2 / debug.h
1 /*
2  * JFFS2 -- Journalling Flash File System, Version 2.
3  *
4  * Copyright © 2001-2007 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  */
11
12 #ifndef _JFFS2_DEBUG_H_
13 #define _JFFS2_DEBUG_H_
14
15 #include <linux/sched.h>
16
17 #ifndef CONFIG_JFFS2_FS_DEBUG
18 #define CONFIG_JFFS2_FS_DEBUG 0
19 #endif
20
21 #if CONFIG_JFFS2_FS_DEBUG > 0
22 /* Enable "paranoia" checks and dumps */
23 #define JFFS2_DBG_PARANOIA_CHECKS
24 #define JFFS2_DBG_DUMPS
25
26 /*
27  * By defining/undefining the below macros one may select debugging messages
28  * fro specific JFFS2 subsystems.
29  */
30 #define JFFS2_DBG_READINODE_MESSAGES
31 #define JFFS2_DBG_FRAGTREE_MESSAGES
32 #define JFFS2_DBG_DENTLIST_MESSAGES
33 #define JFFS2_DBG_NODEREF_MESSAGES
34 #define JFFS2_DBG_INOCACHE_MESSAGES
35 #define JFFS2_DBG_SUMMARY_MESSAGES
36 #define JFFS2_DBG_FSBUILD_MESSAGES
37 #endif
38
39 #if CONFIG_JFFS2_FS_DEBUG > 1
40 #define JFFS2_DBG_FRAGTREE2_MESSAGES
41 #define JFFS2_DBG_READINODE2_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, task_pid_nr(current),         \
85                         __func__ , ##__VA_ARGS__);                      \
86         } while(0)
87
88 #define JFFS2_WARNING(fmt, ...)                                         \
89         do {                                                            \
90                 printk(JFFS2_WARN_MSG_PREFIX                            \
91                         " (%d) %s: " fmt, task_pid_nr(current),         \
92                         __func__ , ##__VA_ARGS__);                      \
93         } while(0)
94
95 #define JFFS2_NOTICE(fmt, ...)                                          \
96         do {                                                            \
97                 printk(JFFS2_NOTICE_MSG_PREFIX                          \
98                         " (%d) %s: " fmt, task_pid_nr(current),         \
99                         __func__ , ##__VA_ARGS__);                      \
100         } while(0)
101
102 #define JFFS2_DEBUG(fmt, ...)                                           \
103         do {                                                            \
104                 printk(JFFS2_DBG_MSG_PREFIX                             \
105                         " (%d) %s: " fmt, task_pid_nr(current),         \
106                         __func__ , ##__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 #ifdef JFFS2_DBG_READINODE2_MESSAGES
120 #define dbg_readinode2(fmt, ...)        JFFS2_DEBUG(fmt, ##__VA_ARGS__)
121 #else
122 #define dbg_readinode2(fmt, ...)
123 #endif
124
125 /* Fragtree build debugging messages */
126 #ifdef JFFS2_DBG_FRAGTREE_MESSAGES
127 #define dbg_fragtree(fmt, ...)  JFFS2_DEBUG(fmt, ##__VA_ARGS__)
128 #else
129 #define dbg_fragtree(fmt, ...)
130 #endif
131 #ifdef JFFS2_DBG_FRAGTREE2_MESSAGES
132 #define dbg_fragtree2(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
133 #else
134 #define dbg_fragtree2(fmt, ...)
135 #endif
136
137 /* Directory entry list manilulation debugging messages */
138 #ifdef JFFS2_DBG_DENTLIST_MESSAGES
139 #define dbg_dentlist(fmt, ...)  JFFS2_DEBUG(fmt, ##__VA_ARGS__)
140 #else
141 #define dbg_dentlist(fmt, ...)
142 #endif
143
144 /* Print the messages about manipulating node_refs */
145 #ifdef JFFS2_DBG_NODEREF_MESSAGES
146 #define dbg_noderef(fmt, ...)   JFFS2_DEBUG(fmt, ##__VA_ARGS__)
147 #else
148 #define dbg_noderef(fmt, ...)
149 #endif
150
151 /* Manipulations with the list of inodes (JFFS2 inocache) */
152 #ifdef JFFS2_DBG_INOCACHE_MESSAGES
153 #define dbg_inocache(fmt, ...)  JFFS2_DEBUG(fmt, ##__VA_ARGS__)
154 #else
155 #define dbg_inocache(fmt, ...)
156 #endif
157
158 /* Summary debugging messages */
159 #ifdef JFFS2_DBG_SUMMARY_MESSAGES
160 #define dbg_summary(fmt, ...)   JFFS2_DEBUG(fmt, ##__VA_ARGS__)
161 #else
162 #define dbg_summary(fmt, ...)
163 #endif
164
165 /* File system build messages */
166 #ifdef JFFS2_DBG_FSBUILD_MESSAGES
167 #define dbg_fsbuild(fmt, ...)   JFFS2_DEBUG(fmt, ##__VA_ARGS__)
168 #else
169 #define dbg_fsbuild(fmt, ...)
170 #endif
171
172 /* Watch the object allocations */
173 #ifdef JFFS2_DBG_MEMALLOC_MESSAGES
174 #define dbg_memalloc(fmt, ...)  JFFS2_DEBUG(fmt, ##__VA_ARGS__)
175 #else
176 #define dbg_memalloc(fmt, ...)
177 #endif
178
179 /* Watch the XATTR subsystem */
180 #ifdef JFFS2_DBG_XATTR_MESSAGES
181 #define dbg_xattr(fmt, ...)  JFFS2_DEBUG(fmt, ##__VA_ARGS__)
182 #else
183 #define dbg_xattr(fmt, ...)
184 #endif 
185
186 /* "Sanity" checks */
187 void
188 __jffs2_dbg_acct_sanity_check_nolock(struct jffs2_sb_info *c,
189                                      struct jffs2_eraseblock *jeb);
190 void
191 __jffs2_dbg_acct_sanity_check(struct jffs2_sb_info *c,
192                               struct jffs2_eraseblock *jeb);
193
194 /* "Paranoia" checks */
195 void
196 __jffs2_dbg_fragtree_paranoia_check(struct jffs2_inode_info *f);
197 void
198 __jffs2_dbg_fragtree_paranoia_check_nolock(struct jffs2_inode_info *f);
199 void
200 __jffs2_dbg_acct_paranoia_check(struct jffs2_sb_info *c,
201                                 struct jffs2_eraseblock *jeb);
202 void
203 __jffs2_dbg_acct_paranoia_check_nolock(struct jffs2_sb_info *c,
204                                        struct jffs2_eraseblock *jeb);
205 void
206 __jffs2_dbg_prewrite_paranoia_check(struct jffs2_sb_info *c,
207                                     uint32_t ofs, int len);
208
209 /* "Dump" functions */
210 void
211 __jffs2_dbg_dump_jeb(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb);
212 void
213 __jffs2_dbg_dump_jeb_nolock(struct jffs2_eraseblock *jeb);
214 void
215 __jffs2_dbg_dump_block_lists(struct jffs2_sb_info *c);
216 void
217 __jffs2_dbg_dump_block_lists_nolock(struct jffs2_sb_info *c);
218 void
219 __jffs2_dbg_dump_node_refs(struct jffs2_sb_info *c,
220                            struct jffs2_eraseblock *jeb);
221 void
222 __jffs2_dbg_dump_node_refs_nolock(struct jffs2_sb_info *c,
223                                   struct jffs2_eraseblock *jeb);
224 void
225 __jffs2_dbg_dump_fragtree(struct jffs2_inode_info *f);
226 void
227 __jffs2_dbg_dump_fragtree_nolock(struct jffs2_inode_info *f);
228 void
229 __jffs2_dbg_dump_buffer(unsigned char *buf, int len, uint32_t offs);
230 void
231 __jffs2_dbg_dump_node(struct jffs2_sb_info *c, uint32_t ofs);
232
233 #ifdef JFFS2_DBG_PARANOIA_CHECKS
234 #define jffs2_dbg_fragtree_paranoia_check(f)                    \
235         __jffs2_dbg_fragtree_paranoia_check(f)
236 #define jffs2_dbg_fragtree_paranoia_check_nolock(f)             \
237         __jffs2_dbg_fragtree_paranoia_check_nolock(f)
238 #define jffs2_dbg_acct_paranoia_check(c, jeb)                   \
239         __jffs2_dbg_acct_paranoia_check(c,jeb)
240 #define jffs2_dbg_acct_paranoia_check_nolock(c, jeb)            \
241         __jffs2_dbg_acct_paranoia_check_nolock(c,jeb)
242 #define jffs2_dbg_prewrite_paranoia_check(c, ofs, len)          \
243         __jffs2_dbg_prewrite_paranoia_check(c, ofs, len)
244 #else
245 #define jffs2_dbg_fragtree_paranoia_check(f)
246 #define jffs2_dbg_fragtree_paranoia_check_nolock(f)
247 #define jffs2_dbg_acct_paranoia_check(c, jeb)
248 #define jffs2_dbg_acct_paranoia_check_nolock(c, jeb)
249 #define jffs2_dbg_prewrite_paranoia_check(c, ofs, len)
250 #endif /* !JFFS2_PARANOIA_CHECKS */
251
252 #ifdef JFFS2_DBG_DUMPS
253 #define jffs2_dbg_dump_jeb(c, jeb)                              \
254         __jffs2_dbg_dump_jeb(c, jeb);
255 #define jffs2_dbg_dump_jeb_nolock(jeb)                          \
256         __jffs2_dbg_dump_jeb_nolock(jeb);
257 #define jffs2_dbg_dump_block_lists(c)                           \
258         __jffs2_dbg_dump_block_lists(c)
259 #define jffs2_dbg_dump_block_lists_nolock(c)                    \
260         __jffs2_dbg_dump_block_lists_nolock(c)
261 #define jffs2_dbg_dump_fragtree(f)                              \
262         __jffs2_dbg_dump_fragtree(f);
263 #define jffs2_dbg_dump_fragtree_nolock(f)                       \
264         __jffs2_dbg_dump_fragtree_nolock(f);
265 #define jffs2_dbg_dump_buffer(buf, len, offs)                   \
266         __jffs2_dbg_dump_buffer(*buf, len, offs);
267 #define jffs2_dbg_dump_node(c, ofs)                             \
268         __jffs2_dbg_dump_node(c, ofs);
269 #else
270 #define jffs2_dbg_dump_jeb(c, jeb)
271 #define jffs2_dbg_dump_jeb_nolock(jeb)
272 #define jffs2_dbg_dump_block_lists(c)
273 #define jffs2_dbg_dump_block_lists_nolock(c)
274 #define jffs2_dbg_dump_fragtree(f)
275 #define jffs2_dbg_dump_fragtree_nolock(f)
276 #define jffs2_dbg_dump_buffer(buf, len, offs)
277 #define jffs2_dbg_dump_node(c, ofs)
278 #endif /* !JFFS2_DBG_DUMPS */
279
280 #ifdef JFFS2_DBG_SANITY_CHECKS
281 #define jffs2_dbg_acct_sanity_check(c, jeb)                     \
282         __jffs2_dbg_acct_sanity_check(c, jeb)
283 #define jffs2_dbg_acct_sanity_check_nolock(c, jeb)              \
284         __jffs2_dbg_acct_sanity_check_nolock(c, jeb)
285 #else
286 #define jffs2_dbg_acct_sanity_check(c, jeb)
287 #define jffs2_dbg_acct_sanity_check_nolock(c, jeb)
288 #endif /* !JFFS2_DBG_SANITY_CHECKS */
289
290 #endif /* _JFFS2_DEBUG_H_ */