mtd/fs/jffs3 compr.c,3.1,3.2 compr_zlib.c,3.1,3.2 debug.h,1.9,1.10

Artem Bityuckiy dedekind at infradead.org
Tue Dec 21 09:48:00 EST 2004


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

Modified Files:
	compr.c compr_zlib.c debug.h 
Log Message:
Change messaging.


Index: compr.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs3/compr.c,v
retrieving revision 3.1
retrieving revision 3.2
diff -u -r3.1 -r3.2
--- compr.c	9 Dec 2004 16:05:03 -0000	3.1
+++ compr.c	21 Dec 2004 14:47:57 -0000	3.2
@@ -15,6 +15,7 @@
  */
 
 #include "compr.h"
+#include "nodelist.h"
 
 static spinlock_t jffs3_compressor_list_lock = SPIN_LOCK_UNLOCKED;
 
@@ -72,7 +73,7 @@
         case JFFS3_COMPR_MODE_PRIORITY:
                 output_buf = kmalloc(*cdatalen,GFP_KERNEL);
                 if (!output_buf) {
-                        printk(KERN_WARNING "JFFS3: No memory for compressor allocation. Compression failed.\n");
+                        WARNING_MSG("No memory for compressor allocation. Compression failed.\n");
                         goto out;
                 }
                 orig_slen = *datalen;
@@ -122,7 +123,7 @@
                                 tmp_buf = kmalloc(orig_dlen,GFP_KERNEL);
                                 spin_lock(&jffs3_compressor_list_lock);
                                 if (!tmp_buf) {
-                                        printk(KERN_WARNING "JFFS3: No memory for compressor allocation. (%d bytes)\n",orig_dlen);
+                                        WARNING_MSG("No memory for compressor allocation. (%d bytes)\n", orig_dlen);
                                         continue;
                                 }
                                 else {
@@ -159,7 +160,7 @@
                 spin_unlock(&jffs3_compressor_list_lock);
                 break;
         default:
-                printk(KERN_ERR "JFFS3: unknow compression mode.\n");
+                ERROR_MSG("Unknow compression mode.\n");
         }
  out:
         if (ret == JFFS3_COMPR_NONE) {
@@ -204,7 +205,7 @@
                                 ret = this->decompress(cdata_in, data_out, cdatalen, datalen, NULL);
                                 spin_lock(&jffs3_compressor_list_lock);
                                 if (ret) {
-                                        printk(KERN_WARNING "Decompressor \"%s\" returned %d\n", this->name, ret);
+                                        WARNING_MSG("Decompressor \"%s\" returned %d\n", this->name, ret);
                                 }
                                 else {
                                         this->stat_decompr_blocks++;
@@ -214,7 +215,7 @@
                                 return ret;
                         }
                 }
-		printk(KERN_WARNING "JFFS3 compression type 0x%02x not available.\n", comprtype);
+		WARNING_MSG("Compression type 0x%02x not available.\n", comprtype);
                 spin_unlock(&jffs3_compressor_list_lock);
 		return -EIO;
 	}
@@ -226,7 +227,7 @@
         struct jffs3_compressor *this;
 
         if (!comp->name) {
-                printk(KERN_WARNING "NULL compressor name at registering JFFS3 compressor. Failed.\n");
+                WARNING_MSG("NULL compressor name at registering JFFS3 compressor. Failed.\n");
                 return -1;
         }
         comp->compr_buf_size=0;
@@ -236,7 +237,7 @@
         comp->stat_compr_new_size=0;
         comp->stat_compr_blocks=0;
         comp->stat_decompr_blocks=0;
-        D1(printk(KERN_DEBUG "Registering JFFS3 compressor \"%s\"\n", comp->name));
+        DBG_COMPR(1, "Registering JFFS3 compressor \"%s\"\n", comp->name);
 
         spin_lock(&jffs3_compressor_list_lock);
 
