mtd/fs/jffs3 build.c, 3.5, 3.6 compr.c, 3.3, 3.4 compr_zlib.c, 3.2, 3.3 debug.c, 1.6, 1.7 debug.h, 1.17, 1.18 erase.c, 3.4, 3.5 fs.c, 3.5, 3.6 nodelist.c, 3.2, 3.3 nodelist.h, 3.6, 3.7 nodemgmt.c, 3.5, 3.6 read.c, 3.4, 3.5 readinode.c, 3.4, 3.5 super-v24.c, 3.2, 3.3 wbuf.c, 3.6, 3.7 write.c, 3.6, 3.7

Artem Bityuckiy dedekind at infradead.org
Thu Dec 23 13:53:41 EST 2004


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

Modified Files:
	build.c compr.c compr_zlib.c debug.c debug.h erase.c fs.c 
	nodelist.c nodelist.h nodemgmt.c read.c readinode.c 
	super-v24.c wbuf.c write.c 
Log Message:
Completely remove D1/D2. Use if (DEBUG1)/if (DEBUG2) instead.


Index: build.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs3/build.c,v
retrieving revision 3.5
retrieving revision 3.6
diff -u -r3.5 -r3.6
--- build.c	22 Dec 2004 18:33:48 -0000	3.5
+++ build.c	23 Dec 2004 18:53:36 -0000	3.6
@@ -105,15 +105,16 @@
 		goto exit;
 
 	DBG_BLD(1, "Scanned flash completely\n");
-	if (DEBUG2)
+	if (DEBUG2) {
+		DBG_BLD(2, "Blocks info:\n");
 		jffs3_dbg_dump_block_lists(c);
+	}
 
 	/* Now scan the directory tree, increasing nlink according to every dirent found. */
 	for_each_inode(i, c, ic) {
 		DBG_BLD(1, "Pass 1: ino #%u\n", ic->ino);
-
-		D1(BUG_ON(ic->ino > c->highest_ino));
-
+		if (SANITY)
+			BUG_ON(ic->ino > c->highest_ino);
 		if (ic->scan_dents) {
 			jffs3_build_inode_pass1(c, ic);
 			cond_resched();
@@ -169,8 +170,10 @@
 		cond_resched();
 	}
 	DBG_BLD(1, "Pass 3 complete\n");
-	if (DEBUG2)
+	if (DEBUG2) {
+		DBG_BLD(2, "Blocks info:\n");
 		jffs3_dbg_dump_block_lists(c);
+	}
 
 	/* Rotate the lists by some number to ensure wear levelling */
 	jffs3_rotate_lists(c);

Index: compr.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs3/compr.c,v
retrieving revision 3.3
retrieving revision 3.4
diff -u -r3.3 -r3.4
--- compr.c	21 Dec 2004 17:12:56 -0000	3.3
+++ compr.c	23 Dec 2004 18:53:36 -0000	3.4
@@ -249,9 +249,10 @@
         }
         list_add_tail(&comp->list, &jffs3_compressor_list);
 out:
-        D2(list_for_each_entry(this, &jffs3_compressor_list, list) {
-                DBG_COMPR(1, "Compressor \"%s\", prio %d\n", this->name, this->priority);
-        })
+        if (DEBUG2) {
+		list_for_each_entry(this, &jffs3_compressor_list, list)
+			DBG_COMPR(1, "Compressor \"%s\", prio %d\n", this->name, this->priority);
+	}
 
         spin_unlock(&jffs3_compressor_list_lock);
 
@@ -260,8 +261,6 @@
 
 int jffs3_unregister_compressor(struct jffs3_compressor *comp)
 {
-        D2(struct jffs3_compressor *this;)
-
         DBG_COMPR(1, "Unregistering JFFS3 compressor \"%s\"\n", comp->name);
 
         spin_lock(&jffs3_compressor_list_lock);
@@ -273,9 +272,11 @@
         }
         list_del(&comp->list);
 
-        D2(list_for_each_entry(this, &jffs3_compressor_list, list) {
-                DBG_COMPR(2, "Compressor \"%s\", prio %d\n", this->name, this->priority);
-        })
+        if (DEBUG2) {
+	        struct jffs3_compressor *this;
+		list_for_each_entry(this, &jffs3_compressor_list, list)
+			DBG_COMPR(2, "Compressor \"%s\", prio %d\n", this->name, this->priority);
+        }
         spin_unlock(&jffs3_compressor_list_lock);
         return 0;
 }

