mtd/fs/jffs3 readinode.c,3.1,3.2 write.c,3.1,3.2

Artem Bityuckiy dedekind at infradead.org
Mon Dec 13 10:38:50 EST 2004


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

Modified Files:
	readinode.c write.c 
Log Message:
Move debug stuff to debug.c. Change debug calls.


Index: readinode.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs3/readinode.c,v
retrieving revision 3.1
retrieving revision 3.2
diff -u -r3.1 -r3.2
--- readinode.c	9 Dec 2004 16:05:07 -0000	3.1
+++ readinode.c	13 Dec 2004 15:38:48 -0000	3.2
@@ -23,104 +23,6 @@
 
 static int jffs3_add_frag_to_fragtree(struct jffs3_sb_info *c, struct rb_root *list, struct jffs3_node_frag *newfrag);
 
-#if CONFIG_JFFS3_FS_DEBUG >= 2
-static void jffs3_print_fragtree(struct rb_root *list, int permitbug)
-{
-	struct jffs3_node_frag *this = frag_first(list);
-	uint32_t lastofs = 0;
-	int buggy = 0;
-
-	while(this) {
-		if (this->node)
-			printk(KERN_DEBUG "frag %04x-%04x: 0x%08x(%d) on flash (*%p). left (%p), right (%p), parent (%p)\n",
-			       this->ofs, this->ofs+this->size, ref_offset(this->node->raw), ref_flags(this->node->raw),
-			       this, frag_left(this), frag_right(this), frag_parent(this));
-		else 
-			printk(KERN_DEBUG "frag %04x-%04x: hole (*%p). left (%p} right (%p), parent (%p)\n", this->ofs, 
-			       this->ofs+this->size, this, frag_left(this), frag_right(this), frag_parent(this));
-		if (this->ofs != lastofs)
-			buggy = 1;
-		lastofs = this->ofs+this->size;
-		this = frag_next(this);
-	}
-	if (buggy && !permitbug) {
-		printk(KERN_CRIT "Frag tree got a hole in it\n");
-		BUG();
-	}
-}
-
-void jffs3_print_frag_list(struct jffs3_inode_info *f)
-{
-	jffs3_print_fragtree(&f->fragtree, 0);
-
-	if (f->metadata) {
-		printk(KERN_DEBUG "metadata at 0x%08x\n", ref_offset(f->metadata->raw));
-	}
-}
-#endif
-
-#if CONFIG_JFFS3_FS_DEBUG >= 1
-static int jffs3_sanitycheck_fragtree(struct jffs3_inode_info *f)
-{
-	struct jffs3_node_frag *frag;
-	int bitched = 0;
-
-	for (frag = frag_first(&f->fragtree); frag; frag = frag_next(frag)) {
-
-		struct jffs3_full_dnode *fn = frag->node;
-		if (!fn || !fn->raw)
-			continue;
-
-		if (ref_flags(fn->raw) == REF_PRISTINE) {
-
-			if (fn->frags > 1) {
-				printk(KERN_WARNING "REF_PRISTINE node at 0x%08x had %d frags. Tell dwmw2\n", ref_offset(fn->raw), fn->frags);
-				bitched = 1;
-			}
-			/* A hole node which isn't multi-page should be garbage-collected
-			   and merged anyway, so we just check for the frag size here,
-			   rather than mucking around with actually reading the node
-			   and checking the compression type, which is the real way
-			   to tell a hole node. */
-			if (frag->ofs & (PAGE_CACHE_SIZE-1) && frag_prev(frag) && frag_prev(frag)->size < PAGE_CACHE_SIZE && frag_prev(frag)->node) {
-				printk(KERN_WARNING "REF_PRISTINE node at 0x%08x had a previous non-hole frag in the same page. Tell dwmw2\n",
-				       ref_offset(fn->raw));
-				bitched = 1;
-			}
-
-			if ((frag->ofs+frag->size) & (PAGE_CACHE_SIZE-1) && frag_next(frag) && frag_next(frag)->size < PAGE_CACHE_SIZE && frag_next(frag)->node) {
-				printk(KERN_WARNING "REF_PRISTINE node at 0x%08x (%08x-%08x) had a following non-hole frag in the same page. Tell dwmw2\n",
-				       ref_offset(fn->raw), frag->ofs, frag->ofs+frag->size);
-				bitched = 1;
-			}
-		}
-	}
-	
-	if (bitched) {
-		struct jffs3_node_frag *thisfrag;
-
-		printk(KERN_WARNING "Inode is #%u\n", f->inocache->ino);
-		thisfrag = frag_first(&f->fragtree);
-		while (thisfrag) {
-			if (!thisfrag->node) {
-				printk("Frag @0x%x-0x%x; node-less hole\n",
-				       thisfrag->ofs, thisfrag->size + thisfrag->ofs);
-			} else if (!thisfrag->node->raw) {
-				printk("Frag @0x%x-0x%x; raw-less hole\n",
-				       thisfrag->ofs, thisfrag->size + thisfrag->ofs);
-			} else {
-				printk("Frag @0x%x-0x%x; raw at 0x%08x(%d) (0x%x-0x%x)\n",
-				       thisfrag->ofs, thisfrag->size + thisfrag->ofs,
-				       ref_offset(thisfrag->node->raw), ref_flags(thisfrag->node->raw),
-				       thisfrag->node->ofs, thisfrag->node->ofs+thisfrag->node->size);
-			}
-			thisfrag = frag_next(thisfrag);
-		}
-	}
-	return bitched;
-}
-#endif /* D1 */
-
 static void jffs3_obsolete_node_frag(struct jffs3_sb_info *c, struct jffs3_node_frag *this)
 {
 	if (this->node) {
@@ -193,12 +95,8 @@
 				mark_ref_normal(next->node->raw);
 		}
 	}
