RTEMS: cpukit/libfs/src/jffs2/src/debug.h Source File

| RTEMS 5.4-rc2

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/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/* Enable "paranoia" checks and dumps */
24#define JFFS2_DBG_PARANOIA_CHECKS
25#define JFFS2_DBG_DUMPS
26
27/*
28 * By defining/undefining the below macros one may select debugging messages
29 * fro specific JFFS2 subsystems.
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/* Sanity checks are supposed to be light-weight and enabled by default */
47#define JFFS2_DBG_SANITY_CHECKS
48
49/*
50 * Dx() are mainly used for debugging messages, they must go away and be
51 * superseded by nicer dbg_xxx() macros...
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/* The prefixes of JFFS2 messages */
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/* JFFS2 message macros */
78#ifndef __rtems__
79#define JFFS2_ERROR(fmt, ...) \
80 pr_err("error: (%d) %s: " fmt, \
81 task_pid_nr(current), __func__, ##__VA_ARGS__)
82
83#define JFFS2_WARNING(fmt, ...) \
84 pr_warn("warning: (%d) %s: " fmt, \
85 task_pid_nr(current), __func__, ##__VA_ARGS__)
86
87#define JFFS2_NOTICE(fmt, ...) \
88 pr_notice("notice: (%d) %s: " fmt, \
89 task_pid_nr(current), __func__, ##__VA_ARGS__)
90
91#define JFFS2_DEBUG(fmt, ...) \
92 printk(KERN_DEBUG "[JFFS2 DBG] (%d) %s: " fmt, \
93 task_pid_nr(current), __func__, ##__VA_ARGS__)
94#else /* __rtems__ */
95#define JFFS2_ERROR(fmt, ...) \
96 pr_err("error: %s: " fmt, \
97 __func__, ##__VA_ARGS__)
98
99#define JFFS2_WARNING(fmt, ...) \
100 pr_warn("warning: %s: " fmt, \
101 __func__, ##__VA_ARGS__)
102
103#define JFFS2_NOTICE(fmt, ...) \
104 pr_notice("notice: %s: " fmt, \
105 __func__, ##__VA_ARGS__)
106
107#define JFFS2_DEBUG(fmt, ...) \
108 printk(KERN_DEBUG "[JFFS2 DBG] %s: " fmt, \
109 __func__, ##__VA_ARGS__)
110#endif /* __rtems__ */
111
112/*
113 * We split our debugging messages on several parts, depending on the JFFS2
114 * subsystem the message belongs to.
115 */
116/* Read inode debugging messages */
117#ifdef JFFS2_DBG_READINODE_MESSAGES
118#define dbg_readinode(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
119#else
120#define dbg_readinode(fmt, ...)
121#endif
122#ifdef JFFS2_DBG_READINODE2_MESSAGES
123#define dbg_readinode2(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
124#else
125#define dbg_readinode2(fmt, ...)
126#endif
127
128/* Fragtree build debugging messages */
129#ifdef JFFS2_DBG_FRAGTREE_MESSAGES
130#define dbg_fragtree(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
131#else
132#define dbg_fragtree(fmt, ...)
133#endif
134#ifdef JFFS2_DBG_FRAGTREE2_MESSAGES
135#define dbg_fragtree2(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
136#else
137#define dbg_fragtree2(fmt, ...)
138#endif
139
140/* Directory entry list manilulation debugging messages */
141#ifdef JFFS2_DBG_DENTLIST_MESSAGES
142#define dbg_dentlist(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
143#else
144#define dbg_dentlist(fmt, ...)
145#endif
146
147/* Print the messages about manipulating node_refs */
148#ifdef JFFS2_DBG_NODEREF_MESSAGES
149#define dbg_noderef(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
150#else
151#define dbg_noderef(fmt, ...)
152#endif
153
154/* Manipulations with the list of inodes (JFFS2 inocache) */
155#ifdef JFFS2_DBG_INOCACHE_MESSAGES
156#define dbg_inocache(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
157#else
158#define dbg_inocache(fmt, ...)
159#endif
160
161/* Summary debugging messages */
162#ifdef JFFS2_DBG_SUMMARY_MESSAGES
163#define dbg_summary(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
164#else
165#define dbg_summary(fmt, ...)
166#endif
167
168/* File system build messages */
169#ifdef JFFS2_DBG_FSBUILD_MESSAGES
170#define dbg_fsbuild(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
171#else
172#define dbg_fsbuild(fmt, ...)
173#endif
174
175/* Watch the object allocations */
176#ifdef JFFS2_DBG_MEMALLOC_MESSAGES
177#define dbg_memalloc(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
178#else
179#define dbg_memalloc(fmt, ...)
180#endif
181
182/* Watch the XATTR subsystem */
183#ifdef JFFS2_DBG_XATTR_MESSAGES
184#define dbg_xattr(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
185#else
186#define dbg_xattr(fmt, ...)
187#endif
188
189/* "Sanity" checks */
190void
191__jffs2_dbg_acct_sanity_check_nolock(struct jffs2_sb_info *c,
192 struct jffs2_eraseblock *jeb);
193void
194__jffs2_dbg_acct_sanity_check(struct jffs2_sb_info *c,
195 struct jffs2_eraseblock *jeb);
196
197/* "Paranoia" checks */
198void
199__jffs2_dbg_fragtree_paranoia_check(struct jffs2_inode_info *f);
200void
201__jffs2_dbg_fragtree_paranoia_check_nolock(struct jffs2_inode_info *f);
202void
203__jffs2_dbg_acct_paranoia_check(struct jffs2_sb_info *c,
204 struct jffs2_eraseblock *jeb);
205void
206__jffs2_dbg_acct_paranoia_check_nolock(struct jffs2_sb_info *c,
207 struct jffs2_eraseblock *jeb);
208void
209__jffs2_dbg_prewrite_paranoia_check(struct jffs2_sb_info *c,
210 uint32_t ofs, int len);
211
212/* "Dump" functions */
213void
214__jffs2_dbg_dump_jeb(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb);
215void
216__jffs2_dbg_dump_jeb_nolock(struct jffs2_eraseblock *jeb);
217void
218__jffs2_dbg_dump_block_lists(struct jffs2_sb_info *c);
219void
220__jffs2_dbg_dump_block_lists_nolock(struct jffs2_sb_info *c);
221void
222__jffs2_dbg_dump_node_refs(struct jffs2_sb_info *c,
223 struct jffs2_eraseblock *jeb);
224void
225__jffs2_dbg_dump_node_refs_nolock(struct jffs2_sb_info *c,
226 struct jffs2_eraseblock *jeb);
227void
228__jffs2_dbg_dump_fragtree(struct jffs2_inode_info *f);
229void
230__jffs2_dbg_dump_fragtree_nolock(struct jffs2_inode_info *f);
231void
232__jffs2_dbg_dump_buffer(unsigned char *buf, int len, uint32_t offs);
233void
234__jffs2_dbg_dump_node(struct jffs2_sb_info *c, uint32_t ofs);
235
236#ifdef JFFS2_DBG_PARANOIA_CHECKS
237#define jffs2_dbg_fragtree_paranoia_check(f) \
238 __jffs2_dbg_fragtree_paranoia_check(f)
239#define jffs2_dbg_fragtree_paranoia_check_nolock(f) \
240 __jffs2_dbg_fragtree_paranoia_check_nolock(f)
241#define jffs2_dbg_acct_paranoia_check(c, jeb) \
242 __jffs2_dbg_acct_paranoia_check(c,jeb)
243#define jffs2_dbg_acct_paranoia_check_nolock(c, jeb) \
244 __jffs2_dbg_acct_paranoia_check_nolock(c,jeb)
245#define jffs2_dbg_prewrite_paranoia_check(c, ofs, len) \
246 __jffs2_dbg_prewrite_paranoia_check(c, ofs, len)
247#else
248#define jffs2_dbg_fragtree_paranoia_check(f)
249#define jffs2_dbg_fragtree_paranoia_check_nolock(f)
250#define jffs2_dbg_acct_paranoia_check(c, jeb)
251#define jffs2_dbg_acct_paranoia_check_nolock(c, jeb)
252#define jffs2_dbg_prewrite_paranoia_check(c, ofs, len)
253#endif /* !JFFS2_PARANOIA_CHECKS */
254
255#ifdef JFFS2_DBG_DUMPS
256#define jffs2_dbg_dump_jeb(c, jeb) \
257 __jffs2_dbg_dump_jeb(c, jeb);
258#define jffs2_dbg_dump_jeb_nolock(jeb) \
259 __jffs2_dbg_dump_jeb_nolock(jeb);
260#define jffs2_dbg_dump_block_lists(c) \
261 __jffs2_dbg_dump_block_lists(c)
262#define jffs2_dbg_dump_block_lists_nolock(c) \
263 __jffs2_dbg_dump_block_lists_nolock(c)
264#define jffs2_dbg_dump_fragtree(f) \
265 __jffs2_dbg_dump_fragtree(f);
266#define jffs2_dbg_dump_fragtree_nolock(f) \
267 __jffs2_dbg_dump_fragtree_nolock(f);
268#define jffs2_dbg_dump_buffer(buf, len, offs) \
269 __jffs2_dbg_dump_buffer(*buf, len, offs);
270#define jffs2_dbg_dump_node(c, ofs) \
271 __jffs2_dbg_dump_node(c, ofs);
272#else
273#define jffs2_dbg_dump_jeb(c, jeb)
274#define jffs2_dbg_dump_jeb_nolock(jeb)
275#define jffs2_dbg_dump_block_lists(c)
276#define jffs2_dbg_dump_block_lists_nolock(c)
277#define jffs2_dbg_dump_fragtree(f)
278#define jffs2_dbg_dump_fragtree_nolock(f)
279#define jffs2_dbg_dump_buffer(buf, len, offs)
280#define jffs2_dbg_dump_node(c, ofs)
281#endif /* !JFFS2_DBG_DUMPS */
282
283#ifdef JFFS2_DBG_SANITY_CHECKS
284#define jffs2_dbg_acct_sanity_check(c, jeb) \
285 __jffs2_dbg_acct_sanity_check(c, jeb)
286#define jffs2_dbg_acct_sanity_check_nolock(c, jeb) \
287 __jffs2_dbg_acct_sanity_check_nolock(c, jeb)
288#else
289#define jffs2_dbg_acct_sanity_check(c, jeb)
290#define jffs2_dbg_acct_sanity_check_nolock(c, jeb)
291#endif /* !JFFS2_DBG_SANITY_CHECKS */
292
293#endif /* _JFFS2_DEBUG_H_ */
jffs2_eraseblock
Definition: nodelist.h:278
jffs2_inode_info
Definition: jffs2_fs_i.h:20
jffs2_sb_info
Definition: jffs2_fs_sb.h:48