diff options
Diffstat (limited to 'fs/jffs2/debug.h')
-rw-r--r-- | fs/jffs2/debug.h | 82 |
1 files changed, 29 insertions, 53 deletions
diff --git a/fs/jffs2/debug.h b/fs/jffs2/debug.h index 11ee75922a5e..3a7b11c2dd86 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.10 2005/08/02 10:03:51 dedekind Exp $ | 10 | * $Id: debug.h,v 1.12 2005/08/05 10:43:47 dedekind Exp $ |
11 | * | 11 | * |
12 | */ | 12 | */ |
13 | #ifndef _JFFS2_DEBUG_H_ | 13 | #ifndef _JFFS2_DEBUG_H_ |
@@ -34,7 +34,7 @@ | |||
34 | #define JFFS2_DBG_FRAGTREE2_MESSAGES | 34 | #define JFFS2_DBG_FRAGTREE2_MESSAGES |
35 | #endif | 35 | #endif |
36 | 36 | ||
37 | /* Enable JFFS2 sanity checks by default */ | 37 | /* Sanity checks are supposed to be light-weight and enabled by default */ |
38 | #define JFFS2_DBG_SANITY_CHECKS | 38 | #define JFFS2_DBG_SANITY_CHECKS |
39 | 39 | ||
40 | /* | 40 | /* |
@@ -55,9 +55,9 @@ | |||
55 | 55 | ||
56 | /* The prefixes of JFFS2 messages */ | 56 | /* The prefixes of JFFS2 messages */ |
57 | #define JFFS2_DBG_MSG_PREFIX "[JFFS2 DBG]" | 57 | #define JFFS2_DBG_MSG_PREFIX "[JFFS2 DBG]" |
58 | #define JFFS2_ERR_MSG_PREFIX "JFFS2 error: " | 58 | #define JFFS2_ERR_MSG_PREFIX "JFFS2 error:" |
59 | #define JFFS2_WARN_MSG_PREFIX "JFFS2 warning: " | 59 | #define JFFS2_WARN_MSG_PREFIX "JFFS2 warning:" |
60 | #define JFFS2_NOTICE_MSG_PREFIX "JFFS2 notice: " | 60 | #define JFFS2_NOTICE_MSG_PREFIX "JFFS2 notice:" |
61 | 61 | ||
62 | #define JFFS2_ERR_LVL KERN_ERR | 62 | #define JFFS2_ERR_LVL KERN_ERR |
63 | #define JFFS2_WARN_LVL KERN_WARNING | 63 | #define JFFS2_WARN_LVL KERN_WARNING |
@@ -67,26 +67,30 @@ | |||
67 | /* JFFS2 message macros */ | 67 | /* JFFS2 message macros */ |
68 | #define JFFS2_ERROR(fmt, ...) \ | 68 | #define JFFS2_ERROR(fmt, ...) \ |
69 | do { \ | 69 | do { \ |
70 | printk(JFFS2_ERR_LVL JFFS2_ERR_MSG_PREFIX " %s: " \ | 70 | printk(JFFS2_ERR_LVL JFFS2_ERR_MSG_PREFIX \ |
71 | fmt, __FUNCTION__, ##__VA_ARGS__); \ | 71 | " %d,%s: " fmt, current->pid, \ |
72 | __FUNCTION__, ##__VA_ARGS__); \ | ||
72 | } while(0) | 73 | } while(0) |
73 | 74 | ||
74 | #define JFFS2_WARNING(fmt, ...) \ | 75 | #define JFFS2_WARNING(fmt, ...) \ |
75 | do { \ | 76 | do { \ |
76 | printk(JFFS2_WARN_LVL JFFS2_WARN_MSG_PREFIX " %s: " \ | 77 | printk(JFFS2_WARN_LVL JFFS2_WARN_MSG_PREFIX \ |
77 | fmt, __FUNCTION__, ##__VA_ARGS__); \ | 78 | " %d,%s: " fmt, current->pid, \ |
79 | __FUNCTION__, ##__VA_ARGS__); \ | ||
78 | } while(0) | 80 | } while(0) |
79 | 81 | ||
80 | #define JFFS2_NOTICE(fmt, ...) \ | 82 | #define JFFS2_NOTICE(fmt, ...) \ |
81 | do { \ | 83 | do { \ |
82 | printk(JFFS2_NOTICE_LVL JFFS2_NOTICE_MSG_PREFIX " %s: " \ | 84 | printk(JFFS2_NOTICE_LVL JFFS2_NOTICE_MSG_PREFIX \ |
83 | fmt, __FUNCTION__, ##__VA_ARGS__); \ | 85 | " %d,%s: " fmt, current->pid, \ |
86 | __FUNCTION__, ##__VA_ARGS__); \ | ||
84 | } while(0) | 87 | } while(0) |
85 | 88 | ||
86 | #define JFFS2_DEBUG(fmt, ...) \ | 89 | #define JFFS2_DEBUG(fmt, ...) \ |
87 | do { \ | 90 | do { \ |
88 | printk(JFFS2_DBG_LVL JFFS2_DBG_MSG_PREFIX " %s: " \ | 91 | printk(JFFS2_DBG_LVL JFFS2_DBG_MSG_PREFIX \ |
89 | fmt, __FUNCTION__, ##__VA_ARGS__); \ | 92 | " %d,%s: " fmt, current->pid, \ |
93 | __FUNCTION__, ##__VA_ARGS__); \ | ||
90 | } while(0) | 94 | } while(0) |
91 | 95 | ||
92 | /* | 96 | /* |
@@ -141,6 +145,14 @@ | |||
141 | #endif | 145 | #endif |
142 | 146 | ||
143 | 147 | ||
148 | /* "Sanity" checks */ | ||
149 | void | ||
150 | __jffs2_dbg_acct_sanity_check_nolock(struct jffs2_sb_info *c, | ||
151 | struct jffs2_eraseblock *jeb); | ||
152 | void | ||
153 | __jffs2_dbg_acct_sanity_check(struct jffs2_sb_info *c, | ||
154 | struct jffs2_eraseblock *jeb); | ||
155 | |||
144 | /* "Paranoia" checks */ | 156 | /* "Paranoia" checks */ |
145 | void | 157 | void |
146 | __jffs2_dbg_fragtree_paranoia_check(struct jffs2_inode_info *f); | 158 | __jffs2_dbg_fragtree_paranoia_check(struct jffs2_inode_info *f); |
@@ -227,47 +239,11 @@ __jffs2_dbg_dump_node(struct jffs2_sb_info *c, uint32_t ofs); | |||
227 | #define jffs2_dbg_dump_node(c, ofs) | 239 | #define jffs2_dbg_dump_node(c, ofs) |
228 | #endif /* !JFFS2_DBG_DUMPS */ | 240 | #endif /* !JFFS2_DBG_DUMPS */ |
229 | 241 | ||
230 | /* | ||
231 | * Sanity checks are supposed to be light-weight and enabled by default. | ||
232 | */ | ||
233 | #ifdef JFFS2_DBG_SANITY_CHECKS | 242 | #ifdef JFFS2_DBG_SANITY_CHECKS |
234 | /* | 243 | #define jffs2_dbg_acct_sanity_check(c, jeb) \ |
235 | * Check the space accounting of the file system and of | 244 | __jffs2_dbg_acct_sanity_check(c, jeb) |
236 | * the JFFS2 erasable block 'jeb'. | 245 | #define jffs2_dbg_acct_sanity_check_nolock(c, jeb) \ |
237 | */ | 246 | __jffs2_dbg_acct_sanity_check_nolock(c, jeb) |
238 | static inline void | ||
239 | jffs2_dbg_acct_sanity_check_nolock(struct jffs2_sb_info *c, | ||
240 | struct jffs2_eraseblock *jeb) | ||
241 | { | ||
242 | if (unlikely(jeb && jeb->used_size + jeb->dirty_size + | ||
243 | jeb->free_size + jeb->wasted_size + | ||
244 | jeb->unchecked_size != c->sector_size)) { | ||
245 | JFFS2_ERROR("eeep, space accounting for block at 0x%08x is screwed.\n", jeb->offset); | ||
246 | JFFS2_ERROR("free %#08x + dirty %#08x + used %#08x + wasted %#08x + unchecked " | ||
247 | "%#08x != total %#08x.\n", jeb->free_size, jeb->dirty_size, jeb->used_size, | ||
248 | jeb->wasted_size, jeb->unchecked_size, c->sector_size); | ||
249 | BUG(); | ||
250 | } | ||
251 | |||
252 | if (unlikely(c->used_size + c->dirty_size + c->free_size + c->erasing_size + c->bad_size | ||
253 | + c->wasted_size + c->unchecked_size != c->flash_size)) { | ||
254 | JFFS2_ERROR("eeep, space accounting superblock info is screwed.\n"); | ||
255 | JFFS2_ERROR("free %#08x + dirty %#08x + used %#08x + erasing %#08x + bad %#08x + " | ||
256 | "wasted %#08x + unchecked %#08x != total %#08x.\n", | ||
257 | c->free_size, c->dirty_size, c->used_size, c->erasing_size, c->bad_size, | ||
258 | c->wasted_size, c->unchecked_size, c->flash_size); | ||
259 | BUG(); | ||
260 | } | ||
261 | } | ||
262 | |||
263 | static inline void | ||
264 | jffs2_dbg_acct_sanity_check(struct jffs2_sb_info *c, | ||
265 | struct jffs2_eraseblock *jeb) | ||
266 | { | ||
267 | spin_lock(&c->erase_completion_lock); | ||
268 | jffs2_dbg_acct_sanity_check_nolock(c, jeb); | ||
269 | spin_unlock(&c->erase_completion_lock); | ||
270 | } | ||
271 | #else | 247 | #else |
272 | #define jffs2_dbg_acct_sanity_check(c, jeb) | 248 | #define jffs2_dbg_acct_sanity_check(c, jeb) |
273 | #define jffs2_dbg_acct_sanity_check_nolock(c, jeb) | 249 | #define jffs2_dbg_acct_sanity_check_nolock(c, jeb) |