RTEMS 6.1-rc6
Loading...
Searching...
No Matches
debug.h
1/*
2 * JFFS2 -- Journalling Flash File System, Version 2.
3 *
4 * Copyright © 2001-2007 Red Hat, Inc.
5 * Copyright © 2004-2010 David Woodhouse <dwmw2@infradead.org>
6 *
7 * Created by David Woodhouse <dwmw2@infradead.org>
8 *
9 * For licensing information, see the file 'LICENCE' in this directory.
10 *
11 */
12
13#ifndef _JFFS2_DEBUG_H_
14#define _JFFS2_DEBUG_H_
15
16#include <linux/printk.h>
17#include <linux/sched.h>
18
19#ifndef CONFIG_JFFS2_FS_DEBUG
20#define CONFIG_JFFS2_FS_DEBUG 0
21#endif
22
23#if CONFIG_JFFS2_FS_DEBUG > 0
24/* Enable "paranoia" checks and dumps */
25#define JFFS2_DBG_PARANOIA_CHECKS
26#define JFFS2_DBG_DUMPS
27
28/*
29 * By defining/undefining the below macros one may select debugging messages
30 * fro specific JFFS2 subsystems.
31 */
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
39#endif
40
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
45#endif
46
47/* Sanity checks are supposed to be light-weight and enabled by default */
48#define JFFS2_DBG_SANITY_CHECKS
49
50/*
51 * Dx() are mainly used for debugging messages, they must go away and be
52 * superseded by nicer dbg_xxx() macros...
53 */
54#if CONFIG_JFFS2_FS_DEBUG > 0
55#define DEBUG
56#define D1(x) x
57#else
58#define D1(x)
59#endif
60
61#if CONFIG_JFFS2_FS_DEBUG > 1
62#define D2(x) x
63#else
64#define D2(x)
65#endif
66
67#define jffs2_dbg(level, fmt, ...) \
68do { \
69 if (CONFIG_JFFS2_FS_DEBUG >= level) \
70 pr_debug(fmt, ##__VA_ARGS__); \
71} while (0)
72
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
77
78/* JFFS2 message macros */
79#ifndef __rtems__
80#define JFFS2_ERROR(fmt, ...) \
81 pr_err("error: (%d) %s: " fmt, \
82 task_pid_nr(current), __func__, ##__VA_ARGS__)
83
84#define JFFS2_WARNING(fmt, ...) \
85 pr_warn("warning: (%d) %s: " fmt, \
86 task_pid_nr(current), __func__, ##__VA_ARGS__)
87
88#define JFFS2_NOTICE(fmt, ...) \
89 pr_notice("notice: (%d) %s: " fmt, \
90 task_pid_nr(current), __func__, ##__VA_ARGS__)
91
92#define JFFS2_DEBUG(fmt, ...) \
93 printk(KERN_DEBUG "[JFFS2 DBG] (%d) %s: " fmt, \
94 task_pid_nr(current), __func__, ##__VA_ARGS__)
95#else /* __rtems__ */
96#define JFFS2_ERROR(fmt, ...) \
97 pr_err("error: %s: " fmt, \
98 __func__, ##__VA_ARGS__)
99
100#define JFFS2_WARNING(fmt, ...) \
101 pr_warn("warning: %s: " fmt, \
102 __func__, ##__VA_ARGS__)
103
104#define JFFS2_NOTICE(fmt, ...) \
105 pr_notice("notice: %s: " fmt, \
106 __func__, ##__VA_ARGS__)
107
108#define JFFS2_DEBUG(fmt, ...) \
109 printk(KERN_DEBUG "[JFFS2 DBG] %s: " fmt, \
110 __func__, ##__VA_ARGS__)
111#endif /* __rtems__ */
112
113/*
114 * We split our debugging messages on several parts, depending on the JFFS2
115 * subsystem the message belongs to.
116 */
117/* Read inode debugging messages */
118#ifdef JFFS2_DBG_READINODE_MESSAGES
119#define dbg_readinode(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
120#else
121#define dbg_readinode(fmt, ...) no_printk(fmt, ##__VA_ARGS__)
122#endif
123#ifdef JFFS2_DBG_READINODE2_MESSAGES
124#define dbg_readinode2(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
125#else
126#define dbg_readinode2(fmt, ...) no_printk(fmt, ##__VA_ARGS__)
127#endif
128
129/* Fragtree build debugging messages */
130#ifdef JFFS2_DBG_FRAGTREE_MESSAGES
131#define dbg_fragtree(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
132#else
133#define dbg_fragtree(fmt, ...) no_printk(fmt, ##__VA_ARGS__)
134#endif
135#ifdef JFFS2_DBG_FRAGTREE2_MESSAGES
136#define dbg_fragtree2(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
137#else
138#define dbg_fragtree2(fmt, ...) no_printk(fmt, ##__VA_ARGS__)
139#endif
140
141/* Directory entry list manilulation debugging messages */
142#ifdef JFFS2_DBG_DENTLIST_MESSAGES
143#define dbg_dentlist(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
144#else
145#define dbg_dentlist(fmt, ...) no_printk(fmt, ##__VA_ARGS__)
146#endif
147
148/* Print the messages about manipulating node_refs */
149#ifdef JFFS2_DBG_NODEREF_MESSAGES
150#define dbg_noderef(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
151#else
152#define dbg_noderef(fmt, ...) no_printk(fmt, ##__VA_ARGS__)
153#endif
154
155/* Manipulations with the list of inodes (JFFS2 inocache) */
156#ifdef JFFS2_DBG_INOCACHE_MESSAGES
157#define dbg_inocache(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
158#else
159#define dbg_inocache(fmt, ...) no_printk(fmt, ##__VA_ARGS__)
160#endif
161
162/* Summary debugging messages */
163#ifdef JFFS2_DBG_SUMMARY_MESSAGES
164#define dbg_summary(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
165#else
166#define dbg_summary(fmt, ...) no_printk(fmt, ##__VA_ARGS__)
167#endif
168
169/* File system build messages */
170#ifdef JFFS2_DBG_FSBUILD_MESSAGES
171#define dbg_fsbuild(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
172#else
173#define dbg_fsbuild(fmt, ...) no_printk(fmt, ##__VA_ARGS__)
174#endif
175
176/* Watch the object allocations */
177#ifdef JFFS2_DBG_MEMALLOC_MESSAGES
178#define dbg_memalloc(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
179#else
180#define dbg_memalloc(fmt, ...) no_printk(fmt, ##__VA_ARGS__)
181#endif
182
183/* Watch the XATTR subsystem */
184#ifdef JFFS2_DBG_XATTR_MESSAGES
185#define dbg_xattr(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
186#else
187#define dbg_xattr(fmt, ...) no_printk(fmt, ##__VA_ARGS__)
188#endif
189
190/* "Sanity" checks */
191void
192__jffs2_dbg_acct_sanity_check_nolock(struct jffs2_sb_info *c,
193 struct jffs2_eraseblock *jeb);
194void
195__jffs2_dbg_acct_sanity_check(struct jffs2_sb_info *c,
196 struct jffs2_eraseblock *jeb);
197
198/* "Paranoia" checks */
199void
200__jffs2_dbg_fragtree_paranoia_check(struct jffs2_inode_info *f);
201void
202__jffs2_dbg_fragtree_paranoia_check_nolock(struct jffs2_inode_info *f);
203void
204__jffs2_dbg_acct_paranoia_check(struct jffs2_sb_info *c,
205 struct jffs2_eraseblock *jeb);
206void
207__jffs2_dbg_acct_paranoia_check_nolock(struct jffs2_sb_info *c,
208 struct jffs2_eraseblock *jeb);
209void
210__jffs2_dbg_prewrite_paranoia_check(struct jffs2_sb_info *c,
211 uint32_t ofs, int len);
212
213/* "Dump" functions */
214void
215__jffs2_dbg_dump_jeb(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb);
216void
217__jffs2_dbg_dump_jeb_nolock(struct jffs2_eraseblock *jeb);
218void
219__jffs2_dbg_dump_block_lists(struct jffs2_sb_info *c);
220void
221__jffs2_dbg_dump_block_lists_nolock(struct jffs2_sb_info *c);
222void
223__jffs2_dbg_dump_node_refs(struct jffs2_sb_info *c,
224 struct jffs2_eraseblock *jeb);
225void
226__jffs2_dbg_dump_node_refs_nolock(struct jffs2_sb_info *c,
227 struct jffs2_eraseblock *jeb);
228void
229__jffs2_dbg_dump_fragtree(struct jffs2_inode_info *f);
230void
231__jffs2_dbg_dump_fragtree_nolock(struct jffs2_inode_info *f);
232void
233__jffs2_dbg_dump_buffer(unsigned char *buf, int len, uint32_t offs);
234void
235__jffs2_dbg_dump_node(struct jffs2_sb_info *c, uint32_t ofs);
236
237#ifdef JFFS2_DBG_PARANOIA_CHECKS
238#define jffs2_dbg_fragtree_paranoia_check(f) \
239 __jffs2_dbg_fragtree_paranoia_check(f)
240#define jffs2_dbg_fragtree_paranoia_check_nolock(f) \
241 __jffs2_dbg_fragtree_paranoia_check_nolock(f)
242#define jffs2_dbg_acct_paranoia_check(c, jeb) \
243 __jffs2_dbg_acct_paranoia_check(c,jeb)
244#define jffs2_dbg_acct_paranoia_check_nolock(c, jeb) \
245 __jffs2_dbg_acct_paranoia_check_nolock(c,jeb)
246#define jffs2_dbg_prewrite_paranoia_check(c, ofs, len) \
247 __jffs2_dbg_prewrite_paranoia_check(c, ofs, len)
248#else
249#define jffs2_dbg_fragtree_paranoia_check(f)
250#define jffs2_dbg_fragtree_paranoia_check_nolock(f)
251#define jffs2_dbg_acct_paranoia_check(c, jeb)
252#define jffs2_dbg_acct_paranoia_check_nolock(c, jeb)
253#define jffs2_dbg_prewrite_paranoia_check(c, ofs, len)
254#endif /* !JFFS2_PARANOIA_CHECKS */
255
256#ifdef JFFS2_DBG_DUMPS
257#define jffs2_dbg_dump_jeb(c, jeb) \
258 __jffs2_dbg_dump_jeb(c, jeb);
259#define jffs2_dbg_dump_jeb_nolock(jeb) \
260 __jffs2_dbg_dump_jeb_nolock(jeb);
261#define jffs2_dbg_dump_block_lists(c) \
262 __jffs2_dbg_dump_block_lists(c)
263#define jffs2_dbg_dump_block_lists_nolock(c) \
264 __jffs2_dbg_dump_block_lists_nolock(c)
265#define jffs2_dbg_dump_fragtree(f) \
266 __jffs2_dbg_dump_fragtree(f);
267#define jffs2_dbg_dump_fragtree_nolock(f) \
268 __jffs2_dbg_dump_fragtree_nolock(f);
269#define jffs2_dbg_dump_buffer(buf, len, offs) \
270 __jffs2_dbg_dump_buffer(*buf, len, offs);
271#define jffs2_dbg_dump_node(c, ofs) \
272 __jffs2_dbg_dump_node(c, ofs);
273#else
274#define jffs2_dbg_dump_jeb(c, jeb)
275#define jffs2_dbg_dump_jeb_nolock(jeb)
276#define jffs2_dbg_dump_block_lists(c)
277#define jffs2_dbg_dump_block_lists_nolock(c)
278#define jffs2_dbg_dump_fragtree(f)
279#define jffs2_dbg_dump_fragtree_nolock(f)
280#define jffs2_dbg_dump_buffer(buf, len, offs)
281#define jffs2_dbg_dump_node(c, ofs)
282#endif /* !JFFS2_DBG_DUMPS */
283
284#ifdef JFFS2_DBG_SANITY_CHECKS
285#define jffs2_dbg_acct_sanity_check(c, jeb) \
286 __jffs2_dbg_acct_sanity_check(c, jeb)
287#define jffs2_dbg_acct_sanity_check_nolock(c, jeb) \
288 __jffs2_dbg_acct_sanity_check_nolock(c, jeb)
289#else
290#define jffs2_dbg_acct_sanity_check(c, jeb)
291#define jffs2_dbg_acct_sanity_check_nolock(c, jeb)
292#endif /* !JFFS2_DBG_SANITY_CHECKS */
293
294#endif /* _JFFS2_DEBUG_H_ */
Definition: nodelist.h:278
Definition: jffs2_fs_i.h:20
Definition: jffs2_fs_sb.h:51