aboutsummaryrefslogtreecommitdiffstats
path: root/fs/jffs2/debug.h
diff options
context:
space:
mode:
authorArtem B. Bityutskiy <dedekind@infradead.org>2005-07-24 11:14:17 -0400
committerThomas Gleixner <tglx@mtd.linutronix.de>2005-11-06 11:06:49 -0500
commite0c8e42f8f218063ff6838b25038ccef7ddf257e (patch)
treea072b5cfd6b9af41dfef13821383af584d989ca6 /fs/jffs2/debug.h
parent6dac02a5e1bba0bb88ece50160fc4a64cccf30d1 (diff)
[JFFS2] Debug code clean up - step 3
Various simplifiactions. printk format corrections. Convert more code to use the new debug functions. Signed-off-by: Artem B. Bityutskiy <dedekind@infradead.org> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'fs/jffs2/debug.h')
-rw-r--r--fs/jffs2/debug.h251
1 files changed, 217 insertions, 34 deletions
diff --git a/fs/jffs2/debug.h b/fs/jffs2/debug.h
index 7d14f7b01397..51ff099a6502 100644
--- a/fs/jffs2/debug.h
+++ b/fs/jffs2/debug.h
@@ -7,7 +7,7 @@
7 * 7 *
8 * For licensing information, see the file 'LICENCE' in this directory. 8 * For licensing information, see the file 'LICENCE' in this directory.
9 * 9 *
10 * $Id: debug.h,v 1.1 2005/07/17 06:56:20 dedekind Exp $ 10 * $Id: debug.h,v 1.5 2005/07/24 15:14:14 dedekind Exp $
11 * 11 *
12 */ 12 */
13#ifndef _JFFS2_DEBUG_H_ 13#ifndef _JFFS2_DEBUG_H_
@@ -15,12 +15,52 @@
15 15
16#include <linux/config.h> 16#include <linux/config.h>
17 17
18/* ------------------------------------------------ */
19/* TODO: remove */
20#undef CONFIG_JFFS2_FS_DEBUG
21#define CONFIG_JFFS2_FS_DEBUG 0
22//#define JFFS2_DBG_PARANOIA_CHECKS
23//#define JFFS2_DBG_DUMPS
24#define JFFS2_DBG_READINODE_MESSAGES
25//#define JFFS2_DBG_FRAGTREE_MESSAGES
26//#define JFFS2_DBG_FRAGTREE2_MESSAGES
27#undef KERN_DEBUG
28#undef KERN_WARNING
29#undef KERN_NOTICE
30#undef KERN_ERR
31#define KERN_DEBUG KERN_CRIT
32#define KERN_WARNING KERN_CRIT
33#define KERN_NOTICE KERN_CRIT
34#define KERN_ERR KERN_CRIT
35/* ------------------------------------------------ */
36
18#ifndef CONFIG_JFFS2_FS_DEBUG 37#ifndef CONFIG_JFFS2_FS_DEBUG
19#define CONFIG_JFFS2_FS_DEBUG 1 38#define CONFIG_JFFS2_FS_DEBUG 1
20#endif 39#endif
21 40
22#if CONFIG_JFFS2_FS_DEBUG > 0 41#if CONFIG_JFFS2_FS_DEBUG == 1
42/* Enable "paranoia" checks and dumps */
23#define JFFS2_DBG_PARANOIA_CHECKS 43#define JFFS2_DBG_PARANOIA_CHECKS
44#define JFFS2_DBG_DUMPS
45#define JFFS2_DBG_READINODE_MESSAGES
46#define JFFS2_DBG_FRAGTREE_MESSAGES
47#define JFFS2_DBG_DENTLIST_MESSAGES
48#define JFFS2_DBG_NODEREF_MESSAGES
49#define JFFS2_DBG_INOCACHE_MESSAGES
50#endif
51
52#if CONFIG_JFFS2_FS_DEBUG == 2
53#define JFFS2_DBG_FRAGTREE2_MESSAGES
54#endif
55
56/* Enable JFFS2 sanity checks by default */
57#define JFFS2_DBG_SANITY_CHECKS
58
59/*
60 * Dx() are mainly used for debugging messages, they must go away and be
61 * superseded by nicer JFFS2_DBG_XXX() macros...
62 */
63#if CONFIG_JFFS2_FS_DEBUG > 0
24#define D1(x) x 64#define D1(x) x
25#else 65#else
26#define D1(x) 66#define D1(x)
@@ -32,73 +72,216 @@
32#define D2(x) 72#define D2(x)
33#endif 73#endif
34 74
35/* Enable JFFS2 sanity checks */ 75/* The prefixes of JFFS2 messages */
36#define JFFS2_DBG_SANITY_CHECKS 76#define JFFS2_DBG_MSG_PREFIX "[JFFS2 DBG]"
77#define JFFS2_ERR_MSG_PREFIX "JFFS2 error: "
78#define JFFS2_WARN_MSG_PREFIX "JFFS2 warning: "
79#define JFFS2_NOTICE_MSG_PREFIX "JFFS2 notice: "
37 80
38#if CONFIG_JFFS2_FS_DEBUG > 0 81#define JFFS2_ERR_LVL KERN_ERR
39void 82#define JFFS2_WARN_LVL KERN_WARNING
40jffs2_dbg_dump_block_lists(struct jffs2_sb_info *c); 83#define JFFS2_NOTICE_LVL KERN_NOTICE
84#define JFFS2_DBG_LVL KERN_DEBUG
41 85
42void 86/* JFFS2 message macros */
43jffs2_dbg_dump_node_refs(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb); 87#define JFFS2_ERROR(fmt, ...) \
88 do { \
89 printk(JFFS2_ERR_LVL JFFS2_ERR_MSG_PREFIX " %s: " \
90 fmt, __FUNCTION__, ##__VA_ARGS__); \
91 } while(0)
44 92
45void 93#define JFFS2_WARNING(fmt, ...) \
46jffs2_dbg_dump_fragtree(struct jffs2_inode_info *f); 94 do { \
95 printk(JFFS2_WARN_LVL JFFS2_WARN_MSG_PREFIX " %s: " \
96 fmt, __FUNCTION__, ##__VA_ARGS__); \
97 } while(0)
98
99#define JFFS2_NOTICE(fmt, ...) \
100 do { \
101 printk(JFFS2_NOTICE_LVL JFFS2_NOTICE_MSG_PREFIX " %s: " \
102 fmt, __FUNCTION__, ##__VA_ARGS__); \
103 } while(0)
47 104
48void 105#define JFFS2_DEBUG(fmt, ...) \
49jffs2_dbg_dump_buffer(char *buf, int len, uint32_t offs); 106 do { \
107 printk(JFFS2_DBG_LVL JFFS2_DBG_MSG_PREFIX " %s: " \
108 fmt, __FUNCTION__, ##__VA_ARGS__); \
109 } while(0)
110
111/*
112 * We split our debugging messages on several parts, depending on the JFFS2
113 * subsystem the message belongs to.
114 */
115/* Read inode debugging messages */
116#ifdef JFFS2_DBG_READINODE_MESSAGES
117#define JFFS2_DBG_READINODE(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
118#else
119#define JFFS2_DBG_READINODE(fmt, ...)
50#endif 120#endif
51 121
52#ifdef JFFS2_DBG_PARANOIA_CHECKS 122/* Fragtree build debugging messages */
53void 123#ifdef JFFS2_DBG_FRAGTREE_MESSAGES
54jffs2_dbg_fragtree_paranoia_check(struct jffs2_inode_info *f); 124#define JFFS2_DBG_FRAGTREE(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
125#else
126#define JFFS2_DBG_FRAGTREE(fmt, ...)
127#endif
128
129/* Directory entry list manilulation debugging messages */
130#ifdef JFFS2_DBG_DENTLIST_MESSAGES
131#define JFFS2_DBG_DENTLIST(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
132#else
133#define JFFS2_DBG_DENTLIST(fmt, ...)
134#endif
135#ifdef JFFS2_DBG_FRAGTREE2_MESSAGES
136#define JFFS2_DBG_FRAGTREE2(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
137#else
138#define JFFS2_DBG_FRAGTREE2(fmt, ...)
139#endif
140
141/* Plays with node_refs */
142#ifdef JFFS2_DBG_NODEREF_MESSAGES
143#define JFFS2_DBG_NODEREF(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
144#else
145#define JFFS2_DBG_NODEREF(fmt, ...)
146#endif
55 147
148/* Plays with the list of inodes (JFFS2 inocache) */
149#ifdef JFFS2_DBG_INOCACHE_MESSAGES
150#define JFFS2_DBG_INOCACHE(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
151#else
152#define JFFS2_DBG_INOCACHE(fmt, ...)
153#endif
154
155/* "Paranoia" checks */
156void
157__jffs2_dbg_fragtree_paranoia_check(struct jffs2_inode_info *f);
56void 158void
57jffs2_dbg_acct_paranoia_check(struct jffs2_sb_info *c, 159__jffs2_dbg_fragtree_paranoia_check_nolock(struct jffs2_inode_info *f);
58 struct jffs2_eraseblock *jeb); 160void
161__jffs2_dbg_acct_paranoia_check(struct jffs2_sb_info *c,
162 struct jffs2_eraseblock *jeb);
163void
164__jffs2_dbg_acct_paranoia_check_nolock(struct jffs2_sb_info *c,
165 struct jffs2_eraseblock *jeb);
166void
167__jffs2_dbg_prewrite_paranoia_check(struct jffs2_sb_info *c,
168 uint32_t ofs, int len);
59 169
170/* "Dump" functions */
171void
172__jffs2_dbg_dump_jeb(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb);
173void
174__jffs2_dbg_dump_jeb_nolock(struct jffs2_eraseblock *jeb);
175void
176__jffs2_dbg_dump_block_lists(struct jffs2_sb_info *c);
177void
178__jffs2_dbg_dump_block_lists_nolock(struct jffs2_sb_info *c);
179void
180__jffs2_dbg_dump_node_refs(struct jffs2_sb_info *c,
181 struct jffs2_eraseblock *jeb);
182void
183__jffs2_dbg_dump_node_refs_nolock(struct jffs2_sb_info *c,
184 struct jffs2_eraseblock *jeb);
185void
186__jffs2_dbg_dump_fragtree(struct jffs2_inode_info *f);
187void
188__jffs2_dbg_dump_fragtree_nolock(struct jffs2_inode_info *f);
60void 189void
61jffs2_dbg_prewrite_paranoia_check(struct jffs2_sb_info *c, 190__jffs2_dbg_dump_buffer(unsigned char *buf, int len, uint32_t offs);
62 uint32_t ofs, int len); 191void
192__jffs2_dbg_dump_node(struct jffs2_sb_info *c, uint32_t ofs);
193
194#ifdef JFFS2_DBG_PARANOIA_CHECKS
195#define jffs2_dbg_fragtree_paranoia_check(f) \
196 __jffs2_dbg_fragtree_paranoia_check(f)
197#define jffs2_dbg_fragtree_paranoia_check_nolock(f) \
198 __jffs2_dbg_fragtree_paranoia_check_nolock(f)
199#define jffs2_dbg_acct_paranoia_check(c, jeb) \
200 __jffs2_dbg_acct_paranoia_check(c,jeb)
201#define jffs2_dbg_acct_paranoia_check_nolock(c, jeb) \
202 __jffs2_dbg_acct_paranoia_check_nolock(c,jeb)
203#define jffs2_dbg_prewrite_paranoia_check(c, ofs, len) \
204 __jffs2_dbg_prewrite_paranoia_check(c, ofs, len)
63#else 205#else
64#define jffs2_dbg_fragtree_paranoia_check(f) 206#define jffs2_dbg_fragtree_paranoia_check(f)
207#define jffs2_dbg_fragtree_paranoia_check_nolock(f)
65#define jffs2_dbg_acct_paranoia_check(c, jeb) 208#define jffs2_dbg_acct_paranoia_check(c, jeb)
209#define jffs2_dbg_acct_paranoia_check_nolock(c, jeb)
66#define jffs2_dbg_prewrite_paranoia_check(c, ofs, len) 210#define jffs2_dbg_prewrite_paranoia_check(c, ofs, len)
67#endif /* !JFFS2_PARANOIA_CHECKS */ 211#endif /* !JFFS2_PARANOIA_CHECKS */
68 212
213#ifdef JFFS2_DBG_DUMPS
214#define jffs2_dbg_dump_jeb(c, jeb) \
215 __jffs2_dbg_dump_jeb(c, jeb);
216#define jffs2_dbg_dump_jeb_nolock(jeb) \
217 __jffs2_dbg_dump_jeb_nolock(jeb);
218#define jffs2_dbg_dump_block_lists(c) \
219 __jffs2_dbg_dump_block_lists(c)
220#define jffs2_dbg_dump_block_lists_nolock(c) \
221 __jffs2_dbg_dump_block_lists_nolock(c)
222#define jffs2_dbg_dump_fragtree(f) \
223 __jffs2_dbg_dump_fragtree(f);
224#define jffs2_dbg_dump_fragtree_nolock(f) \
225 __jffs2_dbg_dump_fragtree_nolock(f);
226#define jffs2_dbg_dump_buffer(buf, len, offs) \
227 __jffs2_dbg_dump_buffer(*buf, len, offs);
228#define jffs2_dbg_dump_node(c, ofs) \
229 __jffs2_dbg_dump_node(c, ofs);
230#else
231#define jffs2_dbg_dump_jeb(c, jeb)
232#define jffs2_dbg_dump_jeb_nolock(jeb)
233#define jffs2_dbg_dump_block_lists(c)
234#define jffs2_dbg_dump_block_lists_nolock(c)
235#define jffs2_dbg_dump_fragtree(f)
236#define jffs2_dbg_dump_fragtree_nolock(f)
237#define jffs2_dbg_dump_buffer(buf, len, offs)
238#define jffs2_dbg_dump_node(c, ofs)
239#endif /* !JFFS2_DBG_DUMPS */
240
241/*
242 * Sanity checks are supposed to be light-weight and enabled by default.
243 */
69#ifdef JFFS2_DBG_SANITY_CHECKS 244#ifdef JFFS2_DBG_SANITY_CHECKS
70/* 245/*
71 * Check the space accounting of the file system and of 246 * Check the space accounting of the file system and of
72 * the JFFS3 erasable block 'jeb'. 247 * the JFFS2 erasable block 'jeb'.
73 */ 248 */
74static inline void 249static inline void
75jffs2_dbg_acct_sanity_check(struct jffs2_sb_info *c, 250jffs2_dbg_acct_sanity_check_nolock(struct jffs2_sb_info *c,
76 struct jffs2_eraseblock *jeb) 251 struct jffs2_eraseblock *jeb)
77{ 252{
78 if (unlikely(jeb && jeb->used_size + jeb->dirty_size + 253 if (unlikely(jeb && jeb->used_size + jeb->dirty_size +
79 jeb->free_size + jeb->wasted_size + 254 jeb->free_size + jeb->wasted_size +
80 jeb->unchecked_size != c->sector_size)) { 255 jeb->unchecked_size != c->sector_size)) {
81 printk(KERN_ERR "Eeep. Space accounting for block at 0x%08x is screwed\n", jeb->offset); 256 JFFS2_ERROR("eeep, space accounting for block at 0x%08x is screwed.\n", jeb->offset);
82 printk(KERN_ERR "free %#08x + dirty %#08x + used %#08x + wasted %#08x + unchecked " 257 JFFS2_ERROR("free %#08x + dirty %#08x + used %#08x + wasted %#08x + unchecked "
83 "%#08x != total %#08x\n", jeb->free_size, jeb->dirty_size, jeb->used_size, 258 "%#08x != total %#08x.\n", jeb->free_size, jeb->dirty_size, jeb->used_size,
84 jeb->wasted_size, jeb->unchecked_size, c->sector_size); 259 jeb->wasted_size, jeb->unchecked_size, c->sector_size);
85 BUG(); 260 BUG();
86 } 261 }
87 262
88 if (unlikely(c->used_size + c->dirty_size + c->free_size + c->erasing_size + c->bad_size 263 if (unlikely(c->used_size + c->dirty_size + c->free_size + c->erasing_size + c->bad_size
89 + c->wasted_size + c->unchecked_size != c->flash_size)) { 264 + c->wasted_size + c->unchecked_size != c->flash_size)) {
90 printk(KERN_ERR "Eeep. Space accounting superblock info is screwed\n"); 265 JFFS2_ERROR("eeep, space accounting superblock info is screwed.\n");
91 printk(KERN_ERR "free %#08x + dirty %#08x + used %#08x + erasing %#08x + bad %#08x + " 266 JFFS2_ERROR("free %#08x + dirty %#08x + used %#08x + erasing %#08x + bad %#08x + "
92 "wasted %#08x + unchecked %#08x != total %#08x\n", 267 "wasted %#08x + unchecked %#08x != total %#08x.\n",
93 c->free_size, c->dirty_size, c->used_size, c->erasing_size, c->bad_size, 268 c->free_size, c->dirty_size, c->used_size, c->erasing_size, c->bad_size,
94 c->wasted_size, c->unchecked_size, c->flash_size); 269 c->wasted_size, c->unchecked_size, c->flash_size);
95 BUG(); 270 BUG();
96 } 271 }
97} 272}
98#else 273
99static inline void 274static inline void
100jffs2_dbg_acct_sanity_check(struct jffs2_sb_info *c, 275jffs2_dbg_acct_sanity_check(struct jffs2_sb_info *c,
101 struct jffs2_eraseblock *jeb); 276 struct jffs2_eraseblock *jeb)
277{
278 spin_lock(&c->erase_completion_lock);
279 jffs2_dbg_acct_sanity_check_nolock(c, jeb);
280 spin_unlock(&c->erase_completion_lock);
281}
282#else
283#define jffs2_dbg_acct_sanity_check(c, jeb)
284#define jffs2_dbg_acct_sanity_check_nolock(c, jeb)
102#endif /* !JFFS2_DBG_SANITY_CHECKS */ 285#endif /* !JFFS2_DBG_SANITY_CHECKS */
103 286
104#endif /* _JFFS2_DEBUG_H_ */ 287#endif /* _JFFS2_DEBUG_H_ */