-	D2(if (jffs3_sanitycheck_fragtree(f)) {
-		   printk(KERN_WARNING "Just added node %04x-%04x @0x%08x on flash, newfrag *%p\n",
-			  fn->ofs, fn->ofs+fn->size, ref_offset(fn->raw), newfrag);
-		   return 0;
-	   })
-	D2(jffs3_print_frag_list(f));
+
+	D2(jffs3_dbg_print_frag_list(f));
 	return 0;
 }
 
@@ -560,7 +458,8 @@
 		tn_list = tn->next;
 		jffs3_free_tmp_dnode_info(tn);
 	}
-	D1(jffs3_sanitycheck_fragtree(f));
+
+	jffs3_dbg_fragtree_paranoia_check(f);
 
 	if (!fn) {
 		/* No data nodes for this inode. */

Index: write.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs3/write.c,v
retrieving revision 3.1
retrieving revision 3.2
diff -u -r3.1 -r3.2
--- write.c	9 Dec 2004 16:05:08 -0000	3.1
+++ write.c	13 Dec 2004 15:38:48 -0000	3.2
@@ -21,7 +21,6 @@
 #include "nodelist.h"
 #include "compr.h"
 
-
 int jffs3_do_new_inode(struct jffs3_sb_info *c, struct jffs3_inode_info *f, uint32_t mode, struct jffs3_raw_inode *ri)
 {
 	struct jffs3_inode_cache *ic;
@@ -56,37 +55,9 @@
 	return 0;
 }
 
-#if CONFIG_JFFS3_FS_DEBUG > 0
-static void writecheck(struct jffs3_sb_info *c, uint32_t ofs)
-{
-	unsigned char buf[16];
-	size_t retlen;
-	int ret, i;
-
-	ret = jffs3_flash_read(c, ofs, 16, &retlen, buf);
-	if (ret || (retlen != 16)) {
-		D1(printk(KERN_DEBUG "read failed or short in writecheck(). ret %d, retlen %zd\n", ret, retlen));
-		return;
-	}
-	ret = 0;
-	for (i=0; i<16; i++) {
-		if (buf[i] != 0xff)
-			ret = 1;
-	}
-	if (ret) {
-		printk(KERN_WARNING "ARGH. About to write node to 0x%08x on flash, but there are data already there:\n", ofs);
-		printk(KERN_WARNING "0x%08x: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n", 
-		       ofs,
-		       buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], buf[7],
-		       buf[8], buf[9], buf[10], buf[11], buf[12], buf[13], buf[14], buf[15]);
-	}
-}
-#endif
-
 
 /* jffs3_write_dnode - given a raw_inode, allocate a full_dnode for it, 
    write it to the flash, link it into the existing inode/fragment list */
