mtd/fs/jffs3 debug.h,1.4,1.5
Artem Bityuckiy
dedekind at infradead.org
Fri Dec 17 08:38:34 EST 2004
Update of /home/cvs/mtd/fs/jffs3
In directory phoenix.infradead.org:/tmp/cvs-serv15067
Modified Files:
debug.h
Log Message:
Fix messaging. Add wbuf sanity check func.
Index: debug.h
===================================================================
RCS file: /home/cvs/mtd/fs/jffs3/debug.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- debug.h 16 Dec 2004 16:46:34 -0000 1.4
+++ debug.h 17 Dec 2004 13:38:31 -0000 1.5
@@ -27,6 +27,7 @@
#define JFFS3_DBG_OTHER 1 /* Not classified */
#define JFFS3_DBG_SCAN 2 /* Flash scan */
#define JFFS3_DBG_GC 3 /* Garbage Collector */
+#define JFFS3_DBG_WBUF 4 /* Write buffer */
#if CONFIG_JFFS3_FS_DEBUG > 0
#define JFFS3_DBG_PARANOIA_CHECKS 1
@@ -34,10 +35,12 @@
#define JFFS3_DBG_SUBSYS_OTHER_PRINT 1
#define JFFS3_DBG_SUBSYS_SCAN_PRINT 1
#define JFFS3_DBG_SUBSYS_GC_PRINT 1
+#define JFFS3_DBG_SUBSYS_WBUF_PRINT 1
#else
#define JFFS3_DBG_SUBSYS_OTHER_PRINT 0
#define JFFS3_DBG_SUBSYS_SCAN_PRINT 0
#define JFFS3_DBG_SUBSYS_GC_PRINT 0
+#define JFFS3_DBG_SUBSYS_WBUF_PRINT 0
#endif
/*
@@ -50,13 +53,16 @@
char *subsysname = NULL; \
if ((debug_level) >= CONFIG_JFFS3_FS_DEBUG) { \
switch (subsystem) { \
- case JFFS3_DBG_GC: \
- if (JFFS3_DBG_SUBSYS_GC_PRINT) \
- subsysname = "GC"; \
case JFFS3_DBG_SCAN: \
if (JFFS3_DBG_SUBSYS_SCAN_PRINT) \
subsysname = "scan"; \
break; \
+ case JFFS3_DBG_GC: \
+ if (JFFS3_DBG_SUBSYS_GC_PRINT) \
+ subsysname = "GC"; \
+ case JFFS3_DBG_WBUF: \
+ if (JFFS3_DBG_SUBSYS_GC_PRINT) \
+ subsysname = "wbuf"; \
case JFFS3_DBG_OTHER: \
if (JFFS3_DBG_SUBSYS_OTHER_PRINT) \
subsysname = ""; \
@@ -85,6 +91,9 @@
#define DBG_GC(debug_level, args...) \
JFFS3DBG_SUBSYSTEM(JFFS3_DBG_GC, debug_level, args)
+#define DBG_WBUF(debug_level, args...) \
+ JFFS3DBG_SUBSYSTEM(JFFS3_DBG_WBUF, debug_level, args)
+
#define ERROR_MSG(args...) \
do { \
printk(KERN_ERR "[JFFS3] Error in %s(): ", __FUNCTION__); \
@@ -119,6 +128,9 @@
void
jffs3_dbg_print_frag_list(struct jffs3_inode_info *f);
+
+void
+jffs3_dbg_dump_buffer(char *buf, int len, uint32_t offs)
#endif
@@ -131,7 +143,7 @@
{
if (unlikely(jeb && jeb->used_size + jeb->dirty_size + jeb->free_size
+ jeb->wasted_size + jeb->unchecked_size != c->sector_size)) {
- printk(KERN_ERR "Eeep. Space accounting for block at 0x%08x is screwed\n", jeb->offset);
+ ERROR_MSG("Eeep. Space accounting for block at 0x%08x is screwed\n", jeb->offset);
printk(KERN_ERR "free %#08x + dirty %#08x + used %#08x + wasted %#08x + unchecked "
"%#08x != total %#08x\n", jeb->free_size, jeb->dirty_size, jeb->used_size,
jeb->wasted_size, jeb->unchecked_size, c->sector_size);
@@ -140,7 +152,7 @@
if (unlikely(c->used_size + c->dirty_size + c->free_size + c->erasing_size + c->bad_size
+ c->wasted_size + c->unchecked_size != c->flash_size)) {
- printk(KERN_ERR "Eeep. Space accounting superblock info is screwed\n");
+ ERROR_MSG("Eeep. Space accounting superblock info is screwed\n");
printk(KERN_ERR "free %#08x + dirty %#08x + used %#08x + erasing %#08x + bad %#08x + "
"wasted %#08x + unchecked %#08x != total %#08x\n",
c->free_size, c->dirty_size, c->used_size, c->erasing_size, c->bad_size,
@@ -148,11 +160,33 @@
BUG();
}
}
+
+/*
+ * Check the wbuf accounting.
+ */
+static inline void
+jffs3_dbg_wbuf_acct_sanity_check(struct jffs3_sb_info *c, struct jffs3_eraseblock *jeb)
+{
+ if (jeb->free_size < (c->wbuf_pagesize - c->wbuf_len)) {
+ ERROR_MSG("Accounting error. wbuf at %#08x has %#03x bytes, %#03x left.\n",
+ c->wbuf_ofs, c->wbuf_len, c->wbuf_pagesize-c->wbuf_len);
+ ERROR_MSG("But free_size for block at %#08x is only %#08x\n",
+ jeb->offset, jeb->free_size);
+ BUG();
+ }
+}
+
#else
+
static inline void
jffs3_dbg_acct_sanity_check(struct jffs3_sb_info *c, struct jffs3_eraseblock *jeb)
{
}
+
+jffs3_dbg_wbuf_acct_sanity_check(struct jffs3_sb_info *c, struct jffs3_eraseblock *jeb)
+{
+}
+
#endif /* JFFS3_DBG_SANITY_CHECKS */
#endif /* __JFFS3_DEBUG_H__ */
More information about the linux-mtd-cvs
mailing list