Index: compr_zlib.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs3/compr_zlib.c,v
retrieving revision 3.2
retrieving revision 3.3
diff -u -r3.2 -r3.3
--- compr_zlib.c	21 Dec 2004 14:47:57 -0000	3.2
+++ compr_zlib.c	23 Dec 2004 18:53:36 -0000	3.3
@@ -163,8 +163,9 @@
 		inf_strm.next_in += 2;
 		inf_strm.avail_in -= 2;
 	} else {
-		/* Let this remain D1 for now -- it should never happen */
-		DBG_COMPR(1, "inflate not skipping adler32\n");
+		/* This should never happen */
+		if (PARANOIA)
+			WARNING_MSG("inflate not skipping adler32\n");
 	}
 
 

Index: debug.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs3/debug.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- debug.c	23 Dec 2004 14:12:56 -0000	1.6
+++ debug.c	23 Dec 2004 18:53:36 -0000	1.7
@@ -195,35 +195,19 @@
 	if (bitched) {
 		struct jffs3_node_frag *thisfrag;
 
-		printk(KERN_ERR "Inode is #%u\n", f->inocache->ino);
-		thisfrag = frag_first(&f->fragtree);
-		while (thisfrag) {
-			if (!thisfrag->node) {
-				printk(KERN_ERR "Frag @0x%x-0x%x; node-less hole\n",
-				       thisfrag->ofs, thisfrag->size + thisfrag->ofs);
-			} else if (!thisfrag->node->raw) {
-				printk(KERN_ERR "Frag @0x%x-0x%x; raw-less hole\n",
-				       thisfrag->ofs, thisfrag->size + thisfrag->ofs);
-			} else {
-				printk(KERN_ERR "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);
-		}
+		ERROR_MSG("Fragtree is corrupted. Fragtree dump:\n");
+		jffs3_dbg_print_frag_list(f);
 		BUG();
 	}
 }
 
 #endif /* PARANOIA > 0 */
 
-#if DEBUG1 > 0
+#if DEBUG1 > 0 || PARANOIA > 0
 
 void
 jffs3_dbg_dump_block_lists(struct jffs3_sb_info *c)
 {
-	DBG(1, "\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);
@@ -431,7 +415,7 @@
 	uint32_t lastofs = 0;
 	int buggy = 0;
 
-	DBG(1, "\n");
+	printk(KERN_DEBUG "inode is ino #%u\n", f->inocache->ino);
 	while(this) {
 		if (this->node)
 			printk(KERN_DEBUG "frag %#04x-%#04x: %#08x(%d) on flash (*%p), left (%p), "
@@ -453,9 +437,20 @@
 		printk(KERN_DEBUG "metadata at 0x%08x\n", ref_offset(f->metadata->raw));
 
 	if (buggy) {
-		printk(KERN_ERR "Error! %s(): Frag tree got a hole in it\n", __FUNCTION__);
+		ERROR_MSG("Error! %s(): Frag tree got a hole in it\n", __FUNCTION__);
 		BUG();
 	}
 }
 
-#endif /* DEBUG1 > 0*/
+void
+jffs3_dbg_print_dirents_list(struct jffs3_full_dirent *list)
+{
+	int i = 0;
+	
+	while(*list) {
+		printk(KERN_DEBUG "%d. Dirent \"%s\" (hash 0x%08x, ino #%u)\n",
+				i++, list->name, list->nhash, list->ino);
+		list = list->next;
+	}
+}
+#endif /* DEBUG1 > 0 || PARANOIA > 0 */

Index: debug.h
===================================================================
RCS file: /home/cvs/mtd/fs/jffs3/debug.h,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- debug.h	23 Dec 2004 14:12:56 -0000	1.17
+++ debug.h	23 Dec 2004 18:53:36 -0000	1.18
@@ -16,6 +16,10 @@
 #include <linux/kernel.h>
 #include "jffs3.h"
 
+#ifndef CONFIG_JFFS3_FS_DEBUG
+#define CONFIG_JFFS3_FS_DEBUG 1
+#endif
+
 #if CONFIG_JFFS3_FS_DEBUG > 0
 #define DEBUG1		1
 #define PARANOIA	1
@@ -310,6 +314,9 @@
 jffs3_dbg_print_frag_list(struct jffs3_inode_info *f);
 
 void
+jffs3_dbg_print_dirents_list(struct jffs3_full_dirent *list);
+	
+void
 jffs3_dbg_dump_buffer(char *buf, int len, uint32_t offs);
 
 

Index: erase.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs3/erase.c,v
retrieving revision 3.4
retrieving revision 3.5
diff -u -r3.4 -r3.5
--- erase.c	22 Dec 2004 18:33:48 -0000	3.4
+++ erase.c	23 Dec 2004 18:53:36 -0000	3.5
@@ -263,24 +263,6 @@
 	DBG_NR(1, "Removed nodes in range %#08x-%#08x from ino #%u\n",
 		  jeb->offset, jeb->offset + c->sector_size, ic->ino);
 
-	D2({
-		int i=0;
-		struct jffs3_raw_node_ref *this;
-		DBG_NR(2, "After remove_node_refs_from_ino_list: \n" KERN_DEBUG);
-
-		this = ic->nodes;
-	   
-		while(this) {
-			printk("%#08x(%d)->", ref_offset(this), ref_flags(this));
-			if (++i == 5) {
-				printk("\n" KERN_DEBUG);
-				i=0;
-			}
-			this = this->next_in_ino;
-		}
-		printk("\n");
-	});
-
 	if (ic->nodes == (void *)ic) {
 		DBG_NR(1, "inocache for ino #%u is all gone now. Freeing\n", ic->ino);
 		jffs3_del_ino_cache(c, ic);

Index: fs.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs3/fs.c,v
retrieving revision 3.5
retrieving revision 3.6
diff -u -r3.5 -r3.6
--- fs.c	22 Dec 2004 18:35:51 -0000	3.5
+++ fs.c	23 Dec 2004 18:53:36 -0000	3.6
@@ -206,8 +206,10 @@
 
 	buf->f_bavail = buf->f_bfree = avail >> PAGE_SHIFT;
 
-	if (DEBUG2)
+	if (DEBUG2) {
+		DBG_VFS(2, "Blocks info:\n");
 		jffs3_dbg_dump_block_lists(c);
+	}
 
 	spin_unlock(&c->erase_completion_lock);
 

Index: nodelist.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs3/nodelist.c,v
retrieving revision 3.2
retrieving revision 3.3
diff -u -r3.2 -r3.3
--- nodelist.c	21 Dec 2004 17:12:56 -0000	3.2
+++ nodelist.c	23 Dec 2004 18:53:36 -0000	3.3
@@ -51,10 +51,10 @@
 	*prev = new;
 
  out:
-	D2(while(*list) {
-		DBG_BI(2, "Dirent \"%s\" (hash 0x%08x, ino #%u\n", (*list)->name, (*list)->nhash, (*list)->ino);
-		list = &(*list)->next;
-	});
+	if (DEBUG2) {
+		DBG_BI(2, "Direntries list:\n");
+		jffs3_dbg_print_dirents_list(*list);
+	}
 }
 
 /* Put a new tmp_dnode_info into the list, keeping the list in 

Index: nodelist.h
===================================================================
RCS file: /home/cvs/mtd/fs/jffs3/nodelist.h,v
retrieving revision 3.6
retrieving revision 3.7
diff -u -r3.6 -r3.7
--- nodelist.h	23 Dec 2004 14:12:56 -0000	3.6
+++ nodelist.h	23 Dec 2004 18:53:37 -0000	3.7
@@ -28,22 +28,6 @@
 #include "os-linux.h"
 #endif
 
-#ifndef CONFIG_JFFS3_FS_DEBUG
-#define CONFIG_JFFS3_FS_DEBUG 1
-#endif
-
-#if CONFIG_JFFS3_FS_DEBUG > 0
-#define D1(x) x
-#else
-#define D1(x)
-#endif
-
-#if CONFIG_JFFS3_FS_DEBUG > 1
-#define D2(x) x
-#else
-#define D2(x)
-#endif
-
 #define JFFS3_NATIVE_ENDIAN
 
 /* Note we handle mode bits conversion from JFFS3 (i.e. Linux) to/from
@@ -238,11 +222,11 @@
 {
 	uint32_t ret;
 
-	D1(if (jeb && jeb != &c->blocks[ref->flash_offset / c->sector_size]) {
-		printk(KERN_CRIT "ref_totlen called with wrong block -- at 0x%08x instead of 0x%08x; ref 0x%08x\n",
+	if (PARANOIA && jeb && jeb != &c->blocks[ref->flash_offset / c->sector_size]) {
+		ERROR_MSG("ref_totlen called with wrong block -- at 0x%08x instead of 0x%08x; ref 0x%08x\n",
 		       jeb->offset, c->blocks[ref->flash_offset / c->sector_size].offset, ref_offset(ref));
 		BUG();
-	})
+	}
 
 #if 1
 	ret = ref->__totlen;
@@ -250,7 +234,7 @@
 	/* This doesn't actually work yet */
 	ret = __ref_totlen(c, jeb, ref);
 	if (ret != ref->__totlen) {
-		printk(KERN_CRIT "Totlen for ref at %p (0x%08x-0x%08x) miscalculated as 0x%x instead of %x\n",
+		ERROR_MSG("Totlen for ref at %p (0x%08x-0x%08x) miscalculated as 0x%x instead of %x\n",
 		       ref, ref_offset(ref), ref_offset(ref)+ref->__totlen,
 		       ret, ref->__totlen);
 		if (!jeb)

Index: nodemgmt.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs3/nodemgmt.c,v
retrieving revision 3.5
retrieving revision 3.6
diff -u -r3.5 -r3.6
--- nodemgmt.c	22 Dec 2004 18:35:51 -0000	3.5
+++ nodemgmt.c	23 Dec 2004 18:53:37 -0000	3.6
@@ -498,23 +498,23 @@
 	spin_lock(&c->erase_completion_lock);
 
 	if (ref_flags(ref) == REF_UNCHECKED) {
-		D1(if (unlikely(jeb->unchecked_size < ref_totlen(c, jeb, ref))) {
+		if (PARANOIA && jeb->unchecked_size < ref_totlen(c, jeb, ref)) {
 			ERROR_MSG("raw unchecked node of size 0x%08x freed from erase block"
 				"%d at 0x%08x, but unchecked_size was already 0x%08x\n",
 				ref_totlen(c, jeb, ref), blocknr, ref->flash_offset, jeb->used_size);
 			BUG();
-		})
+		}
 		DBG_NR(1, "Obsoleting previously unchecked node at 0x%08x of len %x: ",
 			ref_offset(ref), ref_totlen(c, jeb, ref));
 		jeb->unchecked_size -= ref_totlen(c, jeb, ref);
 		c->unchecked_size -= ref_totlen(c, jeb, ref);
 	} else {
-		D1(if (unlikely(jeb->used_size < ref_totlen(c, jeb, ref))) {
+		if (PARANOIA && jeb->used_size < ref_totlen(c, jeb, ref)) {
 			ERROR_MSG("raw node of size 0x%08x freed from erase block %d at 0x%08x, "
 				"but used_size was already 0x%08x\n",
 				ref_totlen(c, jeb, ref), blocknr, ref->flash_offset, jeb->used_size);
 			BUG();
-		})
+		}
 		DBG_NR(1, "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);

Index: read.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs3/read.c,v
retrieving revision 3.4
retrieving revision 3.5
diff -u -r3.4 -r3.5
--- read.c	22 Dec 2004 18:35:51 -0000	3.4
+++ read.c	23 Dec 2004 18:53:37 -0000	3.5
@@ -68,12 +68,12 @@
 		ri->csize = cpu_to_je32(0);
 	}
 
-	D1(if(ofs + len > je32_to_cpu(ri->dsize)) {
+	if(PARANOIA && ofs + len > je32_to_cpu(ri->dsize)) {
 		WARNING_MSG("asked for %d bytes at %d from %d-byte node\n",
 			len, ofs, je32_to_cpu(ri->dsize));
 		ret = -EINVAL;
 		goto out_ri;
-	});
+	};
 
 	
 	if (ri->compr == JFFS3_COMPR_ZERO) {
@@ -174,8 +174,10 @@
 				WARNING_MSG("Eep. Hole in ino #%u fraglist. frag->ofs = 0x%08x, offset = 0x%08x\n",
 						f->inocache->ino, frag->ofs, offset);
 				holesize = min(holesize, frag->ofs - offset);
-				if (DEBUG2)
+				if (DEBUG2) {
+					DBG_READ(2, "The fragment tree dump:\n");
 					jffs3_dbg_print_frag_list(f);
+				}
 			}
 			DBG_READ(1, "Filling non-frag hole from %d-%d\n", offset, offset+holesize);
 			memset(buf, 0, holesize);

Index: readinode.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs3/readinode.c,v
retrieving revision 3.4
retrieving revision 3.5
diff -u -r3.4 -r3.5
--- readinode.c	22 Dec 2004 18:35:51 -0000	3.4
+++ readinode.c	23 Dec 2004 18:53:37 -0000	3.5
@@ -96,8 +96,11 @@
 		}
 	}
 
-	if (DEBUG2)
+	if (DEBUG2) {
+		DBG_BI(2, "The fragment tree dump:\n");
 		jffs3_dbg_print_frag_list(f);
+	}
+	
 	return 0;
 }
 
@@ -195,13 +198,13 @@
 				return -ENOMEM;
 			}
 			
-			D2(
-			DBG_BI(2, "split old frag 0x%04x-0x%04x -->", this->ofs, this->ofs+this->size);
-			if (this->node)
-				DBG_BI(2, "phys 0x%08x\n", ref_offset(this->node->raw));
-			else 
-				DBG_BI(2, "hole\n");
-			   )
+			if (DEBUG2) {
+				DBG_BI(2, "split old frag 0x%04x-0x%04x -->", this->ofs, this->ofs+this->size);
+				if (this->node)
+					DBG_BI(2, "phys 0x%08x\n", ref_offset(this->node->raw));
+				else 
+					DBG_BI(2, "hole\n");
+			}
 			
 			/* New second frag pointing to this's node */
 			newfrag2->ofs = newfrag->ofs + newfrag->size;

Index: super-v24.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs3/super-v24.c,v
retrieving revision 3.2
retrieving revision 3.3
diff -u -r3.2 -r3.3
--- super-v24.c	21 Dec 2004 15:18:51 -0000	3.2
+++ super-v24.c	23 Dec 2004 18:53:37 -0000	3.3
@@ -31,6 +31,18 @@
 #define MTD_BLOCK_MAJOR 31
 #endif
 
+/* Old style. Now only in 2.4 stuff. Will go */
+#if DEBUG1 > 0
+#define D1(x) x
+#else
+#define D1(x)
+#endif
+#if DEBUG2 > 1
+#define D2(x) x
+#else
+#define D2(x)
+#endif
+
 static void jffs3_put_super (struct super_block *);
 
 static struct super_operations jffs3_super_operations =

Index: wbuf.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs3/wbuf.c,v
retrieving revision 3.6
retrieving revision 3.7
diff -u -r3.6 -r3.7
--- wbuf.c	22 Dec 2004 18:35:51 -0000	3.6
+++ wbuf.c	23 Dec 2004 18:53:37 -0000	3.7
@@ -135,8 +135,10 @@
 {
 	DBG_WBUF(1, "About to refile bad block at %08x\n", jeb->offset);
 
-	if (DEBUG2)
+	if (DEBUG2) {
+		DBG_WBUF(2, "Blocks info:\n");
 		jffs3_dbg_dump_block_lists(c);
+	}
 	/* File the existing block on the bad_used_list.... */
 	if (c->nextblock == jeb)
 		c->nextblock = NULL;
@@ -153,8 +155,10 @@
 		c->nr_erasing_blocks++;
 		jffs3_erase_pending_trigger(c);
 	}
-	if (DEBUG2)
+	if (DEBUG2) {
+		DBG_WBUF(2, "Blocks info:\n");
 		jffs3_dbg_dump_block_lists(c);
+	}
 
 	/* Adjust its size counts accordingly */
 	c->wasted_size += jeb->free_size;

Index: write.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs3/write.c,v
retrieving revision 3.6
retrieving revision 3.7
diff -u -r3.6 -r3.7
--- write.c	22 Dec 2004 18:35:52 -0000	3.6
+++ write.c	23 Dec 2004 18:53:37 -0000	3.7
@@ -69,10 +69,10 @@
 	int retried = 0;
 	unsigned long cnt = 2;
 
-	D1(if(je32_to_cpu(ri->hdr_crc) != crc32(0, ri, sizeof(struct jffs3_unknown_node)-4)) {
+	if(PARANOIA && je32_to_cpu(ri->hdr_crc) != crc32(0, ri, sizeof(struct jffs3_unknown_node)-4)) {
 		ERROR_MSG("Eep. CRC not correct\n");
 		BUG();
-	});
+	};
 	vecs[0].iov_base = ri;
 	vecs[0].iov_len = sizeof(*ri);
 	vecs[1].iov_base = (unsigned char *)data;
@@ -221,10 +221,10 @@
 		  je32_to_cpu(rd->pino), name, name, je32_to_cpu(rd->ino),
 		  je32_to_cpu(rd->name_crc));
 
-	D1(if(je32_to_cpu(rd->hdr_crc) != crc32(0, rd, sizeof(struct jffs3_unknown_node)-4)) {
+	if (PARANOIA && je32_to_cpu(rd->hdr_crc) != crc32(0, rd, sizeof(struct jffs3_unknown_node)-4)) {
 		ERROR_MSG("Eep. CRC not correct\n");
 		BUG();
-	});
+	};
 
 	vecs[0].iov_base = rd;
 	vecs[0].iov_len = sizeof(*rd);





More information about the linux-mtd-cvs mailing list