-
 struct jffs3_full_dnode *jffs3_write_dnode(struct jffs3_sb_info *c, struct jffs3_inode_info *f, struct jffs3_raw_inode *ri, const unsigned char *data, uint32_t datalen, uint32_t flash_ofs, int alloc_mode)
 
 {
@@ -108,7 +79,7 @@
 	vecs[1].iov_base = (unsigned char *)data;
 	vecs[1].iov_len = datalen;
 
-	D1(writecheck(c, flash_ofs));
+	jffs2_dbg_prewrite_paranoia_check(c, flash_ofs, vecs[0].iov_len + vecs[1].iov_len);
 
 	if (je32_to_cpu(ri->totlen) != sizeof(*ri) + datalen) {
 		printk(KERN_WARNING "jffs3_write_dnode: ri->totlen (0x%08x) != sizeof(*ri) (0x%08zx) + datalen (0x%08x)\n", je32_to_cpu(ri->totlen), sizeof(*ri), datalen);
@@ -170,8 +141,8 @@
 
 			D1(printk(KERN_DEBUG "Retrying failed write.\n"));
 			
-			ACCT_SANITY_CHECK(c,jeb);
-			D1(ACCT_PARANOIA_CHECK(jeb));
+			jffs3_dbg_acct_sanity_check(c, jeb);
+			jffs3_dbg_acct_paranoia_check(c, jeb);
 
 			if (alloc_mode == ALLOC_GC) {
 				ret = jffs3_reserve_space_gc(c, sizeof(*ri) + datalen, &flash_ofs, &dummy);
@@ -187,8 +158,8 @@
 			if (!ret) {
 				D1(printk(KERN_DEBUG "Allocated space at 0x%08x to retry failed write.\n", flash_ofs));
 
-				ACCT_SANITY_CHECK(c,jeb);
-				D1(ACCT_PARANOIA_CHECK(jeb));
+				jffs3_dbg_acct_sanity_check(c, jeb);
+				jffs3_dbg_acct_paranoia_check(c, jeb);
 
 				goto retry;
 			}
@@ -225,7 +196,7 @@
 		  je32_to_cpu(ri->data_crc), je32_to_cpu(ri->totlen)));
 
 	if (retried) {
-		ACCT_SANITY_CHECK(c,NULL);
+		jffs3_dbg_acct_sanity_check(c, NULL);
 	}
 
 	return fn;
@@ -243,7 +214,6 @@
 	D1(printk(KERN_DEBUG "jffs3_write_dirent(ino #%u, name at *0x%p \"%s\"->ino #%u, name_crc 0x%08x)\n", 
 		  je32_to_cpu(rd->pino), name, name, je32_to_cpu(rd->ino),
 		  je32_to_cpu(rd->name_crc)));
-	D1(writecheck(c, flash_ofs));
 
 	D1(if(je32_to_cpu(rd->hdr_crc) != crc32(0, rd, sizeof(struct jffs3_unknown_node)-4)) {
 		printk(KERN_CRIT "Eep. CRC not correct in jffs3_write_dirent()\n");
@@ -255,6 +225,7 @@
 	vecs[0].iov_len = sizeof(*rd);
 	vecs[1].iov_base = (unsigned char *)name;
 	vecs[1].iov_len = namelen;
+	jffs2_dbg_prewrite_paranoia_check(c, flash_ofs, vecs[0].iov_len + vecs[1].iov_len);
 	
 	raw = jffs3_alloc_raw_node_ref();
 
@@ -305,8 +276,8 @@
 
 			D1(printk(KERN_DEBUG "Retrying failed write.\n"));
 
-			ACCT_SANITY_CHECK(c,jeb);
-			D1(ACCT_PARANOIA_CHECK(jeb));
+			jffs3_dbg_acct_sanity_check(c, jeb);
+			jffs3_dbg_acct_paranoia_check(c, jeb);
 
 			if (alloc_mode == ALLOC_GC) {
 				ret = jffs3_reserve_space_gc(c, sizeof(*rd) + namelen, &flash_ofs, &dummy);
@@ -321,8 +292,8 @@
 
 			if (!ret) {
 				D1(printk(KERN_DEBUG "Allocated space at 0x%08x to retry failed write.\n", flash_ofs));
-				ACCT_SANITY_CHECK(c,jeb);
-				D1(ACCT_PARANOIA_CHECK(jeb));
+				jffs3_dbg_acct_sanity_check(c, jeb);
+				jffs3_dbg_acct_paranoia_check(c, jeb);
 				goto retry;
 			}
 			D1(printk(KERN_DEBUG "Failed to allocate space to retry failed write: %d!\n", ret));
@@ -342,7 +313,7 @@
 	spin_unlock(&c->erase_completion_lock);
 
 	if (retried) {
-		ACCT_SANITY_CHECK(c,NULL);
+		jffs3_dbg_acct_sanity_check(c, NULL);
 	}
 
 	return fd;





More information about the linux-mtd-cvs mailing list