mtd/fs/jffs2 debug.c, 1.3, 1.4 debug.h, 1.2, 1.3 erase.c, 1.81, 1.82 nodemgmt.c, 1.123, 1.124 scan.c, 1.120, 1.121 wbuf.c, 1.94, 1.95

Artem Bityuckiy dedekind at infradead.org
Wed Jul 20 11:32:32 EDT 2005


Update of /home/cvs/mtd/fs/jffs2
In directory phoenix.infradead.org:/tmp/cvs-serv15688

Modified Files:
	debug.c debug.h erase.c nodemgmt.c scan.c wbuf.c 
Log Message:
[JFFS2] Various debugging stuff updates and fixes



Index: debug.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/debug.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- debug.c	18 Jul 2005 12:37:11 -0000	1.3
+++ debug.c	20 Jul 2005 15:32:28 -0000	1.4
@@ -93,7 +93,7 @@
 
 	if (ret) {
 		printk(KERN_ERR "ARGH. About to write node to %#08x on flash, but there are data "
-				"already there. The first corrupted byte is at %#08x.\n", ofs, ofs + i);
+				"already there. The first corrupted byte is at %#08x offset.\n", ofs, ofs + i);
 		jffs2_dbg_dump_buffer(buf, len, ofs);
 		kfree(buf);
 		BUG();
@@ -108,6 +108,14 @@
 void
 jffs2_dbg_acct_paranoia_check(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb)
 {
+	spin_lock(&c->erase_completion_lock);
+	jffs2_dbg_acct_paranoia_check_nolock(c, jeb);
+	spin_unlock(&c->erase_completion_lock);
+}
+	
+void
+jffs2_dbg_acct_paranoia_check_nolock(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb)
+{
 	uint32_t my_used_size = 0;
 	uint32_t my_unchecked_size = 0;
 	uint32_t my_dirty_size = 0;
@@ -121,6 +129,7 @@
 			printk(KERN_ERR "node_ref %#08x shouldn't be in block at %#08x!\n",
 				ref_offset(ref2), jeb->offset);
 			jffs2_dbg_dump_node_refs(c, jeb);
+			jffs2_dbg_dump_jeb(jeb);
 			jffs2_dbg_dump_block_lists(c);
 			BUG();
 
@@ -138,6 +147,7 @@
 					ref_offset(ref2), ref2, ref_offset(ref2->next_phys), ref2->next_phys,
 					ref_offset(jeb->last_node), jeb->last_node);
 			jffs2_dbg_dump_node_refs(c, jeb);
+			jffs2_dbg_dump_jeb(jeb);
 			jffs2_dbg_dump_block_lists(c);
 			BUG();
 		}
@@ -148,6 +158,7 @@
 		printk(KERN_ERR "Calculated used size %#08x != stored used size %#08x\n",
 				my_used_size, jeb->used_size);
 		jffs2_dbg_dump_node_refs(c, jeb);
+		jffs2_dbg_dump_jeb(jeb);
 		jffs2_dbg_dump_block_lists(c);
 		BUG();
 	}
@@ -156,6 +167,7 @@
 		printk(KERN_ERR "Calculated unchecked size %#08x != stored unchecked size %#08x\n",
 				my_unchecked_size, jeb->unchecked_size);
 		jffs2_dbg_dump_node_refs(c, jeb);
+		jffs2_dbg_dump_jeb(jeb);
 		jffs2_dbg_dump_block_lists(c);
 		BUG();
 	}
@@ -166,6 +178,7 @@
 		printk(KERN_ERR "Calculated dirty+wasted size %#08x != stored dirty + wasted size %#08x\n",
 			my_dirty_size, jeb->dirty_size + jeb->wasted_size);
 		jffs2_dbg_dump_node_refs(c, jeb);
+		jffs2_dbg_dump_jeb(jeb);
 		jffs2_dbg_dump_block_lists(c);
 		BUG();
 	}
@@ -176,6 +189,7 @@
 			my_used_size + my_unchecked_size + my_dirty_size,
 			c->sector_size);
 		jffs2_dbg_dump_node_refs(c, jeb);
+		jffs2_dbg_dump_jeb(jeb);
 		jffs2_dbg_dump_block_lists(c);
 		BUG();
 	}
