mtd/fs/jffs3 compr.c, 3.2, 3.3 debug.c, 1.3, 1.4 debug.h, 1.13, 1.14 nodelist.c, 3.1, 3.2 nodemgmt.c, 3.3, 3.4

Artem Bityuckiy dedekind at infradead.org
Tue Dec 21 12:12:59 EST 2004


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

Modified Files:
	compr.c debug.c debug.h nodelist.c nodemgmt.c 
Log Message:
More printk changes


Index: compr.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs3/compr.c,v
retrieving revision 3.2
retrieving revision 3.3
diff -u -r3.2 -r3.3
--- compr.c	21 Dec 2004 14:47:57 -0000	3.2
+++ compr.c	21 Dec 2004 17:12:56 -0000	3.3
@@ -274,7 +274,7 @@
         list_del(&comp->list);
 
         D2(list_for_each_entry(this, &jffs3_compressor_list, list) {
-                DBG_COMPR("Compressor \"%s\", prio %d\n", this->name, this->priority);
+                DBG_COMPR(2, "Compressor \"%s\", prio %d\n", this->name, this->priority);
         })
         spin_unlock(&jffs3_compressor_list_lock);
         return 0;

Index: debug.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs3/debug.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- debug.c	17 Dec 2004 14:46:21 -0000	1.3
+++ debug.c	21 Dec 2004 17:12:56 -0000	1.4
@@ -233,11 +233,11 @@
 #endif /* JFFS3_DBG_PARANOIA_CHECKS */
 
 
-#if CONFIG_JFFS3_FS_DEBUG > 1
+#if CONFIG_JFFS3_FS_DEBUG > 0
 void
 jffs3_dbg_dump_block_lists(struct jffs3_sb_info *c)
 {
-	DBG("%s:\n", __FUNCTION__);
+	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);
@@ -445,7 +445,7 @@
 	uint32_t lastofs = 0;
 	int buggy = 0;
 
