1
2
3
4
5
6
7
8
9
10
11
12
13#ifndef _JFFS2_DEBUG_H_
14#define _JFFS2_DEBUG_H_
15
16#include <linux/sched.h>
17
18#ifndef CONFIG_JFFS2_FS_DEBUG
19#define CONFIG_JFFS2_FS_DEBUG 0
20#endif
21
22#if CONFIG_JFFS2_FS_DEBUG > 0
23
24#define JFFS2_DBG_PARANOIA_CHECKS
25#define JFFS2_DBG_DUMPS
26
27
28
29
30
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
39
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
45
46
47#define JFFS2_DBG_SANITY_CHECKS
48
49
50
51
52
53#if CONFIG_JFFS2_FS_DEBUG > 0
54#define DEBUG
55#define D1(x) x
56#else
57#define D1(x)
58#endif
59
60#if CONFIG_JFFS2_FS_DEBUG > 1
61#define D2(x) x
62#else
63#define D2(x)
64#endif
65
66#define jffs2_dbg(level, fmt, ...) \
67do { \
68 if (CONFIG_JFFS2_FS_DEBUG >= level) \
69 pr_debug(fmt, ##__VA_ARGS__); \
70} while (0)
71
72
73#define JFFS2_DBG KERN_DEBUG
74#define JFFS2_DBG_PREFIX "[JFFS2 DBG]"
75#define JFFS2_DBG_MSG_PREFIX JFFS2_DBG JFFS2_DBG_PREFIX
76
77
78#define JFFS2_ERROR(fmt, ...) \
79 pr_err("error: (%d) %s: " fmt, \
80 task_pid_nr(current), __func__, ##__VA_ARGS__)
81
82#define JFFS2_WARNING(fmt, ...) \
83 pr_warn("warning: (%d) %s: " fmt, \
84 task_pid_nr(current), __func__, ##__VA_ARGS__)
85
86#define JFFS2_NOTICE(fmt, ...) \
87 pr_notice("notice: (%d) %s: " fmt, \
88 task_pid_nr(current), __func__, ##__VA_ARGS__)
89
90#define JFFS2_DEBUG(fmt, ...) \
91 printk(KERN_DEBUG "[JFFS2 DBG] (%d) %s: " fmt, \
92 task_pid_nr(current), __func__, ##__VA_ARGS__)
93
94
95
96
97
98
99#ifdef JFFS2_DBG_READINODE_MESSAGES
100#define dbg_readinode(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
101#else
102#define dbg_readinode(fmt, ...)
103#endif
104#ifdef JFFS2_DBG_READINODE2_MESSAGES
105#define dbg_readinode2(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
106#else
107#define dbg_readinode2(fmt, ...)
108#endif
109
110
111#ifdef JFFS2_DBG_FRAGTREE_MESSAGES
112#define dbg_fragtree(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
113#else
114#define dbg_fragtree(fmt, ...)
115#endif
116#ifdef JFFS2_DBG_FRAGTREE2_MESSAGES
117#define dbg_fragtree2(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
118#else
119#define dbg_fragtree2(fmt, ...)
120#endif
121
122
123#ifdef JFFS2_DBG_DENTLIST_MESSAGES
124#define dbg_dentlist(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
125#else
126#define dbg_dentlist(fmt, ...)
127#endif
128
129
130#ifdef JFFS2_DBG_NODEREF_MESSAGES
131#define dbg_noderef(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
132#else
133#define dbg_noderef(fmt, ...)
134#endif
135
136
137#ifdef JFFS2_DBG_INOCACHE_MESSAGES
138#define dbg_inocache(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
139#else
140#define dbg_inocache(fmt, ...)
141#endif
142
143
144#ifdef JFFS2_DBG_SUMMARY_MESSAGES
145#define dbg_summary(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
146#else
147#define dbg_summary(fmt, ...)
148#endif
149
150
151#ifdef JFFS2_DBG_FSBUILD_MESSAGES
152#define dbg_fsbuild(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
153#else
154#define dbg_fsbuild(fmt, ...)
155#endif
156
157
158#ifdef JFFS2_DBG_MEMALLOC_MESSAGES
159#define dbg_memalloc(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
160#else
161#define dbg_memalloc(fmt, ...)
162#endif
163
164
165#ifdef JFFS2_DBG_XATTR_MESSAGES
166#define dbg_xattr(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
167#else
168#define dbg_xattr(fmt, ...)
169#endif
170
171
172void
173__jffs2_dbg_acct_sanity_check_nolock(struct jffs2_sb_info *c,
174 struct jffs2_eraseblock *jeb);
175void
176__jffs2_dbg_acct_sanity_check(struct jffs2_sb_info *c,
177 struct jffs2_eraseblock *jeb);
178
179
180void
181__jffs2_dbg_fragtree_paranoia_check(struct jffs2_inode_info *f);
182void
183__jffs2_dbg_fragtree_paranoia_check_nolock(struct jffs2_inode_info *f);
184void
185__jffs2_dbg_acct_paranoia_check(struct jffs2_sb_info *c,
186 struct jffs2_eraseblock *jeb);
187void
188__jffs2_dbg_acct_paranoia_check_nolock(struct jffs2_sb_info *c,
189 struct jffs2_eraseblock *jeb);
190void
191__jffs2_dbg_prewrite_paranoia_check(struct jffs2_sb_info *c,
192 uint32_t ofs, int len);
193
194
195void
196__jffs2_dbg_dump_jeb(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb);
197void
198__jffs2_dbg_dump_jeb_nolock(struct jffs2_eraseblock *jeb);
199void
200__jffs2_dbg_dump_block_lists(struct jffs2_sb_info *c);
201void
202__jffs2_dbg_dump_block_lists_nolock(struct jffs2_sb_info *c);
203void
204__jffs2_dbg_dump_node_refs(struct jffs2_sb_info *c,
205 struct jffs2_eraseblock *jeb);
206void
207__jffs2_dbg_dump_node_refs_nolock(struct jffs2_sb_info *c,
208 struct jffs2_eraseblock *jeb);
209void
210__jffs2_dbg_dump_fragtree(struct jffs2_inode_info *f);
211void
212__jffs2_dbg_dump_fragtree_nolock(struct jffs2_inode_info *f);
213void
214__jffs2_dbg_dump_buffer(unsigned char *buf, int len, uint32_t offs);
215void
216__jffs2_dbg_dump_node(struct jffs2_sb_info *c, uint32_t ofs);
217
218#ifdef JFFS2_DBG_PARANOIA_CHECKS
219#define jffs2_dbg_fragtree_paranoia_check(f) \
220 __jffs2_dbg_fragtree_paranoia_check(f)
221#define jffs2_dbg_fragtree_paranoia_check_nolock(f) \
222 __jffs2_dbg_fragtree_paranoia_check_nolock(f)
223#define jffs2_dbg_acct_paranoia_check(c, jeb) \
224 __jffs2_dbg_acct_paranoia_check(c,jeb)
225#define jffs2_dbg_acct_paranoia_check_nolock(c, jeb) \
226 __jffs2_dbg_acct_paranoia_check_nolock(c,jeb)
227#define jffs2_dbg_prewrite_paranoia_check(c, ofs, len) \
228 __jffs2_dbg_prewrite_paranoia_check(c, ofs, len)
229#else
230#define jffs2_dbg_fragtree_paranoia_check(f)
231#define jffs2_dbg_fragtree_paranoia_check_nolock(f)
232#define jffs2_dbg_acct_paranoia_check(c, jeb)
233#define jffs2_dbg_acct_paranoia_check_nolock(c, jeb)
234#define jffs2_dbg_prewrite_paranoia_check(c, ofs, len)
235#endif
236
237#ifdef JFFS2_DBG_DUMPS
238#define jffs2_dbg_dump_jeb(c, jeb) \
239 __jffs2_dbg_dump_jeb(c, jeb);
240#define jffs2_dbg_dump_jeb_nolock(jeb) \
241 __jffs2_dbg_dump_jeb_nolock(jeb);
242#define jffs2_dbg_dump_block_lists(c) \
243 __jffs2_dbg_dump_block_lists(c)
244#define jffs2_dbg_dump_block_lists_nolock(c) \
245 __jffs2_dbg_dump_block_lists_nolock(c)
246#define jffs2_dbg_dump_fragtree(f) \
247 __jffs2_dbg_dump_fragtree(f);
248#define jffs2_dbg_dump_fragtree_nolock(f) \
249 __jffs2_dbg_dump_fragtree_nolock(f);
250#define jffs2_dbg_dump_buffer(buf, len, offs) \
251 __jffs2_dbg_dump_buffer(*buf, len, offs);
252#define jffs2_dbg_dump_node(c, ofs) \
253 __jffs2_dbg_dump_node(c, ofs);
254#else
255#define jffs2_dbg_dump_jeb(c, jeb)
256#define jffs2_dbg_dump_jeb_nolock(jeb)
257#define jffs2_dbg_dump_block_lists(c)
258#define jffs2_dbg_dump_block_lists_nolock(c)
259#define jffs2_dbg_dump_fragtree(f)
260#define jffs2_dbg_dump_fragtree_nolock(f)
261#define jffs2_dbg_dump_buffer(buf, len, offs)
262#define jffs2_dbg_dump_node(c, ofs)
263#endif
264
265#ifdef JFFS2_DBG_SANITY_CHECKS
266#define jffs2_dbg_acct_sanity_check(c, jeb) \
267 __jffs2_dbg_acct_sanity_check(c, jeb)
268#define jffs2_dbg_acct_sanity_check_nolock(c, jeb) \
269 __jffs2_dbg_acct_sanity_check_nolock(c, jeb)
270#else
271#define jffs2_dbg_acct_sanity_check(c, jeb)
272#define jffs2_dbg_acct_sanity_check_nolock(c, jeb)
273#endif
274
275#endif
276