@@ -193,6 +207,7 @@
 	struct jffs2_raw_node_ref *ref;
 	int i = 0;
 
+	printk(KERN_DEBUG "Dump the node_ref oth the eraseblock %#08x\n", jeb->offset);
 	if (!jeb->first_node) {
 		printk(KERN_DEBUG "no nodes in block %#08x\n", jeb->offset);
 		return;
@@ -214,8 +229,22 @@
 }
 
 void
+jffs2_dbg_dump_jeb(struct jffs2_eraseblock *jeb)
+{
+	printk(KERN_DEBUG "dump space accounting for the eraseblock at %#08x\n",
+			jeb->offset);
+
+	printk(KERN_DEBUG "used_size: %#08x\n",		jeb->used_size);
+	printk(KERN_DEBUG "dirty_size: %#08x\n",	jeb->dirty_size);
+	printk(KERN_DEBUG "wasted_size: %#08x\n",	jeb->wasted_size);
+	printk(KERN_DEBUG "unchecked_size: %#08x\n",	jeb->unchecked_size);
+	printk(KERN_DEBUG "free_size: %#08x\n",		jeb->free_size);
+}
+
+void
 jffs2_dbg_dump_block_lists(struct jffs2_sb_info *c)
 {
+	printk(KERN_DEBUG "Dump the blocks list\n");
 	printk(KERN_DEBUG "flash_size: %#08x\n",	c->flash_size);
 	printk(KERN_DEBUG "used_size: %#08x\n",		c->used_size);
 	printk(KERN_DEBUG "dirty_size: %#08x\n",	c->dirty_size);
@@ -443,7 +472,7 @@
 	uint32_t lastofs = 0;
 	int buggy = 0;
 
-	printk(KERN_DEBUG "inode is ino #%u\n", f->inocache->ino);
+	printk(KERN_DEBUG "Dump fragtree of ino #%u\n", f->inocache->ino);
 	while(this) {
 		if (this->node)
 			printk(KERN_DEBUG "frag %#04x-%#04x: %#08x(%d) on flash (*%p), left (%p), "
@@ -470,28 +499,37 @@
 	}
 }
 
-#define JFFS2_BUFDUMP_BYTES_PER_LINE	8
+#define JFFS2_BUFDUMP_BYTES_PER_LINE	32
 void
-jffs2_dbg_dump_buffer(char *buf, int len, uint32_t offs)
+jffs2_dbg_dump_buffer(unsigned char *buf, int len, uint32_t offs)
 {
-	int i = 0;
-	int skip = offs & ~(JFFS2_BUFDUMP_BYTES_PER_LINE - 1);
+	int skip;
+	int i;
+	
+	printk(KERN_DEBUG "Dump from offset %#08x to offset %#08x (%x bytes)\n",
+			offs, offs + len, len);
+	i = skip = offs % JFFS2_BUFDUMP_BYTES_PER_LINE;
+	offs = offs & ~(JFFS2_BUFDUMP_BYTES_PER_LINE - 1);
+	
+	if (skip != 0)
+		printk(KERN_DEBUG "%08d: ", offs);
+	
+	while (skip--)
+		printk("   ");
 
 	while (i < len) {
-		int j = 0;
-
-		printk(KERN_DEBUG "0x#x: \n");
-		while (skip) {
-			printk("   ");
-			skip -= 1;
+		if ((i % JFFS2_BUFDUMP_BYTES_PER_LINE) == 0 && i != len -1) {
+			if (i != 0)
+				printk("\n");
+			offs += JFFS2_BUFDUMP_BYTES_PER_LINE;
+			printk(KERN_DEBUG "%08d: ", offs);
 		}
 
-		while (j < JFFS2_BUFDUMP_BYTES_PER_LINE) {
-			if (i + j < len)
-				printk(" %#02x", buf[i + j++]);
-		}
-
-		i += JFFS2_BUFDUMP_BYTES_PER_LINE;
+		printk("%02x ", buf[i]);
+		
+		i += 1;
 	}
+
+	printk("\n");
 }
 #endif /* JFFS2_DBG_DUMPS */

Index: debug.h
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/debug.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- debug.h	17 Jul 2005 11:54:40 -0000	1.2
+++ debug.h	20 Jul 2005 15:32:28 -0000	1.3
@@ -57,12 +57,22 @@
 			      struct jffs2_eraseblock *jeb);
 
 void
+jffs2_dbg_acct_paranoia_check_nolock(struct jffs2_sb_info *c,
+				     struct jffs2_eraseblock *jeb);
+
+void
 jffs2_dbg_prewrite_paranoia_check(struct jffs2_sb_info *c,
 				  uint32_t ofs, int len);
+
+void
+jffs2_dbg_dump_jeb(struct jffs2_eraseblock *jeb);
+
 #else
 #define jffs2_dbg_fragtree_paranoia_check(f)
 #define jffs2_dbg_acct_paranoia_check(c, jeb)
+#define jffs2_dbg_acct_paranoia_check_nolock(c, jeb)
 #define jffs2_dbg_prewrite_paranoia_check(c, ofs, len)
+#define jffs2_dbg_dump_jeb(jeb)
 #endif /* !JFFS2_PARANOIA_CHECKS */
 
 #ifdef JFFS2_DBG_DUMPS
@@ -76,7 +86,7 @@
 jffs2_dbg_dump_fragtree(struct jffs2_inode_info *f);
 
 void
-jffs2_dbg_dump_buffer(char *buf, int len, uint32_t offs);
+jffs2_dbg_dump_buffer(unsigned char *buf, int len, uint32_t offs);
 #else
 #define jffs2_dbg_dump_block_lists(c)
 #define jffs2_dbg_dump_node_refs(c, jeb)
@@ -90,8 +100,8 @@
  * the JFFS2 erasable block 'jeb'.
  */
 static inline void
-jffs2_dbg_acct_sanity_check(struct jffs2_sb_info *c,
-			    struct jffs2_eraseblock *jeb)
+jffs2_dbg_acct_sanity_check_nolock(struct jffs2_sb_info *c,
+				   struct jffs2_eraseblock *jeb)
 {
 	if (unlikely(jeb && jeb->used_size + jeb->dirty_size +
 			jeb->free_size + jeb->wasted_size +
@@ -113,8 +123,19 @@
 		BUG();
 	}
 }
+
+static inline void
+jffs2_dbg_acct_sanity_check(struct jffs2_sb_info *c,
+			    struct jffs2_eraseblock *jeb)
+{
+	spin_lock(&c->erase_completion_lock);
+	jffs2_dbg_acct_sanity_check_nolock(c, jeb);
+	spin_unlock(&c->erase_completion_lock);
+}
+
 #else
 #define jffs2_dbg_acct_sanity_check(c, jeb)
+#define jffs2_dbg_acct_sanity_check_nolock(c, jeb)
 #endif /* !JFFS2_DBG_SANITY_CHECKS */
 
 #endif /* _JFFS2_DEBUG_H_ */

Index: erase.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/erase.c,v
retrieving revision 1.81
retrieving revision 1.82
diff -u -r1.81 -r1.82
--- erase.c	17 Jul 2005 06:56:20 -0000	1.81
+++ erase.c	20 Jul 2005 15:32:28 -0000	1.82
@@ -429,8 +429,8 @@
 	c->free_size += jeb->free_size;
 	c->used_size += jeb->used_size;
 
-	jffs2_dbg_acct_sanity_check(c,jeb);
-	jffs2_dbg_acct_paranoia_check(c, jeb);
+	jffs2_dbg_acct_sanity_check_nolock(c,jeb);
+	jffs2_dbg_acct_paranoia_check_nolock(c, jeb);
 
 	list_add_tail(&jeb->list, &c->free_list);
 	c->nr_erasing_blocks--;

Index: nodemgmt.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/nodemgmt.c,v
retrieving revision 1.123
retrieving revision 1.124
diff -u -r1.123 -r1.124
--- nodemgmt.c	17 Jul 2005 06:56:21 -0000	1.123
+++ nodemgmt.c	20 Jul 2005 15:32:28 -0000	1.124
@@ -349,8 +349,8 @@
 		list_add_tail(&jeb->list, &c->clean_list);
 		c->nextblock = NULL;
 	}
-	jffs2_dbg_acct_sanity_check(c,jeb);
-	jffs2_dbg_acct_paranoia_check(c, jeb);
+	jffs2_dbg_acct_sanity_check_nolock(c,jeb);
+	jffs2_dbg_acct_paranoia_check_nolock(c, jeb);
 
 	spin_unlock(&c->erase_completion_lock);
 
@@ -430,7 +430,7 @@
 			       ref_totlen(c, jeb, ref), blocknr, ref->flash_offset, jeb->used_size);
 			BUG();
 		})