@@ -249,7 +250,7 @@
         list_add_tail(&comp->list, &jffs3_compressor_list);
 out:
         D2(list_for_each_entry(this, &jffs3_compressor_list, list) {
-                printk(KERN_DEBUG "Compressor \"%s\", prio %d\n", this->name, this->priority);
+                DBG_COMPR(1, "Compressor \"%s\", prio %d\n", this->name, this->priority);
         })
 
         spin_unlock(&jffs3_compressor_list_lock);
@@ -261,19 +262,19 @@
 {
         D2(struct jffs3_compressor *this;)
 
-        D1(printk(KERN_DEBUG "Unregistering JFFS3 compressor \"%s\"\n", comp->name));
+        DBG_COMPR(1, "Unregistering JFFS3 compressor \"%s\"\n", comp->name);
 
         spin_lock(&jffs3_compressor_list_lock);
 
         if (comp->usecount) {
                 spin_unlock(&jffs3_compressor_list_lock);
-                printk(KERN_WARNING "JFFS3: Compressor modul is in use. Unregister failed.\n");
+                WARNING_MSG("Compressor modul is in use. Unregister failed.\n");
                 return -1;
         }
         list_del(&comp->list);
 
         D2(list_for_each_entry(this, &jffs3_compressor_list, list) {
-                printk(KERN_DEBUG "Compressor \"%s\", prio %d\n", this->name, this->priority);
+                DBG_COMPR("Compressor \"%s\", prio %d\n", this->name, this->priority);
         })
         spin_unlock(&jffs3_compressor_list_lock);
         return 0;
@@ -370,7 +371,7 @@
                 }
         }
         spin_unlock(&jffs3_compressor_list_lock);
-        printk(KERN_WARNING "JFFS3: compressor %s not found.\n",name);
+        WARNING_MSG("Compressor %s not found.\n", name);
         return 1;
 }
 
@@ -396,7 +397,7 @@
                 }
         }
         spin_unlock(&jffs3_compressor_list_lock);
-        printk(KERN_WARNING "JFFS3: compressor %s not found.\n",name);        
+        WARNING_MSG("Compressor %s not found.\n",name);        
         return 1;
 reinsert:
         /* list is sorted in the order of priority, so if
@@ -445,13 +446,13 @@
 /* Setting default compression mode */
 #ifdef CONFIG_JFFS3_CMODE_NONE
         jffs3_compression_mode = JFFS3_COMPR_MODE_NONE;
-        D1(printk(KERN_INFO "JFFS3: default compression mode: none\n");)
+        DBG_COMPR(1, "Default compression mode: none\n");
 #else
 #ifdef CONFIG_JFFS3_CMODE_SIZE
         jffs3_compression_mode = JFFS3_COMPR_MODE_SIZE;
-        D1(printk(KERN_INFO "JFFS3: default compression mode: size\n");)
+        DBG_COMPR(1, "Default compression mode: size\n");
 #else
-        D1(printk(KERN_INFO "JFFS3: default compression mode: priority\n");)
+        DBG_COMPR(1, "Default compression mode: priority\n");
 #endif
 #endif
         return 0;

Index: compr_zlib.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs3/compr_zlib.c,v
retrieving revision 3.1
retrieving revision 3.2
diff -u -r3.1 -r3.2
--- compr_zlib.c	9 Dec 2004 16:05:04 -0000	3.1
+++ compr_zlib.c	21 Dec 2004 14:47:57 -0000	3.2
@@ -46,17 +46,17 @@
 {
 	def_strm.workspace = vmalloc(zlib_deflate_workspacesize());
 	if (!def_strm.workspace) {
-		printk(KERN_WARNING "Failed to allocate %d bytes for deflate workspace\n", zlib_deflate_workspacesize());
+		WARNING_MSG("Failed to allocate %d bytes for deflate workspace\n", zlib_deflate_workspacesize());
 		return -ENOMEM;
 	}
-	D1(printk(KERN_DEBUG "Allocated %d bytes for deflate workspace\n", zlib_deflate_workspacesize()));
+	DBG_COMPR(1, "Allocated %d bytes for deflate workspace\n", zlib_deflate_workspacesize());
 	inf_strm.workspace = vmalloc(zlib_inflate_workspacesize());
 	if (!inf_strm.workspace) {
-		printk(KERN_WARNING "Failed to allocate %d bytes for inflate workspace\n", zlib_inflate_workspacesize());
+		WARNING_MSG("Failed to allocate %d bytes for inflate workspace\n", zlib_inflate_workspacesize());
 		vfree(def_strm.workspace);
 		return -ENOMEM;
 	}
-	D1(printk(KERN_DEBUG "Allocated %d bytes for inflate workspace\n", zlib_inflate_workspacesize()));
+	DBG_COMPR(1, "Allocated %d bytes for inflate workspace\n", zlib_inflate_workspacesize());
 	return 0;
 }
 