-	DBG("%s:\n", __FUNCTION__);
+	DBG(1, "\n");
 	while(this) {
 		if (this->node)
 			printk(KERN_DEBUG "frag %#04x-%#04x: %#08x(%d) on flash (*%p), left (%p), "

Index: debug.h
===================================================================
RCS file: /home/cvs/mtd/fs/jffs3/debug.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- debug.h	21 Dec 2004 16:25:46 -0000	1.13
+++ debug.h	21 Dec 2004 17:12:56 -0000	1.14
@@ -47,9 +47,12 @@
 #define JFFS3_DBG_VFS		9	/* VFS callback handlers */
 #define JFFS3_DBG_BLD		10	/* File system build (on mount) */
 #define JFFS3_DBG_COMPR		11	/* Compression */
-#define JFFS3_DBG_SUMMARY	12	/* Summary info */
+#define JFFS3_DBG_SUMMARY	12	/* Summaries processing */
 #define JFFS3_DBG_RI		13	/* Read inode */
 #define JFFS3_DBG_BI		14	/* Build inode (after reading) */
+#define JFFS3_DBG_RSV		15	/* Flash space reservation */
+#define JFFS3_DBG_NR		16	/* Manipulating raw_node_ref objects */
+#define JFFS3_DBG_BL		17	/* Manipulating block lists */
 
 #if CONFIG_JFFS3_FS_DEBUG > 0
 #define JFFS3_DBG_PARANOIA_CHECKS	1
@@ -68,6 +71,9 @@
 #define JFFS3_DBG_SUBSYS_SUMMARY_PRINT  1
 #define JFFS3_DBG_SUBSYS_RI_PRINT	1
 #define JFFS3_DBG_SUBSYS_BI_PRINT	1
+#define JFFS3_DBG_SUBSYS_RSV_PRINT	1
+#define JFFS3_DBG_SUBSYS_NR_PRINT	1
+#define JFFS3_DBG_SUBSYS_BL_PRINT	1
 #else
 #define JFFS3_DBG_SUBSYS_OTHER_PRINT	0
 #define JFFS3_DBG_SUBSYS_SCAN_PRINT	0
@@ -83,6 +89,9 @@
 #define JFFS3_DBG_SUBSYS_SUMMARY_PRINT  0
 #define JFFS3_DBG_SUBSYS_RI_PRINT	0
 #define JFFS3_DBG_SUBSYS_BI_PRINT	0
+#define JFFS3_DBG_SUBSYS_RSV_PRINT	0
+#define JFFS3_DBG_SUBSYS_NR_PRINT	0
+#define JFFS3_DBG_SUBSYS_BL_PRINT	0
 #endif
 
 /*
@@ -95,6 +104,18 @@
 	char *subsysname = NULL;						\
 	if ((debug_level) >= CONFIG_JFFS3_FS_DEBUG) {				\
 		switch (subsystem) {						\
+			case JFFS3_DBG_NR:					\
+				if (JFFS3_DBG_SUBSYS_NR_PRINT)			\
+					subsysname = "nr";			\
+				break;						\
+			case JFFS3_DBG_BL:					\
+				if (JFFS3_DBG_SUBSYS_BL_PRINT)			\
+					subsysname = "bl";			\
+				break;						\
+			case JFFS3_DBG_RSV:					\
+				if (JFFS3_DBG_SUBSYS_RSV_PRINT)			\
+					subsysname = "rsv";			\
+				break;						\
 			case JFFS3_DBG_BI:					\
 				if (JFFS3_DBG_SUBSYS_BI_PRINT)			\
 					subsysname = "bi";			\
@@ -108,7 +129,7 @@
 					subsysname = "summary";			\
 				break;						\
 			case JFFS3_DBG_COMPR:					\
-				if (JFFS3_DBG_SUBSYS_BLD_PRINT)			\
+				if (JFFS3_DBG_SUBSYS_COMPR_PRINT)		\
 					subsysname = "compr";			\
 				break;						\
 			case JFFS3_DBG_BLD:					\
@@ -208,6 +229,15 @@
 #define DBG_BI(debug_level, args...)						\
 	JFFS3DBG_SUBSYSTEM(JFFS3_DBG_BI, debug_level, args)
 
+#define DBG_RSV(debug_level, args...)						\
+	JFFS3DBG_SUBSYSTEM(JFFS3_DBG_RSV, debug_level, args)
+
+#define DBG_NR(debug_level, args...)						\
+	JFFS3DBG_SUBSYSTEM(JFFS3_DBG_NR, debug_level, args)
+
+#define DBG_BL(debug_level, args...)						\
+	JFFS3DBG_SUBSYSTEM(JFFS3_DBG_BL, debug_level, args)
+
 /* 
  * Please, use this macro in case of critical error which makes JFFS3
  * futher unworkable or when you use BUG().
@@ -230,7 +260,7 @@
 
 /*
  * Use this macro when you want to note something. Do not use too often
- * in order not to put unneded garbage to the system log
+ * in order not to put unneded garbage to the system log.
  */
 #define NOTICE_MSG(args...)							\
 	do {									\

Index: nodelist.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs3/nodelist.c,v
retrieving revision 3.1
retrieving revision 3.2
diff -u -r3.1 -r3.2
--- nodelist.c	9 Dec 2004 16:05:06 -0000	3.1
+++ nodelist.c	21 Dec 2004 17:12:56 -0000	3.2
@@ -25,18 +25,19 @@
 void jffs3_add_fd_to_list(struct jffs3_sb_info *c, struct jffs3_full_dirent *new, struct jffs3_full_dirent **list)
 {
 	struct jffs3_full_dirent **prev = list;
-	D1(printk(KERN_DEBUG "jffs3_add_fd_to_list( %p, %p (->%p))\n", new, list, *list));
+	DBG_BI(1, "c %p, new %p list %p, *list %p\n", new, new, list, *list);
 
 	while ((*prev) && (*prev)->nhash <= new->nhash) {
 		if ((*prev)->nhash == new->nhash && !strcmp((*prev)->name, new->name)) {
 			/* Duplicate. Free one */
 			if (new->version < (*prev)->version) {
-				D1(printk(KERN_DEBUG "Eep! Marking new dirent node obsolete\n"));
-				D1(printk(KERN_DEBUG "New dirent is \"%s\"->ino #%u. Old is \"%s\"->ino #%u\n", new->name, new->ino, (*prev)->name, (*prev)->ino));
+				DBG_BI(1, "Eep! Marking new dirent node obsolete\n");
+				DBG_BI(1, "New dirent is \"%s\"->ino #%u. Old is \"%s\"->ino #%u\n",
+						new->name, new->ino, (*prev)->name, (*prev)->ino);
 				jffs3_mark_node_obsolete(c, new->raw);
 				jffs3_free_full_dirent(new);
 			} else {
-				D1(printk(KERN_DEBUG "Marking old dirent node (ino #%u) obsolete\n", (*prev)->ino));
+				DBG_BI(1, "Marking old dirent node (ino #%u) obsolete\n", (*prev)->ino);
 				new->next = (*prev)->next;
 				jffs3_mark_node_obsolete(c, ((*prev)->raw));
 				jffs3_free_full_dirent(*prev);
@@ -51,7 +52,7 @@
 
  out:
 	D2(while(*list) {
-		printk(KERN_DEBUG "Dirent \"%s\" (hash 0x%08x, ino #%u\n", (*list)->name, (*list)->nhash, (*list)->ino);
+		DBG_BI(2, "Dirent \"%s\" (hash 0x%08x, ino #%u\n", (*list)->name, (*list)->nhash, (*list)->ino);
 		list = &(*list)->next;
 	});
 }
@@ -99,7 +100,7 @@
 	while (ref && ref->next_in_ino) {
 		if (!ref_obsolete(ref))
 			return ref;
-		D1(printk(KERN_DEBUG "node at 0x%08x is obsoleted. Ignoring.\n", ref_offset(ref)));
+		DBG_RI(1, "Node at 0x%08x is obsoleted. Ignoring.\n", ref_offset(ref));
 		ref = ref->next_in_ino;
 	}
 	return NULL;
@@ -122,14 +123,14 @@
 
 	*mctime_ver = 0;
 	
-	D1(printk(KERN_DEBUG "jffs3_get_inode_nodes(): ino #%u\n", f->inocache->ino));
+	DBG_RI(1, "ino #%u\n", f->inocache->ino);
 
 	spin_lock(&c->erase_completion_lock);
 
 	valid_ref = jffs3_first_valid_node(f->inocache->nodes);
 
-	if (!valid_ref)
-		printk(KERN_WARNING "Eep. No valid nodes for ino #%u\n", f->inocache->ino);
+	if (!valid_ref && f->inocache->ino != 0)
+		WARNING_MSG("Eep. No valid nodes for ino #%u\n", f->inocache->ino);
 
 	while (valid_ref) {
 		/* We can hold a pointer to a non-obsolete node without the spinlock,
@@ -149,34 +150,35 @@
 				       min_t(uint32_t, ref_totlen(c, NULL, ref), sizeof(node)),
 				       &retlen, (void *)&node);
 		if (err) {
-			printk(KERN_WARNING "error %d reading node at 0x%08x in get_inode_nodes()\n", err, ref_offset(ref));
+			WARNING_MSG("error %d reading node at 0x%08x in get_inode_nodes()\n",
+						err, ref_offset(ref));
 			goto free_out;
 		}
 			
 
 			/* Check we've managed to read at least the common node header */
 		if (retlen < min_t(uint32_t, ref_totlen(c, NULL, ref), sizeof(node.u))) {
-			printk(KERN_WARNING "short read in get_inode_nodes()\n");
+			WARNING_MSG("short read in get_inode_nodes()\n");
 			err = -EIO;
 			goto free_out;
 		}
 			
 		switch (je16_to_cpu(node.u.nodetype)) {
 		case JFFS3_NODETYPE_DIRENT:
-			D1(printk(KERN_DEBUG "Node at %08x (%d) is a dirent node\n", ref_offset(ref), ref_flags(ref)));
+			DBG_RI(1, "Node at %08x (%d) is a dirent node\n", ref_offset(ref), ref_flags(ref));
 			if (ref_flags(ref) == REF_UNCHECKED) {
-				printk(KERN_WARNING "BUG: Dirent node at 0x%08x never got checked? How?\n", ref_offset(ref));
+				ERROR_MSG("Dirent node at 0x%08x never got checked? How?\n", ref_offset(ref));
 				BUG();
 			}
 			if (retlen < sizeof(node.d)) {
-				printk(KERN_WARNING "short read in get_inode_nodes()\n");
+				WARNING_MSG("short read in get_inode_nodes()\n");
 				err = -EIO;
 				goto free_out;
 			}
 			/* sanity check */
 			if (PAD((node.d.nsize + sizeof (node.d))) != PAD(je32_to_cpu (node.d.totlen))) {
-				printk(KERN_NOTICE "jffs3_get_inode_nodes(): Illegal nsize in node at 0x%08x: nsize 0x%02x, totlen %04x\n",
-				       ref_offset(ref), node.d.nsize, je32_to_cpu(node.d.totlen));
+				WARNING_MSG("Illegal nsize in node at 0x%08x: nsize 0x%02x, totlen %04x\n",
+						ref_offset(ref), node.d.nsize, je32_to_cpu(node.d.totlen));
 				jffs3_mark_node_obsolete(c, ref);
 				spin_lock(&c->erase_completion_lock);
 				continue;
@@ -185,7 +187,7 @@
 				*highest_version = je32_to_cpu(node.d.version);
 			if (ref_obsolete(ref)) {
 				/* Obsoleted. This cannot happen, surely? dwmw2 20020308 */
-				printk(KERN_ERR "Dirent node at 0x%08x became obsolete while we weren't looking\n",
+				ERROR_MSG("Dirent node at 0x%08x became obsolete while we weren't looking\n",
 				       ref_offset(ref));
 				BUG();
 			}
@@ -225,7 +227,7 @@
 					err = -EIO;
 					
 				if (err) {
-					printk(KERN_WARNING "Read remainder of name in jffs3_get_inode_nodes(): error %d\n", err);
+					WARNING_MSG("Read remainder of name in jffs3_get_inode_nodes(): error %d\n", err);
 					jffs3_free_full_dirent(fd);
 					goto free_out;
 				}
@@ -236,24 +238,25 @@
 				/* Wheee. We now have a complete jffs3_full_dirent structure, with
 				   the name in it and everything. Link it into the list 
 				*/
-			D1(printk(KERN_DEBUG "Adding fd \"%s\", ino #%u\n", fd->name, fd->ino));
+			DBG_RI(1, "Adding fd \"%s\", ino #%u\n", fd->name, fd->ino);
 			jffs3_add_fd_to_list(c, fd, &ret_fd);
 			break;
 
 		case JFFS3_NODETYPE_INODE:
-			D1(printk(KERN_DEBUG "Node at %08x (%d) is a data node\n", ref_offset(ref), ref_flags(ref)));
+			DBG_RI(1, "Node at %08x (%d) is a data node\n", ref_offset(ref), ref_flags(ref));
 			if (retlen < sizeof(node.i)) {
-				printk(KERN_WARNING "read too short for dnode\n");
+				WARNING_MSG("read too short for dnode\n");
 				err = -EIO;
 				goto free_out;
 			}
 			if (je32_to_cpu(node.i.version) > *highest_version)
 				*highest_version = je32_to_cpu(node.i.version);
-			D1(printk(KERN_DEBUG "version %d, highest_version now %d\n", je32_to_cpu(node.i.version), *highest_version));
+			DBG_RI(1, "version %d, highest_version now %d\n",
+					je32_to_cpu(node.i.version), *highest_version);
 
 			if (ref_obsolete(ref)) {
 				/* Obsoleted. This cannot happen, surely? dwmw2 20020308 */
-				printk(KERN_ERR "Inode node at 0x%08x became obsolete while we weren't looking\n",
+				ERROR_MSG("Inode node at 0x%08x became obsolete while we weren't looking\n",
 				       ref_offset(ref));
 				BUG();
 			}
@@ -265,7 +268,7 @@
 
 				crc = crc32(0, &node, sizeof(node.i)-8);
 				if (crc != je32_to_cpu(node.i.node_crc)) {
-					printk(KERN_NOTICE "jffs3_get_inode_nodes(): CRC failed on node at 0x%08x: Read 0x%08x, calculated 0x%08x\n",
+					WARNING_MSG("CRC failed on node at 0x%08x: Read 0x%08x, calculated 0x%08x\n",
 					       ref_offset(ref), je32_to_cpu(node.i.node_crc), crc);
 					jffs3_mark_node_obsolete(c, ref);
 					spin_lock(&c->erase_completion_lock);
@@ -274,8 +277,10 @@
 				
 				/* sanity checks */
 				if ( je32_to_cpu(node.i.offset) > je32_to_cpu(node.i.isize) ||
-				     PAD(je32_to_cpu(node.i.csize) + sizeof (node.i)) != PAD(je32_to_cpu(node.i.totlen))) {
-					printk(KERN_NOTICE "jffs3_get_inode_nodes(): Inode corrupted at 0x%08x, totlen %d, #ino  %d, version %d, isize %d, csize %d, dsize %d \n",
+					PAD(je32_to_cpu(node.i.csize) + sizeof (node.i))
+								!= PAD(je32_to_cpu(node.i.totlen))) {
+					WARNING_MSG("Inode corrupted at 0x%08x, totlen %d, #ino  %d, "
+						"version %d, isize %d, csize %d, dsize %d \n",
 						ref_offset(ref),  je32_to_cpu(node.i.totlen),  je32_to_cpu(node.i.ino),
 						je32_to_cpu(node.i.version),  je32_to_cpu(node.i.isize), 
 						je32_to_cpu(node.i.csize), je32_to_cpu(node.i.dsize));
@@ -292,10 +297,10 @@
 						err = c->mtd->point (c->mtd, ref_offset(ref) + sizeof(node.i), je32_to_cpu(node.i.csize),
 								     &retlen, &buf);
 						if (!err && retlen < je32_to_cpu(node.i.csize)) {
-							D1(printk(KERN_DEBUG "MTD point returned len too short: 0x%zx\n", retlen));
+							DBG_RI(1, "MTD point returned len too short: 0x%zx\n", retlen);
 							c->mtd->unpoint(c->mtd, buf, ref_offset(ref) + sizeof(node.i), je32_to_cpu(node.i.csize));
 						} else if (err){
-							D1(printk(KERN_DEBUG "MTD point failed %d\n", err));
+							DBG_RI(1, "MTD point failed %d\n", err);
 						} else
 							pointed = 1; /* succefully pointed to device */
 					}
@@ -323,8 +328,9 @@
 #endif
 
 					if (crc != je32_to_cpu(node.i.data_crc)) {
-						printk(KERN_NOTICE "jffs3_get_inode_nodes(): Data CRC failed on node at 0x%08x: Read 0x%08x, calculated 0x%08x\n",
-						       ref_offset(ref), je32_to_cpu(node.i.data_crc), crc);
+						WARNING_MSG("Data CRC failed on node at 0x%08x: "
+							"Read 0x%08x, calculated 0x%08x\n",
+							ref_offset(ref), je32_to_cpu(node.i.data_crc), crc);
 						jffs3_mark_node_obsolete(c, ref);
 						spin_lock(&c->erase_completion_lock);
 						continue;
@@ -352,10 +358,10 @@
 				if ((je32_to_cpu(node.i.dsize) >= PAGE_CACHE_SIZE) ||
 				    ( ((je32_to_cpu(node.i.offset)&(PAGE_CACHE_SIZE-1))==0) &&
 				      (je32_to_cpu(node.i.dsize)+je32_to_cpu(node.i.offset) ==  je32_to_cpu(node.i.isize)))) {
-					D1(printk(KERN_DEBUG "Marking node at 0x%08x REF_PRISTINE\n", ref_offset(ref)));
+					DBG_RI(1, "Marking node at 0x%08x REF_PRISTINE\n", ref_offset(ref));
 					ref->flash_offset = ref_offset(ref) | REF_PRISTINE;
 				} else {
-					D1(printk(KERN_DEBUG "Marking node at 0x%08x REF_NORMAL\n", ref_offset(ref)));
+					DBG_RI(1, "Marking node at 0x%08x REF_NORMAL\n", ref_offset(ref));
 					ref->flash_offset = ref_offset(ref) | REF_NORMAL;
 				}
 				spin_unlock(&c->erase_completion_lock);
@@ -363,14 +369,14 @@
 
 			tn = jffs3_alloc_tmp_dnode_info();
 			if (!tn) {
-				D1(printk(KERN_DEBUG "alloc tn failed\n"));
+				DBG_RI(1, "alloc tn failed\n");
 				err = -ENOMEM;
 				goto free_out;
 			}
 
 			tn->fn = jffs3_alloc_full_dnode();
 			if (!tn->fn) {
-				D1(printk(KERN_DEBUG "alloc fn failed\n"));
+				DBG_RI(1, "alloc fn failed\n");
 				err = -ENOMEM;
 				jffs3_free_tmp_dnode_info(tn);
 				goto free_out;
@@ -384,9 +390,9 @@
 			else // normal case...
 				tn->fn->size = je32_to_cpu(node.i.dsize);
 			tn->fn->raw = ref;
-			D1(printk(KERN_DEBUG "dnode @%08x: ver %u, offset %04x, dsize %04x\n",
+			DBG_RI(1, "dnode @%08x: ver %u, offset %04x, dsize %04x\n",
 				  ref_offset(ref), je32_to_cpu(node.i.version),
-				  je32_to_cpu(node.i.offset), je32_to_cpu(node.i.dsize)));
+				  je32_to_cpu(node.i.offset), je32_to_cpu(node.i.dsize));
 			jffs3_add_tn_to_list(tn, &ret_tn);
 			break;
 
@@ -395,7 +401,7 @@
 				struct jffs3_eraseblock *jeb;
 				uint32_t len;
 
-				printk(KERN_ERR "Eep. Unknown node type %04x at %08x was marked REF_UNCHECKED\n",
+				WARNING_MSG("Eep. Unknown node type %04x at %08x was marked REF_UNCHECKED\n",
 				       je16_to_cpu(node.u.nodetype), ref_offset(ref));
 
 				/* Mark the node as having been checked and fix the accounting accordingly */
@@ -414,28 +420,32 @@
 			node.u.nodetype = cpu_to_je16(JFFS3_NODE_ACCURATE | je16_to_cpu(node.u.nodetype));
 			if (crc32(0, &node, sizeof(struct jffs3_unknown_node)-4) != je32_to_cpu(node.u.hdr_crc)) {
 				/* Hmmm. This should have been caught at scan time. */
-				printk(KERN_ERR "Node header CRC failed at %08x. But it must have been OK earlier.\n",
+				WARNING_MSG("Node header CRC failed at %08x. But it must have been OK earlier.\n",
 				       ref_offset(ref));
-				printk(KERN_ERR "Node was: { %04x, %04x, %08x, %08x }\n", 
+				WARNING_MSG("Node was: { %04x, %04x, %08x, %08x }\n", 
 				       je16_to_cpu(node.u.magic), je16_to_cpu(node.u.nodetype), je32_to_cpu(node.u.totlen),
 				       je32_to_cpu(node.u.hdr_crc));
 				jffs3_mark_node_obsolete(c, ref);
 			} else switch(je16_to_cpu(node.u.nodetype) & JFFS3_COMPAT_MASK) {
 			case JFFS3_FEATURE_INCOMPAT:
-				printk(KERN_NOTICE "Unknown INCOMPAT nodetype %04X at %08x\n", je16_to_cpu(node.u.nodetype), ref_offset(ref));
+				ERROR_MSG("Unknown INCOMPAT nodetype %04X at %08x\n",
+					je16_to_cpu(node.u.nodetype), ref_offset(ref));
 				/* EEP */
 				BUG();
 				break;
 			case JFFS3_FEATURE_ROCOMPAT:
-				printk(KERN_NOTICE "Unknown ROCOMPAT nodetype %04X at %08x\n", je16_to_cpu(node.u.nodetype), ref_offset(ref));
+				ERROR_MSG("Unknown ROCOMPAT nodetype %04X at %08x\n",
+					je16_to_cpu(node.u.nodetype), ref_offset(ref));
 				if (!(c->flags & JFFS3_SB_FLAG_RO))
 					BUG();
 				break;
-			case JFFS3_FEATURE_RWCOMPAT_COPY:
-				printk(KERN_NOTICE "Unknown RWCOMPAT_COPY nodetype %04X at %08x\n", je16_to_cpu(node.u.nodetype), ref_offset(ref));
+			case JFFS3_FEATURE_RWCOMPAT_COPY:				
+				DBG_RI(1, "Unknown RWCOMPAT_COPY nodetype %04X at %08x\n",
+					je16_to_cpu(node.u.nodetype), ref_offset(ref));
 				break;
 			case JFFS3_FEATURE_RWCOMPAT_DELETE:
-				printk(KERN_NOTICE "Unknown RWCOMPAT_DELETE nodetype %04X at %08x\n", je16_to_cpu(node.u.nodetype), ref_offset(ref));
+				DBG_RI(1, "Unknown RWCOMPAT_DELETE nodetype %04X at %08x\n",
+					je16_to_cpu(node.u.nodetype), ref_offset(ref));
 				jffs3_mark_node_obsolete(c, ref);
 				break;
 			}
@@ -473,7 +483,7 @@
 {
 	struct jffs3_inode_cache *ret;
 
-	D2(printk(KERN_DEBUG "jffs3_get_ino_cache(): ino %u\n", ino));
+	DBG(1, "ino %u\n", ino);
 
 	ret = c->inocache_list[ino % INOCACHE_HASHSIZE];
 	while (ret && ret->ino < ino) {
@@ -483,14 +493,14 @@
 	if (ret && ret->ino != ino)
 		ret = NULL;
 
-	D2(printk(KERN_DEBUG "jffs3_get_ino_cache found %p for ino %u\n", ret, ino));
+	DBG(1, "found %p for ino %u\n", ret, ino);
 	return ret;
 }
 
 void jffs3_add_ino_cache (struct jffs3_sb_info *c, struct jffs3_inode_cache *new)
 {
 	struct jffs3_inode_cache **prev;
-	D2(printk(KERN_DEBUG "jffs3_add_ino_cache: Add %p (ino #%u)\n", new, new->ino));
+	DBG(2, "Add %p (ino #%u)\n", new, new->ino);
 	spin_lock(&c->inocache_lock);
 	
 	prev = &c->inocache_list[new->ino % INOCACHE_HASHSIZE];
@@ -507,7 +517,7 @@
 void jffs3_del_ino_cache(struct jffs3_sb_info *c, struct jffs3_inode_cache *old)
 {
 	struct jffs3_inode_cache **prev;
-	D2(printk(KERN_DEBUG "jffs3_del_ino_cache: Del %p (ino #%u)\n", old, old->ino));
+	DBG(2, "Del %p (ino #%u)\n", old, old->ino);
 	spin_lock(&c->inocache_lock);
 	
 	prev = &c->inocache_list[old->ino % INOCACHE_HASHSIZE];
@@ -531,7 +541,7 @@
 		this = c->inocache_list[i];
 		while (this) {
 			next = this->next;
-			D2(printk(KERN_DEBUG "jffs3_free_ino_caches: Freeing ino #%u at %p\n", this->ino, this));
+			DBG(2, "Freeing ino #%u at %p\n", this->ino, this);
 			jffs3_free_inode_cache(this);
 			this = next;
 		}
@@ -563,29 +573,29 @@
 	struct jffs3_node_frag *prev = NULL;
 	struct jffs3_node_frag *frag = NULL;
 
-	D2(printk(KERN_DEBUG "jffs3_lookup_node_frag(%p, %d)\n", fragtree, offset));
+	DBG_BI(2, "fragtree %p, ofset %d\n", fragtree, offset);
 
 	next = fragtree->rb_node;
 
 	while(next) {
 		frag = rb_entry(next, struct jffs3_node_frag, rb);
 
-		D2(printk(KERN_DEBUG "Considering frag %d-%d (%p). left %p, right %p\n",
-			  frag->ofs, frag->ofs+frag->size, frag, frag->rb.rb_left, frag->rb.rb_right));
+		DBG_BI(2, "Considering frag %d-%d (%p). left %p, right %p\n",
+			  frag->ofs, frag->ofs+frag->size, frag, frag->rb.rb_left, frag->rb.rb_right);
 		if (frag->ofs + frag->size <= offset) {
-			D2(printk(KERN_DEBUG "Going right from frag %d-%d, before the region we care about\n",
-				  frag->ofs, frag->ofs+frag->size));
+			DBG_BI(2, "Going right from frag %d-%d, before the region we care about\n",
+				  frag->ofs, frag->ofs+frag->size);
 			/* Remember the closest smaller match on the way down */
 			if (!prev || frag->ofs > prev->ofs)
 				prev = frag;
 			next = frag->rb.rb_right;
 		} else if (frag->ofs > offset) {
-			D2(printk(KERN_DEBUG "Going left from frag %d-%d, after the region we care about\n",
-				  frag->ofs, frag->ofs+frag->size));
+			DBG_BI(2, "Going left from frag %d-%d, after the region we care about\n",
+				  frag->ofs, frag->ofs+frag->size);
 			next = frag->rb.rb_left;
 		} else {
-			D2(printk(KERN_DEBUG "Returning frag %d,%d, matched\n",
-				  frag->ofs, frag->ofs+frag->size));
+			DBG_BI(2, "Returning frag %d,%d, matched\n",
+				  frag->ofs, frag->ofs+frag->size);
 			return frag;
 		}
 	}
@@ -594,10 +604,10 @@
 	   and return the closest smaller one */
 
 	if (prev)
-		D2(printk(KERN_DEBUG "No match. Returning frag %d,%d, closest previous\n",
-			  prev->ofs, prev->ofs+prev->size));
+		DBG_BI(2, "No match. Returning frag %d,%d, closest previous\n",
+			  prev->ofs, prev->ofs+prev->size);
 	else 
-		D2(printk(KERN_DEBUG "Returning NULL, empty fragtree\n"));
+		DBG_BI(2, "Returning NULL, empty fragtree\n");
 	
 	return prev;
 }
@@ -616,21 +626,21 @@
 
 	while(frag) {
 		if (frag->rb.rb_left) {
-			D2(printk(KERN_DEBUG "Going left from frag (%p) %d-%d\n", 
-				  frag, frag->ofs, frag->ofs+frag->size));
+			DBG_BI(2, "Going left from frag (%p) %d-%d\n", 
+				  frag, frag->ofs, frag->ofs+frag->size);
 			frag = frag_left(frag);
 			continue;
 		}
 		if (frag->rb.rb_right) {
-			D2(printk(KERN_DEBUG "Going right from frag (%p) %d-%d\n", 
-				  frag, frag->ofs, frag->ofs+frag->size));
+			DBG_BI(2, "Going right from frag (%p) %d-%d\n", 
+				  frag, frag->ofs, frag->ofs+frag->size);
 			frag = frag_right(frag);
 			continue;
 		}
 
-		D2(printk(KERN_DEBUG "jffs3_kill_fragtree: frag at 0x%x-0x%x: node %p, frags %d--\n",
+		DBG_BI(2, "frag at 0x%x-0x%x: node %p, frags %d--\n",
 			  frag->ofs, frag->ofs+frag->size, frag->node,
-			  frag->node?frag->node->frags:0));
+			  frag->node?frag->node->frags:0);
 			
 		if (frag->node && !(--frag->node->frags)) {
 			/* Not a hole, and it's the final remaining frag 
@@ -660,20 +670,20 @@
 	struct rb_node *parent = &base->rb;
 	struct rb_node **link = &parent;
 
-	D2(printk(KERN_DEBUG "jffs3_fragtree_insert(%p; %d-%d, %p)\n", newfrag, 
-		  newfrag->ofs, newfrag->ofs+newfrag->size, base));
+	DBG_BI(2, "newfrag %p frag range %d-%d, base %p)\n", newfrag, 
+		  newfrag->ofs, newfrag->ofs+newfrag->size, base);
 
 	while (*link) {
 		parent = *link;
 		base = rb_entry(parent, struct jffs3_node_frag, rb);
 	
-		D2(printk(KERN_DEBUG "fragtree_insert considering frag at 0x%x\n", base->ofs));
+		DBG_BI(2, "considering frag at 0x%x\n", base->ofs);
 		if (newfrag->ofs > base->ofs)
 			link = &base->rb.rb_right;
 		else if (newfrag->ofs < base->ofs)
 			link = &base->rb.rb_left;
 		else {
-			printk(KERN_CRIT "Duplicate frag at %08x (%p,%p)\n", newfrag->ofs, newfrag, base);
+			ERROR_MSG("Duplicate frag at %08x (%p,%p)\n", newfrag->ofs, newfrag, base);
 			BUG();
 		}
 	}

Index: nodemgmt.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs3/nodemgmt.c,v
retrieving revision 3.3
retrieving revision 3.4
diff -u -r3.3 -r3.4
--- nodemgmt.c	21 Dec 2004 15:18:50 -0000	3.3
+++ nodemgmt.c	21 Dec 2004 17:12:56 -0000	3.4
@@ -48,10 +48,10 @@
 	/* align it */
 	minsize = PAD(minsize);
 
-	D1(printk(KERN_DEBUG "jffs3_reserve_space(): Requested 0x%x bytes\n", minsize));
+	DBG_RSV(1, "Requested 0x%x bytes\n", minsize);
 	down(&c->alloc_sem);
 
-	D1(printk(KERN_DEBUG "jffs3_reserve_space(): alloc sem got\n"));
+	DBG_RSV(1, "jffs3_reserve_space(): alloc sem got\n");
 
 	spin_lock(&c->erase_completion_lock);
 
@@ -76,11 +76,12 @@
 			dirty = c->dirty_size + c->erasing_size - c->nr_erasing_blocks * c->sector_size + c->unchecked_size;
 			if (dirty < c->nospc_dirty_size) {
 				if (prio == ALLOC_DELETION && c->nr_free_blocks + c->nr_erasing_blocks >= c->resv_blocks_deletion) {
-					printk(KERN_NOTICE "jffs3_reserve_space(): Low on dirty space to GC, but it's a deletion. Allowing...\n");
+					DBG_RSV(1, "Low on dirty space to GC, but it's a deletion. Allowing...\n");
 					break;
 				}
-				D1(printk(KERN_DEBUG "dirty size 0x%08x + unchecked_size 0x%08x < nospc_dirty_size 0x%08x, returning -ENOSPC\n",
-					  dirty, c->unchecked_size, c->sector_size));
+				DBG_RSV(1, "dirty size 0x%08x + unchecked_size 0x%08x < "
+					"nospc_dirty_size 0x%08x, returning -ENOSPC\n",
+					dirty, c->unchecked_size, c->sector_size);
 
 				spin_unlock(&c->erase_completion_lock);
 				up(&c->alloc_sem);
@@ -99,12 +100,14 @@
 			avail = c->free_size + c->dirty_size + c->erasing_size + c->unchecked_size;
 			if ( (avail / c->sector_size) <= blocksneeded) {
 				if (prio == ALLOC_DELETION && c->nr_free_blocks + c->nr_erasing_blocks >= c->resv_blocks_deletion) {
-					printk(KERN_NOTICE "jffs3_reserve_space(): Low on possibly available space, but it's a deletion. Allowing...\n");
+					DBG_RSV(1, "Low on possibly available space, "
+						"but it's a deletion. Allowing...\n");
 					break;
 				}
 
-				D1(printk(KERN_DEBUG "max. available size 0x%08x  < blocksneeded * sector_size 0x%08x, returning -ENOSPC\n",
-					  avail, blocksneeded * c->sector_size));
+				DBG_RSV(1, "max. available size 0x%08x  < blocksneeded * sector_size "
+					"0x%08x, returning -ENOSPC\n",
+					avail, blocksneeded * c->sector_size);
 				spin_unlock(&c->erase_completion_lock);
 				up(&c->alloc_sem);
 				return -ENOSPC;
@@ -112,9 +115,14 @@
 
 			up(&c->alloc_sem);
 
-			D1(printk(KERN_DEBUG "Triggering GC pass. nr_free_blocks %d, nr_erasing_blocks %d, free_size 0x%08x, dirty_size 0x%08x, wasted_size 0x%08x, used_size 0x%08x, erasing_size 0x%08x, bad_size 0x%08x (total 0x%08x of 0x%08x)\n",
-				  c->nr_free_blocks, c->nr_erasing_blocks, c->free_size, c->dirty_size, c->wasted_size, c->used_size, c->erasing_size, c->bad_size,
-				  c->free_size + c->dirty_size + c->wasted_size + c->used_size + c->erasing_size + c->bad_size, c->flash_size));
+			DBG_RSV(1, "Triggering GC pass. nr_free_blocks %d, nr_erasing_blocks %d, "
+					"free_size 0x%08x, dirty_size 0x%08x, wasted_size 0x%08x, "
+					"used_size 0x%08x, erasing_size 0x%08x, bad_size 0x%08x "
+					"(total 0x%08x of 0x%08x)\n",
+					c->nr_free_blocks, c->nr_erasing_blocks, c->free_size,
+					c->dirty_size, c->wasted_size, c->used_size, c->erasing_size,
+					c->bad_size, c->free_size + c->dirty_size + c->wasted_size
+					 + c->used_size + c->erasing_size + c->bad_size, c->flash_size);
 			spin_unlock(&c->erase_completion_lock);
 			
 			ret = jffs3_garbage_collect_pass(c);
@@ -132,7 +140,7 @@
 
 		ret = jffs3_do_reserve_space(c, minsize, ofs, len, sumsize);
 		if (ret) {
-			D1(printk(KERN_DEBUG "jffs3_reserve_space: ret is %d\n", ret));
+			DBG_RSV(1, "ret is %d\n", ret);
 		}
 	}
 	spin_unlock(&c->erase_completion_lock);
@@ -146,13 +154,13 @@
 	int ret = -EAGAIN;
 	minsize = PAD(minsize);
 
-	D1(printk(KERN_DEBUG "jffs3_reserve_space_gc(): Requested 0x%x bytes\n", minsize));
+	DBG_RSV(1, "jffs3_reserve_space_gc(): Requested 0x%x bytes\n", minsize);
 
 	spin_lock(&c->erase_completion_lock);
 	while(ret == -EAGAIN) {
 		ret = jffs3_do_reserve_space(c, minsize, ofs, len, sumsize);
 		if (ret) {
-		        D1(printk(KERN_DEBUG "jffs3_reserve_space_gc: looping, ret is %d\n", ret));
+		        DBG_RSV(1, "looping, ret is %d\n", ret);
 		}
 	}
 	spin_unlock(&c->erase_completion_lock);
@@ -171,19 +179,18 @@
 #ifdef CONFIG_JFFS3_SUMMARY
 
 	if (sumsize != JFFS3_SUMMARY_NOSUM_SIZE) {
-		
 		int ret;
 		
-        if (jeb) {
-            if ((ret=jffs3_sum_care_sum_collected(jeb))) return ret;
-            nofree_size = sumsize + jeb->sum_collected->sum_size + JFFS3_SUMMARY_FRAME_SIZE;
-        }
+		if (jeb) {
+		    if ((ret=jffs3_sum_care_sum_collected(jeb))) return ret;
+		    nofree_size = sumsize + jeb->sum_collected->sum_size + JFFS3_SUMMARY_FRAME_SIZE;
+		}
 		
-		DBG_SUMMARY(1,"JFFS3: minsize %d , jeb->free(%d) , sum_collected->size(%d) , sumsize(%d)\n",
+		DBG_SUMMARY(1,"minsize %d , jeb->free(%d) , sum_collected->size(%d) , sumsize(%d)\n",
 		minsize,jeb->free_size,jeb->sum_collected->sum_size,sumsize);
 		
 		if (jeb && (minsize + jeb->sum_collected->sum_size + sumsize + JFFS3_SUMMARY_FRAME_SIZE > jeb->free_size)) {
-			DBG_SUMMARY(1,"JFFS3: generating summary for 0x%08x.\n", jeb->offset);
+			DBG_SUMMARY(1,"generating summary for 0x%08x.\n", jeb->offset);
 			if (jeb->sum_collected->sum_size == JFFS3_SUMMARY_NOSUM_SIZE) {
 				sumsize = JFFS3_SUMMARY_NOSUM_SIZE;
 				jffs3_sum_clean_collected(jeb);
@@ -195,7 +202,8 @@
 			if (ret)
 				return ret;
 			
-			if (jeb->sum_collected->sum_size == JFFS3_SUMMARY_NOSUM_SIZE) { //jffs3_write_sumnode can't write out the summary information
+			if (jeb->sum_collected->sum_size == JFFS3_SUMMARY_NOSUM_SIZE) {
+				/* jffs3_write_sumnode can't write out the summary information */
 				sumsize = JFFS3_SUMMARY_NOSUM_SIZE;
 				jffs3_sum_clean_collected(jeb);
 				goto restart;
@@ -208,31 +216,32 @@
 				jeb->dirty_size += jeb->wasted_size;
 				jeb->wasted_size = 0;
 				if (VERYDIRTY(c, jeb->dirty_size)) {
-					D1(printk(KERN_DEBUG "Adding full erase block at 0x%08x to very_dirty_list (free 0x%08x, dirty 0x%08x, used 0x%08x\n",
-					  jeb->offset, jeb->free_size, jeb->dirty_size, jeb->used_size));
+					DBG_BL(1, "Adding full erase block at 0x%08x to very_dirty_list "
+						"(free 0x%08x, dirty 0x%08x, used 0x%08x\n",
+						  jeb->offset, jeb->free_size, jeb->dirty_size, jeb->used_size);
 					list_add_tail(&jeb->list, &c->very_dirty_list);
 				} else {
-					D1(printk(KERN_DEBUG "Adding full erase block at 0x%08x to dirty_list (free 0x%08x, dirty 0x%08x, used 0x%08x\n",
-					  jeb->offset, jeb->free_size, jeb->dirty_size, jeb->used_size));
+					DBG_BL(1, "Adding full erase block at 0x%08x to dirty_list "
+						"(free 0x%08x, dirty 0x%08x, used 0x%08x\n",
+						jeb->offset, jeb->free_size, jeb->dirty_size, jeb->used_size);
 					list_add_tail(&jeb->list, &c->dirty_list);
 				}
 			} else { 
-				D1(printk(KERN_DEBUG "Adding full erase block at 0x%08x to clean_list (free 0x%08x, dirty 0x%08x, used 0x%08x\n",
- 				  jeb->offset, jeb->free_size, jeb->dirty_size, jeb->used_size));
+				DBG_BL(1, "Adding full erase block at 0x%08x to clean_list "
+					"(free 0x%08x, dirty 0x%08x, used 0x%08x\n",
+ 					jeb->offset, jeb->free_size, jeb->dirty_size, jeb->used_size);
 				list_add_tail(&jeb->list, &c->clean_list);
 			}
 			c->nextblock = jeb = NULL;
 		}
-	}
-	else {	
+	} else {	
 #endif
-
 		if (jeb && minsize > jeb->free_size) {
 			/* Skip the end of this block and file it as having some dirty space */
 			/* If there's a pending write to it, flush now */
 			if (jffs3_wbuf_dirty(c)) {
 				spin_unlock(&c->erase_completion_lock);
-				D1(printk(KERN_DEBUG "jffs3_do_reserve_space: Flushing write buffer\n"));			    
+				DBG_RSV(1, "Flushing write buffer\n");
 				jffs3_flush_wbuf_pad(c);
 				spin_lock(&c->erase_completion_lock);
 				jeb = c->nextblock;
@@ -250,26 +259,27 @@
 				jeb->dirty_size += jeb->wasted_size;
 				jeb->wasted_size = 0;
 				if (VERYDIRTY(c, jeb->dirty_size)) {
-					D1(printk(KERN_DEBUG "Adding full erase block at 0x%08x to very_dirty_list (free 0x%08x, dirty 0x%08x, used 0x%08x\n",
-					  jeb->offset, jeb->free_size, jeb->dirty_size, jeb->used_size));
+					DBG_BL(1, "Adding full erase block at 0x%08x to very_dirty_list"
+						" (free 0x%08x, dirty 0x%08x, used 0x%08x\n",
+						jeb->offset, jeb->free_size, jeb->dirty_size, jeb->used_size);
 					list_add_tail(&jeb->list, &c->very_dirty_list);
 				} else {
-					D1(printk(KERN_DEBUG "Adding full erase block at 0x%08x to dirty_list (free 0x%08x, dirty 0x%08x, used 0x%08x\n",
-					  jeb->offset, jeb->free_size, jeb->dirty_size, jeb->used_size));
+					DBG_BL(1, "Adding full erase block at 0x%08x to dirty_list "
+						"(free 0x%08x, dirty 0x%08x, used 0x%08x\n",
+						jeb->offset, jeb->free_size, jeb->dirty_size, jeb->used_size);
 					list_add_tail(&jeb->list, &c->dirty_list);
 				}
 			} else { 
-				D1(printk(KERN_DEBUG "Adding full erase block at 0x%08x to clean_list (free 0x%08x, dirty 0x%08x, used 0x%08x\n",
-				  jeb->offset, jeb->free_size, jeb->dirty_size, jeb->used_size));
+				DBG_BL(1, "Adding full erase block at 0x%08x to clean_list (free 0x%08x, "
+					"dirty 0x%08x, used 0x%08x\n",
+					jeb->offset, jeb->free_size, jeb->dirty_size, jeb->used_size);
 				list_add_tail(&jeb->list, &c->clean_list);
 			}
 			c->nextblock = jeb = NULL;
 		}
-	
 #ifdef CONFIG_JFFS3_SUMMARY
  	}
 #endif		
-	
 	if (!jeb) {
 		struct list_head *next;
 		/* Take the next block off the 'free' list */
@@ -285,13 +295,13 @@
 				list_add_tail(&ejeb->list, &c->erase_pending_list);
 				c->nr_erasing_blocks++;
 				jffs3_erase_pending_trigger(c);
-				D1(printk(KERN_DEBUG "jffs3_do_reserve_space: Triggering erase of erasable block at 0x%08x\n",
-					  ejeb->offset));
+				DBG_RSV(1, "Triggering erase of erasable block at 0x%08x\n",
+					  ejeb->offset);
 			}
 
 			if (!c->nr_erasing_blocks && 
 			    !list_empty(&c->erasable_pending_wbuf_list)) {
-				D1(printk(KERN_DEBUG "jffs3_do_reserve_space: Flushing write buffer\n"));
+				DBG_RSV(1, "Flushing write buffer\n");
 				/* c->nextblock is NULL, no update to c->nextblock allowed */			    
 				spin_unlock(&c->erase_completion_lock);
 				jffs3_flush_wbuf_pad(c);
@@ -303,9 +313,13 @@
 			if (!c->nr_erasing_blocks) {
 				/* Ouch. We're in GC, or we wouldn't have got here.
 				   And there's no space left. At all. */
-				printk(KERN_CRIT "Argh. No free space left for GC. nr_erasing_blocks is %d. nr_free_blocks is %d. (erasableempty: %s, erasingempty: %s, erasependingempty: %s)\n", 
-				       c->nr_erasing_blocks, c->nr_free_blocks, list_empty(&c->erasable_list)?"yes":"no", 
-				       list_empty(&c->erasing_list)?"yes":"no", list_empty(&c->erase_pending_list)?"yes":"no");
+				WARNING_MSG("Argh. No free space left for GC. nr_erasing_blocks is %d."
+					" nr_free_blocks is %d. (erasableempty: %s, erasingempty: %s, "
+					"erasependingempty: %s)\n", 
+				       c->nr_erasing_blocks, c->nr_free_blocks,
+				       list_empty(&c->erasable_list)?"yes" : "no", 
+				       list_empty(&c->erasing_list)?"yes" : "no",
+				       list_empty(&c->erase_pending_list)?"yes":"no");
 				return -ENOSPC;
 			}
 
@@ -326,7 +340,8 @@
 		c->nr_free_blocks--;
 
 		if (jeb->free_size != c->sector_size - c->cleanmarker_size) {
-			printk(KERN_WARNING "Eep. Block 0x%08x taken from free_list had free_size of 0x%08x!!\n", jeb->offset, jeb->free_size);
+			WARNING_MSG("Eep. Block 0x%08x taken from free_list had free_size of 0x%08x!!\n",
+					jeb->offset, jeb->free_size);
 			goto restart;
 		}
 	}
@@ -348,7 +363,7 @@
 		spin_lock(&c->erase_completion_lock);
 	}
 
-	D1(printk(KERN_DEBUG "jffs3_do_reserve_space(): Giving 0x%x bytes at 0x%x\n", *len, *ofs));
+	DBG_RSV(1, "Giving 0x%x bytes at 0x%x\n", *len, *ofs);
 	return 0;
 }
 
@@ -364,7 +379,6 @@
  *
  *	Must be called with the alloc_sem held.
  */
- 
 int jffs3_add_physical_node_ref(struct jffs3_sb_info *c, struct jffs3_raw_node_ref *new)
 {
 	struct jffs3_eraseblock *jeb;
@@ -373,10 +387,10 @@
 	jeb = &c->blocks[new->flash_offset / c->sector_size];
 	len = ref_totlen(c, jeb, new);
 
-	D1(printk(KERN_DEBUG "jffs3_add_physical_node_ref(): Node at 0x%x(%d), size 0x%x\n", ref_offset(new), ref_flags(new), len));
+	DBG_NR(1, "Node at 0x%x(%d), size 0x%x\n", ref_offset(new), ref_flags(new), len);
 #if 1
 	if (jeb != c->nextblock || (ref_offset(new)) != jeb->offset + (c->sector_size - jeb->free_size)) {
-		printk(KERN_WARNING "argh. node added in wrong place\n");
+		WARNING_MSG("argh. node added in wrong place\n");
 		jffs3_free_raw_node_ref(new);
 		return -EINVAL;
 	}
@@ -401,8 +415,9 @@
 
 	if (!jeb->free_size && !jeb->dirty_size) {
 		/* If it lives on the dirty_list, jffs3_reserve_space will put it there */
-		D1(printk(KERN_DEBUG "Adding full erase block at 0x%08x to clean_list (free 0x%08x, dirty 0x%08x, used 0x%08x\n",
-			  jeb->offset, jeb->free_size, jeb->dirty_size, jeb->used_size));
+		DBG_BL(1, "Adding full erase block at 0x%08x to clean_list "
+			"(free 0x%08x, dirty 0x%08x, used 0x%08x\n",
+			jeb->offset, jeb->free_size, jeb->dirty_size, jeb->used_size);
 		if (jffs3_wbuf_dirty(c)) {
 			/* Flush the last write in the block if it's outstanding */
 			spin_unlock(&c->erase_completion_lock);
@@ -424,7 +439,7 @@
 
 void jffs3_complete_reservation(struct jffs3_sb_info *c)
 {
-	D1(printk(KERN_DEBUG "jffs3_complete_reservation()\n"));
+	DBG_RSV(1, "entering\n");
 	jffs3_garbage_collect_trigger(c);
 	up(&c->alloc_sem);
 }
@@ -435,7 +450,7 @@
 
 	list_for_each(this, head) {
 		if (this == obj) {
-			D1(printk("%p is on list at %p\n", obj, head));
+			DBG_BL(1, "%p is on list at %p\n", obj, head);
 			return 1;
 
 		}
@@ -452,16 +467,18 @@
 	size_t retlen;
 
 	if(!ref) {
-		printk(KERN_NOTICE "EEEEEK. jffs3_mark_node_obsolete called with NULL node\n");
-		return;
+		ERROR_MSG("called with NULL node\n");
+		BUG();
 	}
+	
 	if (ref_obsolete(ref)) {
-		D1(printk(KERN_DEBUG "jffs3_mark_node_obsolete called with already obsolete node at 0x%08x\n", ref_offset(ref)));
+		DBG_NR(1, "called with already obsolete node at 0x%08x\n", ref_offset(ref));
 		return;
 	}
+
 	blocknr = ref->flash_offset / c->sector_size;
 	if (blocknr >= c->nr_blocks) {
-		printk(KERN_NOTICE "raw node at 0x%08x is off the end of device!\n", ref->flash_offset);
+		ERROR_MSG("raw node at 0x%08x is off the end of device!\n", ref->flash_offset);
 		BUG();
 	}
 	jeb = &c->blocks[blocknr];
@@ -481,27 +498,30 @@
 
 	if (ref_flags(ref) == REF_UNCHECKED) {
 		D1(if (unlikely(jeb->unchecked_size < ref_totlen(c, jeb, ref))) {
-			printk(KERN_NOTICE "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);
+			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();
 		})
-		D1(printk(KERN_DEBUG "Obsoleting previously unchecked node at 0x%08x of len %x: ", ref_offset(ref), ref_totlen(c, jeb, ref)));
+		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))) {
-			printk(KERN_NOTICE "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);
+			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();
 		})
-		D1(printk(KERN_DEBUG "Obsoleting node at 0x%08x of len %x: ", ref_offset(ref), ref_totlen(c, jeb, ref)));
+		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);
 	}
 
 	// Take care, that wasted size is taken into concern
 	if ((jeb->dirty_size || ISDIRTY(jeb->wasted_size + ref_totlen(c, jeb, ref))) && jeb != c->nextblock) {
-		D1(printk("Dirtying\n"));
+		DBG_NR(1, "Dirtying\n");
 		addedsize = ref_totlen(c, jeb, ref);
 		jeb->dirty_size += ref_totlen(c, jeb, ref);
 		c->dirty_size += ref_totlen(c, jeb, ref);
@@ -509,12 +529,12 @@
 		/* Convert wasted space to dirty, if not a bad block */
 		if (jeb->wasted_size) {
 			if (on_list(&jeb->list, &c->bad_used_list)) {
-				D1(printk(KERN_DEBUG "Leaving block at %08x on the bad_used_list\n",
-					  jeb->offset));
+				DBG_BL(1, "Leaving block at %08x on the bad_used_list\n",
+					  jeb->offset);
 				addedsize = 0; /* To fool the refiling code later */
 			} else {
-				D1(printk(KERN_DEBUG "Converting %d bytes of wasted space to dirty in block at %08x\n",
-					  jeb->wasted_size, jeb->offset));
+				DBG_NR(1, "Converting %d bytes of wasted space to dirty in block at %08x\n",
+					  jeb->wasted_size, jeb->offset);
 				addedsize += jeb->wasted_size;
 				jeb->dirty_size += jeb->wasted_size;
 				c->dirty_size += jeb->wasted_size;
@@ -523,7 +543,7 @@
 			}
 		}
 	} else {
-		D1(printk("Wasting\n"));
+		DBG_NR(1, "Wasting\n");
 		addedsize = 0;
 		jeb->wasted_size += ref_totlen(c, jeb, ref);
 		c->wasted_size += ref_totlen(c, jeb, ref);	
@@ -545,50 +565,51 @@
 	}
 
 	if (jeb == c->nextblock) {
-		D2(printk(KERN_DEBUG "Not moving nextblock 0x%08x to dirty/erase_pending list\n", jeb->offset));
+		DBG_NR(2, "Not moving nextblock 0x%08x to dirty/erase_pending list\n", jeb->offset);
 	} else if (!jeb->used_size && !jeb->unchecked_size) {
 		if (jeb == c->gcblock) {
-			D1(printk(KERN_DEBUG "gcblock at 0x%08x completely dirtied. Clearing gcblock...\n", jeb->offset));
+			DBG_NR(1, "gcblock at 0x%08x completely dirtied. Clearing gcblock...\n", jeb->offset);
 			c->gcblock = NULL;
 		} else {
-			D1(printk(KERN_DEBUG "Eraseblock at 0x%08x completely dirtied. Removing from (dirty?) list...\n", jeb->offset));
+			DBG_BL(1, "Eraseblock at 0x%08x completely dirtied. Removing from "
+				"(dirty?) list...\n", jeb->offset);
 			list_del(&jeb->list);
 		}
 		if (jffs3_wbuf_dirty(c)) {
-			D1(printk(KERN_DEBUG "...and adding to erasable_pending_wbuf_list\n"));
+			DBG_BL(1, "...and adding to erasable_pending_wbuf_list\n");
 			list_add_tail(&jeb->list, &c->erasable_pending_wbuf_list);
 		} else {
 			if (jiffies & 127) {
 				/* Most of the time, we just erase it immediately. Otherwise we
 				   spend ages scanning it on mount, etc. */
-				D1(printk(KERN_DEBUG "...and adding to erase_pending_list\n"));
+				DBG_BL(1, "...and adding to erase_pending_list\n");
 				list_add_tail(&jeb->list, &c->erase_pending_list);
 				c->nr_erasing_blocks++;
 				jffs3_erase_pending_trigger(c);
 			} else {
 				/* Sometimes, however, we leave it elsewhere so it doesn't get
 				   immediately reused, and we spread the load a bit. */
-				D1(printk(KERN_DEBUG "...and adding to erasable_list\n"));
+				DBG_BL(1, "...and adding to erasable_list\n");
 				list_add_tail(&jeb->list, &c->erasable_list);
 			}				
 		}
-		D1(printk(KERN_DEBUG "Done OK\n"));
+		DBG_NR(1, "Done OK\n");
 	} else if (jeb == c->gcblock) {
-		D2(printk(KERN_DEBUG "Not moving gcblock 0x%08x to dirty_list\n", jeb->offset));
+		DBG_NR(2, "Not moving gcblock 0x%08x to dirty_list\n", jeb->offset);
 	} else if (ISDIRTY(jeb->dirty_size) && !ISDIRTY(jeb->dirty_size - addedsize)) {
-		D1(printk(KERN_DEBUG "Eraseblock at 0x%08x is freshly dirtied. Removing from clean list...\n", jeb->offset));
+		DBG_BL(1, "Eraseblock at 0x%08x is freshly dirtied. Removing from clean list...\n", jeb->offset);
 		list_del(&jeb->list);
-		D1(printk(KERN_DEBUG "...and adding to dirty_list\n"));
+		DBG_BL(1, "...and adding to dirty_list\n");
 		list_add_tail(&jeb->list, &c->dirty_list);
 	} else if (VERYDIRTY(c, jeb->dirty_size) &&
 		   !VERYDIRTY(c, jeb->dirty_size - addedsize)) {
-		D1(printk(KERN_DEBUG "Eraseblock at 0x%08x is now very dirty. Removing from dirty list...\n", jeb->offset));
+		DBG_BL(1, "Eraseblock at 0x%08x is now very dirty. Removing from dirty list...\n", jeb->offset);
 		list_del(&jeb->list);
-		D1(printk(KERN_DEBUG "...and adding to very_dirty_list\n"));
+		DBG_BL(1, "...and adding to very_dirty_list\n");
 		list_add_tail(&jeb->list, &c->very_dirty_list);
 	} else {
-		D1(printk(KERN_DEBUG "Eraseblock at 0x%08x not moved anywhere. (free 0x%08x, dirty 0x%08x, used 0x%08x)\n",
-			  jeb->offset, jeb->free_size, jeb->dirty_size, jeb->used_size)); 
+		DBG_NR(1, "Eraseblock at 0x%08x not moved anywhere. (free 0x%08x, dirty 0x%08x, used 0x%08x)\n",
+			jeb->offset, jeb->free_size, jeb->dirty_size, jeb->used_size); 
 	}			  	
 
 	spin_unlock(&c->erase_completion_lock);
@@ -603,33 +624,35 @@
 	   the block hasn't _already_ been erased, and that 'ref' itself hasn't been freed yet
 	   by jffs3_free_all_node_refs() in erase.c. Which is nice. */
 
-	D1(printk(KERN_DEBUG "obliterating obsoleted node at 0x%08x\n", ref_offset(ref)));
+	DBG_NR(1, "obliterating obsoleted node at 0x%08x\n", ref_offset(ref));
 	ret = jffs3_flash_read(c, ref_offset(ref), sizeof(n), &retlen, (char *)&n);
 	if (ret) {
-		printk(KERN_WARNING "Read error reading from obsoleted node at 0x%08x: %d\n", ref_offset(ref), ret);
+		WARNING_MSG("Read error reading from obsoleted node at 0x%08x: %d\n", ref_offset(ref), ret);
 		goto out_erase_sem;
 	}
 	if (retlen != sizeof(n)) {
-		printk(KERN_WARNING "Short read from obsoleted node at 0x%08x: %zd\n", ref_offset(ref), retlen);
+		WARNING_MSG("Short read from obsoleted node at 0x%08x: %zd\n", ref_offset(ref), retlen);
 		goto out_erase_sem;
 	}
 	if (PAD(je32_to_cpu(n.totlen)) != PAD(ref_totlen(c, jeb, ref))) {
-		printk(KERN_WARNING "Node totlen on flash (0x%08x) != totlen from node ref (0x%08x)\n", je32_to_cpu(n.totlen), ref_totlen(c, jeb, ref));
+		WARNING_MSG("Node totlen on flash (0x%08x) != totlen from node ref (0x%08x)\n",
+			je32_to_cpu(n.totlen), ref_totlen(c, jeb, ref));
 		goto out_erase_sem;
 	}
 	if (!(je16_to_cpu(n.nodetype) & JFFS3_NODE_ACCURATE)) {
-		D1(printk(KERN_DEBUG "Node at 0x%08x was already marked obsolete (nodetype 0x%04x)\n", ref_offset(ref), je16_to_cpu(n.nodetype)));
+		DBG_NR(1, "Node at 0x%08x was already marked obsolete (nodetype 0x%04x)\n",
+				ref_offset(ref), je16_to_cpu(n.nodetype));
 		goto out_erase_sem;
 	}
 	/* XXX FIXME: This is ugly now */
 	n.nodetype = cpu_to_je16(je16_to_cpu(n.nodetype) & ~JFFS3_NODE_ACCURATE);
 	ret = jffs3_flash_write(c, ref_offset(ref), sizeof(n), &retlen, (char *)&n);
 	if (ret) {
-		printk(KERN_WARNING "Write error in obliterating obsoleted node at 0x%08x: %d\n", ref_offset(ref), ret);
+		WARNING_MSG("Write error in obliterating obsoleted node at 0x%08x: %d\n", ref_offset(ref), ret);
 		goto out_erase_sem;
 	}
 	if (retlen != sizeof(n)) {
-		printk(KERN_WARNING "Short write in obliterating obsoleted node at 0x%08x: %zd\n", ref_offset(ref), retlen);
+		WARNING_MSG("Short write in obliterating obsoleted node at 0x%08x: %zd\n", ref_offset(ref), retlen);
 		goto out_erase_sem;
 	}
 
@@ -657,7 +680,7 @@
 		ref->next_in_ino = NULL;
 
 		if (ic->nodes == (void *)ic) {
-			D1(printk(KERN_DEBUG "inocache for ino #%u is all gone now. Freeing\n", ic->ino));
+			DBG_NR(1, "inocache for ino #%u is all gone now. Freeing\n", ic->ino);
 			jffs3_del_ino_cache(c, ic);
 			jffs3_free_inode_cache(ic);
 		}
@@ -720,8 +743,8 @@
 	uint32_t dirty;
 
 	if (c->unchecked_size) {
-		D1(printk(KERN_DEBUG "jffs3_thread_should_wake(): unchecked_size %d, checked_ino #%d\n",
-			  c->unchecked_size, c->checked_ino));
+		DBG_GCT(1, "unchecked_size %d, checked_ino #%d\n",
+			  c->unchecked_size, c->checked_ino);
 		return 1;
 	}
 
@@ -739,8 +762,8 @@
 			(dirty > c->nospc_dirty_size)) 
 		ret = 1;
 
-	D1(printk(KERN_DEBUG "jffs3_thread_should_wake(): nr_free_blocks %d, nr_erasing_blocks %d, dirty_size 0x%x: %s\n", 
-		  c->nr_free_blocks, c->nr_erasing_blocks, c->dirty_size, ret?"yes":"no"));
+	DBG_GCT(1, "nr_free_blocks %d, nr_erasing_blocks %d, dirty_size 0x%x: %s\n", 
+		  c->nr_free_blocks, c->nr_erasing_blocks, c->dirty_size, ret ? "yes" : "no");
 
 	return ret;
 }





More information about the linux-mtd-cvs mailing list