-		D1(printk(KERN_DEBUG "Obsoleting node at 0x%08x of len %x: ", ref_offset(ref), ref_totlen(c, jeb, ref)));
+		D1(printk(KERN_DEBUG "Obsoleting node at 0x%08x of len %#x: ", ref_offset(ref), ref_totlen(c, jeb, ref)));
 		jeb->used_size -= ref_totlen(c, jeb, ref);
 		c->used_size -= ref_totlen(c, jeb, ref);
 	}
@@ -466,9 +466,8 @@
 	}
 	ref->flash_offset = ref_offset(ref) | REF_OBSOLETE;
 	
-	jffs2_dbg_acct_sanity_check(c, jeb);
-
-	jffs2_dbg_acct_paranoia_check(c, jeb);
+	jffs2_dbg_acct_sanity_check_nolock(c, jeb);
+	jffs2_dbg_acct_paranoia_check_nolock(c, jeb);
 
 	if (c->flags & JFFS2_SB_FLAG_SCANNING) {
 		/* Flash scanning is in progress. Don't muck about with the block

Index: scan.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/scan.c,v
retrieving revision 1.120
retrieving revision 1.121
diff -u -r1.120 -r1.121
--- scan.c	17 Jul 2005 06:56:21 -0000	1.120
+++ scan.c	20 Jul 2005 15:32:28 -0000	1.121
@@ -130,7 +130,7 @@
 		if (ret < 0)
 			goto out;
 
-		jffs2_dbg_acct_paranoia_check(c, jeb);
+		jffs2_dbg_acct_paranoia_check_nolock(c, jeb);
 
 		/* Now decide which list to put it on */
 		switch(ret) {
@@ -370,7 +370,7 @@
 scan_more:	
 	while(ofs < jeb->offset + c->sector_size) {
 
-		jffs2_dbg_acct_paranoia_check(c, jeb);
+		jffs2_dbg_acct_paranoia_check_nolock(c, jeb);
 
 		cond_resched();
 

Index: wbuf.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/wbuf.c,v
retrieving revision 1.94
retrieving revision 1.95
diff -u -r1.94 -r1.95
--- wbuf.c	17 Jul 2005 12:01:43 -0000	1.94
+++ wbuf.c	20 Jul 2005 15:32:28 -0000	1.95
@@ -162,8 +162,8 @@
 	jeb->wasted_size += jeb->free_size;
 	jeb->free_size = 0;
 
-	jffs2_dbg_acct_sanity_check(c,jeb);
-	jffs2_dbg_acct_paranoia_check(c, jeb);
+	jffs2_dbg_acct_sanity_check_nolock(c,jeb);
+	jffs2_dbg_acct_paranoia_check_nolock(c, jeb);
 }
 
 /* Recover from failure to write wbuf. Recover the nodes up to the
@@ -390,11 +390,11 @@
 	else
 		jeb->last_node = container_of(first_raw, struct jffs2_raw_node_ref, next_phys);
 
-	jffs2_dbg_acct_sanity_check(c,jeb);
-        jffs2_dbg_acct_paranoia_check(c, jeb);
+	jffs2_dbg_acct_sanity_check_nolock(c, jeb);
+        jffs2_dbg_acct_paranoia_check_nolock(c, jeb);
 
-	jffs2_dbg_acct_sanity_check(c,new_jeb);
-        jffs2_dbg_acct_paranoia_check(c, new_jeb);
+	jffs2_dbg_acct_sanity_check_nolock(c, new_jeb);
+        jffs2_dbg_acct_paranoia_check_nolock(c, new_jeb);
 
 	spin_unlock(&c->erase_completion_lock);
 





More information about the linux-mtd-cvs mailing list