@@ -81,7 +81,7 @@
 	down(&deflate_sem);
 
 	if (Z_OK != zlib_deflateInit(&def_strm, 3)) {
-		printk(KERN_WARNING "deflateInit failed\n");
+		WARNING_MSG("deflateInit failed\n");
 		up(&deflate_sem);
 		return -1;
 	}
@@ -95,13 +95,13 @@
 	while (def_strm.total_out < *dstlen - STREAM_END_SPACE && def_strm.total_in < *sourcelen) {
 		def_strm.avail_out = *dstlen - (def_strm.total_out + STREAM_END_SPACE);
 		def_strm.avail_in = min((unsigned)(*sourcelen-def_strm.total_in), def_strm.avail_out);
-		D1(printk(KERN_DEBUG "calling deflate with avail_in %d, avail_out %d\n",
-			  def_strm.avail_in, def_strm.avail_out));
+		DBG_COMPR(1, "calling deflate with avail_in %d, avail_out %d\n",
+			  def_strm.avail_in, def_strm.avail_out);
 		ret = zlib_deflate(&def_strm, Z_PARTIAL_FLUSH);
-		D1(printk(KERN_DEBUG "deflate returned with avail_in %d, avail_out %d, total_in %ld, total_out %ld\n", 
-			  def_strm.avail_in, def_strm.avail_out, def_strm.total_in, def_strm.total_out));
+		DBG_COMPR(1, "deflate returned with avail_in %d, avail_out %d, total_in %ld, total_out %ld\n", 
+			  def_strm.avail_in, def_strm.avail_out, def_strm.total_in, def_strm.total_out);
 		if (ret != Z_OK) {
-			D1(printk(KERN_DEBUG "deflate in loop returned %d\n", ret));
+			DBG_COMPR(1, "deflate in loop returned %d\n", ret);
 			zlib_deflateEnd(&def_strm);
 			up(&deflate_sem);
 			return -1;
@@ -113,20 +113,20 @@
 	zlib_deflateEnd(&def_strm);
 
 	if (ret != Z_STREAM_END) {
-		D1(printk(KERN_DEBUG "final deflate returned %d\n", ret));
+		DBG_COMPR(1, "final deflate returned %d\n", ret);
 		ret = -1;
 		goto out;
 	}
 
 	if (def_strm.total_out >= def_strm.total_in) {
-		D1(printk(KERN_DEBUG "zlib compressed %ld bytes into %ld; failing\n",
-			  def_strm.total_in, def_strm.total_out));
+		DBG_COMPR(1, "zlib compressed %ld bytes into %ld; failing\n",
+			  def_strm.total_in, def_strm.total_out);
 		ret = -1;
 		goto out;
 	}
 
-	D1(printk(KERN_DEBUG "zlib compressed %ld bytes into %ld\n",
-		  def_strm.total_in, def_strm.total_out));
+	DBG_COMPR(1, "zlib compressed %ld bytes into %ld\n",
+		  def_strm.total_in, def_strm.total_out);
 
 	*dstlen = def_strm.total_out;
 	*sourcelen = def_strm.total_in;
@@ -158,18 +158,18 @@
 	    ((data_in[0] & 0x0f) == Z_DEFLATED) &&
 	    !(((data_in[0]<<8) + data_in[1]) % 31)) {
 
-		D2(printk(KERN_DEBUG "inflate skipping adler32\n"));
+		DBG_COMPR(2, "inflate skipping adler32\n");
 		wbits = -((data_in[0] >> 4) + 8);
 		inf_strm.next_in += 2;
 		inf_strm.avail_in -= 2;
 	} else {
 		/* Let this remain D1 for now -- it should never happen */
-		D1(printk(KERN_DEBUG "inflate not skipping adler32\n"));
+		DBG_COMPR(1, "inflate not skipping adler32\n");
 	}
 
 
 	if (Z_OK != zlib_inflateInit2(&inf_strm, wbits)) {
-		printk(KERN_WARNING "inflateInit failed\n");
+		WARNING_MSG("inflateInit failed\n");
 		up(&inflate_sem);
 		return 1;
 	}
@@ -177,7 +177,7 @@
 	while((ret = zlib_inflate(&inf_strm, Z_FINISH)) == Z_OK)
 		;
 	if (ret != Z_STREAM_END) {
-		printk(KERN_NOTICE "inflate returned %d\n", ret);
+		DBG_COMPR(1, "inflate returned %d\n", ret);
 	}
 	zlib_inflateEnd(&inf_strm);
 	up(&inflate_sem);

Index: debug.h
===================================================================
RCS file: /home/cvs/mtd/fs/jffs3/debug.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- debug.h	21 Dec 2004 14:10:28 -0000	1.9
+++ debug.h	21 Dec 2004 14:47:57 -0000	1.10
@@ -34,6 +34,7 @@
 #define JFFS3_DBG_GCT		8	/* GC thread */
 #define JFFS3_DBG_VFS		9	/* VFS callback handlers */
 #define JFFS3_DBG_BLD		10	/* File system build (on mount) */
+#define JFFS3_DBG_COMPR		11	/* Compression */
 
 #if CONFIG_JFFS3_FS_DEBUG > 0
 #define JFFS3_DBG_PARANOIA_CHECKS	1
@@ -48,6 +49,7 @@
 #define JFFS3_DBG_SUBSYS_GCT_PRINT	1
 #define JFFS3_DBG_SUBSYS_VFS_PRINT	1
 #define JFFS3_DBG_SUBSYS_BLD_PRINT	1
+#define JFFS3_DBG_SUBSYS_COMPR_PRINT	1
 #else
 #define JFFS3_DBG_SUBSYS_OTHER_PRINT	0
 #define JFFS3_DBG_SUBSYS_SCAN_PRINT	0
@@ -59,6 +61,7 @@
 #define JFFS3_DBG_SUBSYS_GCT_PRINT	0
 #define JFFS3_DBG_SUBSYS_VFS_PRINT	0
 #define JFFS3_DBG_SUBSYS_BLD_PRINT	0
+#define JFFS3_DBG_SUBSYS_COMPR_PRINT	0
 #endif
 
 /*
@@ -71,6 +74,10 @@
 	char *subsysname = NULL;						\
 	if ((debug_level) >= CONFIG_JFFS3_FS_DEBUG) {				\
 		switch (subsystem) {						\
+			case JFFS3_DBG_COMPR:					\
+				if (JFFS3_DBG_SUBSYS_BLD_PRINT)			\
+					subsysname = "compr";			\
+				break;						\
 			case JFFS3_DBG_BLD:					\
 				if (JFFS3_DBG_SUBSYS_BLD_PRINT)			\
 					subsysname = "build";			\
@@ -154,6 +161,9 @@
 #define DBG_BLD(debug_level, args...)						\
 	JFFS3DBG_SUBSYSTEM(JFFS3_DBG_BLD, debug_level, args)
 
+#define DBG_COMPR(debug_level, args...)						\
+	JFFS3DBG_SUBSYSTEM(JFFS3_DBG_COMPR, debug_level, args)
+
 #define ERROR_MSG(args...)							\
 	do {									\
 		printk(KERN_ERR "[JFFS3] Error in %s(): ", __FUNCTION__);	\





More information about the linux-mtd-cvs mailing list