linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2 v3] udf : enable error print in udf_read_tagged().
@ 2011-10-03 13:53 Namjae Jeon
  2011-10-05 22:08 ` Jan Kara
  0 siblings, 1 reply; 36+ messages in thread
From: Namjae Jeon @ 2011-10-03 13:53 UTC (permalink / raw)
  To: jack, joe; +Cc: linux-kernel, Namjae Jeon

While reading metadata, if a problem occurs, Print out only one of the five case.(It also does not show a checksum properly.)
Because currently it have been disable by undef udf_debug.
If there is a problem with scratched disc or loader, the user needs to know which error happened.
And I use pr_fmt instead of printk by joe's suggestion. I try to modify totally it to pr_fmt also.

Signed-off-by: Namjae Jeon <linkinjeon@gmail.com>
---
 fs/udf/directory.c |    4 ++--
 fs/udf/inode.c     |   14 +++++++-------
 fs/udf/misc.c      |   17 ++++++++++-------
 fs/udf/super.c     |    2 +-
 fs/udf/truncate.c  |    5 ++---
 fs/udf/udfdecl.h   |   15 +++++++--------
 fs/udf/udftime.c   |    2 +-
 fs/udf/unicode.c   |    6 +++---
 8 files changed, 33 insertions(+), 32 deletions(-)

diff --git a/fs/udf/directory.c b/fs/udf/directory.c
index 2ffdb67..a4caf7a 100644
--- a/fs/udf/directory.c
+++ b/fs/udf/directory.c
@@ -201,7 +201,7 @@ struct short_ad *udf_get_fileshortad(uint8_t *ptr, int maxoffset, uint32_t *offs
 	struct short_ad *sa;
 
 	if ((!ptr) || (!offset)) {
-		printk(KERN_ERR "udf: udf_get_fileshortad() invalidparms\n");
+		pr_err("udf_get_fileshortad() invalidparms\n");
 		return NULL;
 	}
 
@@ -223,7 +223,7 @@ struct long_ad *udf_get_filelongad(uint8_t *ptr, int maxoffset, uint32_t *offset
 	struct long_ad *la;
 
 	if ((!ptr) || (!offset)) {
-		printk(KERN_ERR "udf: udf_get_filelongad() invalidparms\n");
+		pr_err("udf_get_filelongad() invalidparms\n");
 		return NULL;
 	}
 
diff --git a/fs/udf/inode.c b/fs/udf/inode.c
index 1d1358e..58665ce 100644
--- a/fs/udf/inode.c
+++ b/fs/udf/inode.c
@@ -83,7 +83,7 @@ void udf_evict_inode(struct inode *inode)
 	end_writeback(inode);
 	if (iinfo->i_alloc_type != ICBTAG_FLAG_AD_IN_ICB &&
 	    inode->i_size != iinfo->i_lenExtents) {
-		printk(KERN_WARNING "UDF-fs (%s): Inode %lu (mode %o) has "
+		pr_warn("(%s): Inode %lu (mode %o) has "
 			"inode size %llu different from extent length %llu. "
 			"Filesystem need not be standards compliant.\n",
 			inode->i_sb->s_id, inode->i_ino, inode->i_mode,
@@ -1169,7 +1169,7 @@ static void __udf_read_inode(struct inode *inode)
 	 */
 	bh = udf_read_ptagged(inode->i_sb, &iinfo->i_location, 0, &ident);
 	if (!bh) {
-		printk(KERN_ERR "udf: udf_read_inode(ino %ld) failed !bh\n",
+		pr_err("udf_read_inode(ino %ld) failed !bh\n",
 		       inode->i_ino);
 		make_bad_inode(inode);
 		return;
@@ -1177,7 +1177,7 @@ static void __udf_read_inode(struct inode *inode)
 
 	if (ident != TAG_IDENT_FE && ident != TAG_IDENT_EFE &&
 	    ident != TAG_IDENT_USE) {
-		printk(KERN_ERR "udf: udf_read_inode(ino %ld) "
+		pr_err("udf_read_inode(ino %ld) "
 				"failed ident=%d\n", inode->i_ino, ident);
 		brelse(bh);
 		make_bad_inode(inode);
@@ -1218,7 +1218,7 @@ static void __udf_read_inode(struct inode *inode)
 		}
 		brelse(ibh);
 	} else if (fe->icbTag.strategyType != cpu_to_le16(4)) {
-		printk(KERN_ERR "udf: unsupported strategy type: %d\n",
+		pr_err("unsupported strategy type: %d\n",
 		       le16_to_cpu(fe->icbTag.strategyType));
 		brelse(bh);
 		make_bad_inode(inode);
@@ -1413,7 +1413,7 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh)
 		udf_debug("METADATA BITMAP FILE-----\n");
 		break;
 	default:
-		printk(KERN_ERR "udf: udf_fill_inode(ino %ld) failed unknown "
+		pr_err("udf_fill_inode(ino %ld) failed unknown "
 				"file type=%d\n", inode->i_ino,
 				fe->icbTag.fileType);
 		make_bad_inode(inode);
@@ -1438,7 +1438,7 @@ static int udf_alloc_i_data(struct inode *inode, size_t size)
 	iinfo->i_ext.i_data = kmalloc(size, GFP_KERNEL);
 
 	if (!iinfo->i_ext.i_data) {
-		printk(KERN_ERR "udf:udf_alloc_i_data (ino %ld) "
+		pr_err("udf_alloc_i_data (ino %ld) "
 				"no free memory\n", inode->i_ino);
 		return -ENOMEM;
 	}
@@ -1689,7 +1689,7 @@ out:
 	if (do_sync) {
 		sync_dirty_buffer(bh);
 		if (buffer_write_io_error(bh)) {
-			printk(KERN_WARNING "IO error syncing udf inode "
+			pr_warn("IO error syncing udf inode "
 				"[%s:%08lx]\n", inode->i_sb->s_id,
 				inode->i_ino);
 			err = -EIO;
diff --git a/fs/udf/misc.c b/fs/udf/misc.c
index 9215700..4f0345e 100644
--- a/fs/udf/misc.c
+++ b/fs/udf/misc.c
@@ -204,6 +204,7 @@ struct buffer_head *udf_read_tagged(struct super_block *sb, uint32_t block,
 {
 	struct tag *tag_p;
 	struct buffer_head *bh = NULL;
+	u8 checksum;
 
 	/* Read the block */
 	if (block == 0xFFFFFFFF)
@@ -211,7 +212,7 @@ struct buffer_head *udf_read_tagged(struct super_block *sb, uint32_t block,
 
 	bh = udf_tread(sb, block);
 	if (!bh) {
-		udf_debug("block=%d, location=%d: read failed\n",
+		pr_err("block=%d, location=%d: read failed\n",
 			  block, location);
 		return NULL;
 	}
@@ -221,22 +222,24 @@ struct buffer_head *udf_read_tagged(struct super_block *sb, uint32_t block,
 	*ident = le16_to_cpu(tag_p->tagIdent);
 
 	if (location != le32_to_cpu(tag_p->tagLocation)) {
-		udf_debug("location mismatch block %u, tag %u != %u\n",
+		pr_err("location mismatch block %u, tag %u != %u\n",
 			  block, le32_to_cpu(tag_p->tagLocation), location);
 		goto error_out;
 	}
 
 	/* Verify the tag checksum */
-	if (udf_tag_checksum(tag_p) != tag_p->tagChecksum) {
-		printk(KERN_ERR "udf: tag checksum failed block %d\n", block);
+	checksum = udf_tag_checksum(tag_p);
+	if (checksum != tag_p->tagChecksum) {
+		pr_err("tag checksum failed block %d, checksum 0x%02x != 0x%02x\n",
+		block, checksum, tag_p->tagChecksum);
 		goto error_out;
 	}
 
 	/* Verify the tag version */
 	if (tag_p->descVersion != cpu_to_le16(0x0002U) &&
 	    tag_p->descVersion != cpu_to_le16(0x0003U)) {
-		udf_debug("tag version 0x%04x != 0x0002 || 0x0003 block %d\n",
-			  le16_to_cpu(tag_p->descVersion), block);
+		pr_err("tag version 0x%04x != 0x0002 || 0x0003 block %d\n",
+		le16_to_cpu(tag_p->descVersion), block);
 		goto error_out;
 	}
 
@@ -247,7 +250,7 @@ struct buffer_head *udf_read_tagged(struct super_block *sb, uint32_t block,
 					le16_to_cpu(tag_p->descCRCLength)))
 		return bh;
 
-	udf_debug("Crc failure block %d: crc = %d, crclen = %d\n", block,
+	pr_err("Crc failure block %d: crc = %d, crclen = %d\n", block,
 	    le16_to_cpu(tag_p->descCRC), le16_to_cpu(tag_p->descCRCLength));
 
 error_out:
diff --git a/fs/udf/super.c b/fs/udf/super.c
index 7b27b06..bbf6256 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -550,7 +550,7 @@ static int udf_parse_options(char *options, struct udf_options *uopt,
 			uopt->dmode = option & 0777;
 			break;
 		default:
-			printk(KERN_ERR "udf: bad mount option \"%s\" "
+			pr_err("bad mount option \"%s\" "
 			       "or missing value\n", p);
 			return 0;
 		}
diff --git a/fs/udf/truncate.c b/fs/udf/truncate.c
index 8424308..65c11cd 100644
--- a/fs/udf/truncate.c
+++ b/fs/udf/truncate.c
@@ -95,8 +95,7 @@ void udf_truncate_tail_extent(struct inode *inode)
 		lbcount += elen;
 		if (lbcount > inode->i_size) {
 			if (lbcount - inode->i_size >= inode->i_sb->s_blocksize)
-				printk(KERN_WARNING
-				       "udf_truncate_tail_extent(): Too long "
+				pr_warn("udf_truncate_tail_extent(): Too long "
 				       "extent after EOF in inode %u: i_size: "
 				       "%Ld lbcount: %Ld extent %u+%u\n",
 				       (unsigned)inode->i_ino,
@@ -109,7 +108,7 @@ void udf_truncate_tail_extent(struct inode *inode)
 			extent_trunc(inode, &epos, &eloc, etype, elen, nelen);
 			epos.offset += adsize;
 			if (udf_next_aext(inode, &epos, &eloc, &elen, 1) != -1)
-				printk(KERN_ERR "udf_truncate_tail_extent(): "
+				pr_err("udf_truncate_tail_extent(): "
 				       "Extent after EOF in inode %u.\n",
 				       (unsigned)inode->i_ino);
 			break;
diff --git a/fs/udf/udfdecl.h b/fs/udf/udfdecl.h
index dbd52d4b..f77c813 100644
--- a/fs/udf/udfdecl.h
+++ b/fs/udf/udfdecl.h
@@ -1,6 +1,8 @@
 #ifndef __UDF_DECL_H
 #define __UDF_DECL_H
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include "ecma_167.h"
 #include "osta_udf.h"
 
@@ -19,18 +21,15 @@
 #undef UDFFS_DEBUG
 
 #ifdef UDFFS_DEBUG
-#define udf_debug(f, a...) \
-do { \
-	printk(KERN_DEBUG "UDF-fs DEBUG %s:%d:%s: ", \
-		__FILE__, __LINE__, __func__); \
-	printk(f, ##a); \
-} while (0)
+#define udf_debug(fmt, ...)	\
+	pr_debug("DEBUG %s:%d:%s: " fmt,	\
+		__FILE__, __LINE__, __func__, ##__VA_ARGS__);
 #else
-#define udf_debug(f, a...) /**/
+#define udf_debug(fmt, ...) /**/
 #endif
 
 #define udf_info(f, a...) \
-	printk(KERN_INFO "UDF-fs INFO " f, ##a);
+	pr_info("INFO " f, ##a);
 
 
 #define udf_fixed_to_variable(x) ( ( ( (x) >> 5 ) * 39 ) + ( (x) & 0x0000001F ) )
diff --git a/fs/udf/udftime.c b/fs/udf/udftime.c
index b8c828c..927c931 100644
--- a/fs/udf/udftime.c
+++ b/fs/udf/udftime.c
@@ -34,9 +34,9 @@
  * http://www.boulder.nist.gov/timefreq/pubs/bulletin/leapsecond.htm
  */
 
+#include "udfdecl.h"
 #include <linux/types.h>
 #include <linux/kernel.h>
-#include "udfdecl.h"
 
 #define EPOCH_YEAR 1970
 
diff --git a/fs/udf/unicode.c b/fs/udf/unicode.c
index d03a90b..9455dc7 100644
--- a/fs/udf/unicode.c
+++ b/fs/udf/unicode.c
@@ -114,7 +114,7 @@ int udf_CS0toUTF8(struct ustr *utf_o, const struct ustr *ocu_i)
 	cmp_id = ocu_i->u_cmpID;
 	if (cmp_id != 8 && cmp_id != 16) {
 		memset(utf_o, 0, sizeof(struct ustr));
-		printk(KERN_ERR "udf: unknown compression code (%d) stri=%s\n",
+		pr_err("unknown compression code (%d) stri=%s\n",
 		       cmp_id, ocu_i->u_name);
 		return 0;
 	}
@@ -242,7 +242,7 @@ try_again:
 	if (utf_cnt) {
 error_out:
 		ocu[++u_len] = '?';
-		printk(KERN_DEBUG "udf: bad UTF-8 character\n");
+		pr_debug("bad UTF-8 character\n");
 	}
 
 	ocu[length - 1] = (uint8_t)u_len + 1;
@@ -267,7 +267,7 @@ static int udf_CS0toNLS(struct nls_table *nls, struct ustr *utf_o,
 	cmp_id = ocu_i->u_cmpID;
 	if (cmp_id != 8 && cmp_id != 16) {
 		memset(utf_o, 0, sizeof(struct ustr));
-		printk(KERN_ERR "udf: unknown compression code (%d) stri=%s\n",
+		pr_err("unknown compression code (%d) stri=%s\n",
 		       cmp_id, ocu_i->u_name);
 		return 0;
 	}
-- 
1.7.4.4


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* Re: [PATCH 1/2 v3] udf : enable error print in udf_read_tagged().
  2011-10-03 13:53 [PATCH 1/2 v3] udf : enable error print in udf_read_tagged() Namjae Jeon
@ 2011-10-05 22:08 ` Jan Kara
  2011-10-05 22:19   ` Joe Perches
  0 siblings, 1 reply; 36+ messages in thread
From: Jan Kara @ 2011-10-05 22:08 UTC (permalink / raw)
  To: Namjae Jeon; +Cc: jack, joe, linux-kernel

  Hello,

On Mon 03-10-11 22:53:57, Namjae Jeon wrote:
> While reading metadata, if a problem occurs, Print out only one of the
> five case.(It also does not show a checksum properly.) Because currently
> it have been disable by undef udf_debug.  If there is a problem with
> scratched disc or loader, the user needs to know which error happened.
> And I use pr_fmt instead of printk by joe's suggestion. I try to modify
> totally it to pr_fmt also.
  Thanks for the patch. I'm willing to take the patch since it's an
improvement but what would be even nicer is to have error reporting like in
ext3 / ext4. We would have functions udf_info, udf_warn, udf_err which
also print sb->s_id with each error so that user can better identify on
which filesystem error happened. So the format would be like:

UDF-fs error/warning/info (device %s): ...

Would you like to improve the patch like this?

								Honza

> 
> Signed-off-by: Namjae Jeon <linkinjeon@gmail.com>
> ---
>  fs/udf/directory.c |    4 ++--
>  fs/udf/inode.c     |   14 +++++++-------
>  fs/udf/misc.c      |   17 ++++++++++-------
>  fs/udf/super.c     |    2 +-
>  fs/udf/truncate.c  |    5 ++---
>  fs/udf/udfdecl.h   |   15 +++++++--------
>  fs/udf/udftime.c   |    2 +-
>  fs/udf/unicode.c   |    6 +++---
>  8 files changed, 33 insertions(+), 32 deletions(-)
> 
> diff --git a/fs/udf/directory.c b/fs/udf/directory.c
> index 2ffdb67..a4caf7a 100644
> --- a/fs/udf/directory.c
> +++ b/fs/udf/directory.c
> @@ -201,7 +201,7 @@ struct short_ad *udf_get_fileshortad(uint8_t *ptr, int maxoffset, uint32_t *offs
>  	struct short_ad *sa;
>  
>  	if ((!ptr) || (!offset)) {
> -		printk(KERN_ERR "udf: udf_get_fileshortad() invalidparms\n");
> +		pr_err("udf_get_fileshortad() invalidparms\n");
>  		return NULL;
>  	}
>  
> @@ -223,7 +223,7 @@ struct long_ad *udf_get_filelongad(uint8_t *ptr, int maxoffset, uint32_t *offset
>  	struct long_ad *la;
>  
>  	if ((!ptr) || (!offset)) {
> -		printk(KERN_ERR "udf: udf_get_filelongad() invalidparms\n");
> +		pr_err("udf_get_filelongad() invalidparms\n");
>  		return NULL;
>  	}
>  
> diff --git a/fs/udf/inode.c b/fs/udf/inode.c
> index 1d1358e..58665ce 100644
> --- a/fs/udf/inode.c
> +++ b/fs/udf/inode.c
> @@ -83,7 +83,7 @@ void udf_evict_inode(struct inode *inode)
>  	end_writeback(inode);
>  	if (iinfo->i_alloc_type != ICBTAG_FLAG_AD_IN_ICB &&
>  	    inode->i_size != iinfo->i_lenExtents) {
> -		printk(KERN_WARNING "UDF-fs (%s): Inode %lu (mode %o) has "
> +		pr_warn("(%s): Inode %lu (mode %o) has "
>  			"inode size %llu different from extent length %llu. "
>  			"Filesystem need not be standards compliant.\n",
>  			inode->i_sb->s_id, inode->i_ino, inode->i_mode,
> @@ -1169,7 +1169,7 @@ static void __udf_read_inode(struct inode *inode)
>  	 */
>  	bh = udf_read_ptagged(inode->i_sb, &iinfo->i_location, 0, &ident);
>  	if (!bh) {
> -		printk(KERN_ERR "udf: udf_read_inode(ino %ld) failed !bh\n",
> +		pr_err("udf_read_inode(ino %ld) failed !bh\n",
>  		       inode->i_ino);
>  		make_bad_inode(inode);
>  		return;
> @@ -1177,7 +1177,7 @@ static void __udf_read_inode(struct inode *inode)
>  
>  	if (ident != TAG_IDENT_FE && ident != TAG_IDENT_EFE &&
>  	    ident != TAG_IDENT_USE) {
> -		printk(KERN_ERR "udf: udf_read_inode(ino %ld) "
> +		pr_err("udf_read_inode(ino %ld) "
>  				"failed ident=%d\n", inode->i_ino, ident);
>  		brelse(bh);
>  		make_bad_inode(inode);
> @@ -1218,7 +1218,7 @@ static void __udf_read_inode(struct inode *inode)
>  		}
>  		brelse(ibh);
>  	} else if (fe->icbTag.strategyType != cpu_to_le16(4)) {
> -		printk(KERN_ERR "udf: unsupported strategy type: %d\n",
> +		pr_err("unsupported strategy type: %d\n",
>  		       le16_to_cpu(fe->icbTag.strategyType));
>  		brelse(bh);
>  		make_bad_inode(inode);
> @@ -1413,7 +1413,7 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh)
>  		udf_debug("METADATA BITMAP FILE-----\n");
>  		break;
>  	default:
> -		printk(KERN_ERR "udf: udf_fill_inode(ino %ld) failed unknown "
> +		pr_err("udf_fill_inode(ino %ld) failed unknown "
>  				"file type=%d\n", inode->i_ino,
>  				fe->icbTag.fileType);
>  		make_bad_inode(inode);
> @@ -1438,7 +1438,7 @@ static int udf_alloc_i_data(struct inode *inode, size_t size)
>  	iinfo->i_ext.i_data = kmalloc(size, GFP_KERNEL);
>  
>  	if (!iinfo->i_ext.i_data) {
> -		printk(KERN_ERR "udf:udf_alloc_i_data (ino %ld) "
> +		pr_err("udf_alloc_i_data (ino %ld) "
>  				"no free memory\n", inode->i_ino);
>  		return -ENOMEM;
>  	}
> @@ -1689,7 +1689,7 @@ out:
>  	if (do_sync) {
>  		sync_dirty_buffer(bh);
>  		if (buffer_write_io_error(bh)) {
> -			printk(KERN_WARNING "IO error syncing udf inode "
> +			pr_warn("IO error syncing udf inode "
>  				"[%s:%08lx]\n", inode->i_sb->s_id,
>  				inode->i_ino);
>  			err = -EIO;
> diff --git a/fs/udf/misc.c b/fs/udf/misc.c
> index 9215700..4f0345e 100644
> --- a/fs/udf/misc.c
> +++ b/fs/udf/misc.c
> @@ -204,6 +204,7 @@ struct buffer_head *udf_read_tagged(struct super_block *sb, uint32_t block,
>  {
>  	struct tag *tag_p;
>  	struct buffer_head *bh = NULL;
> +	u8 checksum;
>  
>  	/* Read the block */
>  	if (block == 0xFFFFFFFF)
> @@ -211,7 +212,7 @@ struct buffer_head *udf_read_tagged(struct super_block *sb, uint32_t block,
>  
>  	bh = udf_tread(sb, block);
>  	if (!bh) {
> -		udf_debug("block=%d, location=%d: read failed\n",
> +		pr_err("block=%d, location=%d: read failed\n",
>  			  block, location);
>  		return NULL;
>  	}
> @@ -221,22 +222,24 @@ struct buffer_head *udf_read_tagged(struct super_block *sb, uint32_t block,
>  	*ident = le16_to_cpu(tag_p->tagIdent);
>  
>  	if (location != le32_to_cpu(tag_p->tagLocation)) {
> -		udf_debug("location mismatch block %u, tag %u != %u\n",
> +		pr_err("location mismatch block %u, tag %u != %u\n",
>  			  block, le32_to_cpu(tag_p->tagLocation), location);
>  		goto error_out;
>  	}
>  
>  	/* Verify the tag checksum */
> -	if (udf_tag_checksum(tag_p) != tag_p->tagChecksum) {
> -		printk(KERN_ERR "udf: tag checksum failed block %d\n", block);
> +	checksum = udf_tag_checksum(tag_p);
> +	if (checksum != tag_p->tagChecksum) {
> +		pr_err("tag checksum failed block %d, checksum 0x%02x != 0x%02x\n",
> +		block, checksum, tag_p->tagChecksum);
>  		goto error_out;
>  	}
>  
>  	/* Verify the tag version */
>  	if (tag_p->descVersion != cpu_to_le16(0x0002U) &&
>  	    tag_p->descVersion != cpu_to_le16(0x0003U)) {
> -		udf_debug("tag version 0x%04x != 0x0002 || 0x0003 block %d\n",
> -			  le16_to_cpu(tag_p->descVersion), block);
> +		pr_err("tag version 0x%04x != 0x0002 || 0x0003 block %d\n",
> +		le16_to_cpu(tag_p->descVersion), block);
>  		goto error_out;
>  	}
>  
> @@ -247,7 +250,7 @@ struct buffer_head *udf_read_tagged(struct super_block *sb, uint32_t block,
>  					le16_to_cpu(tag_p->descCRCLength)))
>  		return bh;
>  
> -	udf_debug("Crc failure block %d: crc = %d, crclen = %d\n", block,
> +	pr_err("Crc failure block %d: crc = %d, crclen = %d\n", block,
>  	    le16_to_cpu(tag_p->descCRC), le16_to_cpu(tag_p->descCRCLength));
>  
>  error_out:
> diff --git a/fs/udf/super.c b/fs/udf/super.c
> index 7b27b06..bbf6256 100644
> --- a/fs/udf/super.c
> +++ b/fs/udf/super.c
> @@ -550,7 +550,7 @@ static int udf_parse_options(char *options, struct udf_options *uopt,
>  			uopt->dmode = option & 0777;
>  			break;
>  		default:
> -			printk(KERN_ERR "udf: bad mount option \"%s\" "
> +			pr_err("bad mount option \"%s\" "
>  			       "or missing value\n", p);
>  			return 0;
>  		}
> diff --git a/fs/udf/truncate.c b/fs/udf/truncate.c
> index 8424308..65c11cd 100644
> --- a/fs/udf/truncate.c
> +++ b/fs/udf/truncate.c
> @@ -95,8 +95,7 @@ void udf_truncate_tail_extent(struct inode *inode)
>  		lbcount += elen;
>  		if (lbcount > inode->i_size) {
>  			if (lbcount - inode->i_size >= inode->i_sb->s_blocksize)
> -				printk(KERN_WARNING
> -				       "udf_truncate_tail_extent(): Too long "
> +				pr_warn("udf_truncate_tail_extent(): Too long "
>  				       "extent after EOF in inode %u: i_size: "
>  				       "%Ld lbcount: %Ld extent %u+%u\n",
>  				       (unsigned)inode->i_ino,
> @@ -109,7 +108,7 @@ void udf_truncate_tail_extent(struct inode *inode)
>  			extent_trunc(inode, &epos, &eloc, etype, elen, nelen);
>  			epos.offset += adsize;
>  			if (udf_next_aext(inode, &epos, &eloc, &elen, 1) != -1)
> -				printk(KERN_ERR "udf_truncate_tail_extent(): "
> +				pr_err("udf_truncate_tail_extent(): "
>  				       "Extent after EOF in inode %u.\n",
>  				       (unsigned)inode->i_ino);
>  			break;
> diff --git a/fs/udf/udfdecl.h b/fs/udf/udfdecl.h
> index dbd52d4b..f77c813 100644
> --- a/fs/udf/udfdecl.h
> +++ b/fs/udf/udfdecl.h
> @@ -1,6 +1,8 @@
>  #ifndef __UDF_DECL_H
>  #define __UDF_DECL_H
>  
> +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> +
>  #include "ecma_167.h"
>  #include "osta_udf.h"
>  
> @@ -19,18 +21,15 @@
>  #undef UDFFS_DEBUG
>  
>  #ifdef UDFFS_DEBUG
> -#define udf_debug(f, a...) \
> -do { \
> -	printk(KERN_DEBUG "UDF-fs DEBUG %s:%d:%s: ", \
> -		__FILE__, __LINE__, __func__); \
> -	printk(f, ##a); \
> -} while (0)
> +#define udf_debug(fmt, ...)	\
> +	pr_debug("DEBUG %s:%d:%s: " fmt,	\
> +		__FILE__, __LINE__, __func__, ##__VA_ARGS__);
>  #else
> -#define udf_debug(f, a...) /**/
> +#define udf_debug(fmt, ...) /**/
>  #endif
>  
>  #define udf_info(f, a...) \
> -	printk(KERN_INFO "UDF-fs INFO " f, ##a);
> +	pr_info("INFO " f, ##a);
>  
>  
>  #define udf_fixed_to_variable(x) ( ( ( (x) >> 5 ) * 39 ) + ( (x) & 0x0000001F ) )
> diff --git a/fs/udf/udftime.c b/fs/udf/udftime.c
> index b8c828c..927c931 100644
> --- a/fs/udf/udftime.c
> +++ b/fs/udf/udftime.c
> @@ -34,9 +34,9 @@
>   * http://www.boulder.nist.gov/timefreq/pubs/bulletin/leapsecond.htm
>   */
>  
> +#include "udfdecl.h"
>  #include <linux/types.h>
>  #include <linux/kernel.h>
> -#include "udfdecl.h"
>  
>  #define EPOCH_YEAR 1970
>  
> diff --git a/fs/udf/unicode.c b/fs/udf/unicode.c
> index d03a90b..9455dc7 100644
> --- a/fs/udf/unicode.c
> +++ b/fs/udf/unicode.c
> @@ -114,7 +114,7 @@ int udf_CS0toUTF8(struct ustr *utf_o, const struct ustr *ocu_i)
>  	cmp_id = ocu_i->u_cmpID;
>  	if (cmp_id != 8 && cmp_id != 16) {
>  		memset(utf_o, 0, sizeof(struct ustr));
> -		printk(KERN_ERR "udf: unknown compression code (%d) stri=%s\n",
> +		pr_err("unknown compression code (%d) stri=%s\n",
>  		       cmp_id, ocu_i->u_name);
>  		return 0;
>  	}
> @@ -242,7 +242,7 @@ try_again:
>  	if (utf_cnt) {
>  error_out:
>  		ocu[++u_len] = '?';
> -		printk(KERN_DEBUG "udf: bad UTF-8 character\n");
> +		pr_debug("bad UTF-8 character\n");
>  	}
>  
>  	ocu[length - 1] = (uint8_t)u_len + 1;
> @@ -267,7 +267,7 @@ static int udf_CS0toNLS(struct nls_table *nls, struct ustr *utf_o,
>  	cmp_id = ocu_i->u_cmpID;
>  	if (cmp_id != 8 && cmp_id != 16) {
>  		memset(utf_o, 0, sizeof(struct ustr));
> -		printk(KERN_ERR "udf: unknown compression code (%d) stri=%s\n",
> +		pr_err("unknown compression code (%d) stri=%s\n",
>  		       cmp_id, ocu_i->u_name);
>  		return 0;
>  	}
> -- 
> 1.7.4.4
> 
-- 
Jan Kara <jack@suse.cz>
SUSE Labs, CR

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 1/2 v3] udf : enable error print in udf_read_tagged().
  2011-10-05 22:08 ` Jan Kara
@ 2011-10-05 22:19   ` Joe Perches
  2011-10-06 21:41     ` Jan Kara
  0 siblings, 1 reply; 36+ messages in thread
From: Joe Perches @ 2011-10-05 22:19 UTC (permalink / raw)
  To: Jan Kara; +Cc: Namjae Jeon, linux-kernel

On Thu, 2011-10-06 at 00:08 +0200, Jan Kara wrote:
> Hello,
> 
> On Mon 03-10-11 22:53:57, Namjae Jeon wrote:
> > While reading metadata, if a problem occurs, Print out only one of the
> > five case.(It also does not show a checksum properly.) Because currently
> > it have been disable by undef udf_debug.  If there is a problem with
> > scratched disc or loader, the user needs to know which error happened.
> > And I use pr_fmt instead of printk by joe's suggestion. I try to modify
> > totally it to pr_fmt also.

>   Thanks for the patch. I'm willing to take the patch since it's an
> improvement but what would be even nicer is to have error reporting like in
> ext3 / ext4. We would have functions udf_info, udf_warn, udf_err which
> also print sb->s_id with each error so that user can better identify on
> which filesystem error happened.

Modifying the follow-on patch I sent would be pretty trivial.



^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 1/2 v3] udf : enable error print in udf_read_tagged().
  2011-10-05 22:19   ` Joe Perches
@ 2011-10-06 21:41     ` Jan Kara
  2011-10-09  3:16       ` NamJae Jeon
  0 siblings, 1 reply; 36+ messages in thread
From: Jan Kara @ 2011-10-06 21:41 UTC (permalink / raw)
  To: Joe Perches; +Cc: Jan Kara, Namjae Jeon, linux-kernel

On Wed 05-10-11 15:19:58, Joe Perches wrote:
> On Thu, 2011-10-06 at 00:08 +0200, Jan Kara wrote:
> > Hello,
> > 
> > On Mon 03-10-11 22:53:57, Namjae Jeon wrote:
> > > While reading metadata, if a problem occurs, Print out only one of the
> > > five case.(It also does not show a checksum properly.) Because currently
> > > it have been disable by undef udf_debug.  If there is a problem with
> > > scratched disc or loader, the user needs to know which error happened.
> > > And I use pr_fmt instead of printk by joe's suggestion. I try to modify
> > > totally it to pr_fmt also.
> 
> >   Thanks for the patch. I'm willing to take the patch since it's an
> > improvement but what would be even nicer is to have error reporting like in
> > ext3 / ext4. We would have functions udf_info, udf_warn, udf_err which
> > also print sb->s_id with each error so that user can better identify on
> > which filesystem error happened.
> 
> Modifying the follow-on patch I sent would be pretty trivial.
  Sure, I can do that but if Namjae is willing to do it, I'd have less work
:).

								Honza
-- 
Jan Kara <jack@suse.cz>
SUSE Labs, CR

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 1/2 v3] udf : enable error print in udf_read_tagged().
  2011-10-06 21:41     ` Jan Kara
@ 2011-10-09  3:16       ` NamJae Jeon
  2011-10-09  3:29         ` Joe Perches
  0 siblings, 1 reply; 36+ messages in thread
From: NamJae Jeon @ 2011-10-09  3:16 UTC (permalink / raw)
  To: Jan Kara; +Cc: Joe Perches, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1536 bytes --]

2011/10/7 Jan Kara <jack@suse.cz>:
> On Wed 05-10-11 15:19:58, Joe Perches wrote:
>> On Thu, 2011-10-06 at 00:08 +0200, Jan Kara wrote:
>> > Hello,
>> >
>> > On Mon 03-10-11 22:53:57, Namjae Jeon wrote:
>> > > While reading metadata, if a problem occurs, Print out only one of the
>> > > five case.(It also does not show a checksum properly.) Because currently
>> > > it have been disable by undef udf_debug.  If there is a problem with
>> > > scratched disc or loader, the user needs to know which error happened.
>> > > And I use pr_fmt instead of printk by joe's suggestion. I try to modify
>> > > totally it to pr_fmt also.
>>
>> >   Thanks for the patch. I'm willing to take the patch since it's an
>> > improvement but what would be even nicer is to have error reporting like in
>> > ext3 / ext4. We would have functions udf_info, udf_warn, udf_err which
>> > also print sb->s_id with each error so that user can better identify on
>> > which filesystem error happened.
>>
>> Modifying the follow-on patch I sent would be pretty trivial.
>  Sure, I can do that but if Namjae is willing to do it, I'd have less work
> :).
Hi. Jan.

Currently I can not send a patch using git send-email.
maybe it is the problem related with git or patch size...
So I attach a patch. Is it okay? or I resend a patch again..
plz review attach patch.
Thanks.
>
>                                                                Honza
> --
> Jan Kara <jack@suse.cz>
> SUSE Labs, CR
>

[-- Attachment #2: 0001-udf-enable-error-print-in-udf_read_tagged.patch --]
[-- Type: application/octet-stream, Size: 45479 bytes --]

From 1f7d2991e18050d8230aa7b563d61216918bd865 Mon Sep 17 00:00:00 2001
From: Namjae Jeon <linkinjeon@gmail.com>
Date: Sat, 8 Oct 2011 23:32:03 +0900
Subject: [PATCH v4] udf : enable error print in udf_read_tagged().

While reading metadata, if a problem occurs, Print out only one of the five case.(It also does not show a checksum properly.)
Because currently it have been disable by undef udf_debug.
If there is a problem with scratched disc or loader, the user needs to know which error happened.
And I use pr_fmt instead of printk by joe's suggestion. I try to modify totally it to pr_fmt also.

Signed-off-by: Namjae Jeon <linkinjeon@gmail.com>
---
 fs/udf/balloc.c    |   15 ++--
 fs/udf/directory.c |   24 +++---
 fs/udf/inode.c     |   44 +++++-----
 fs/udf/lowlevel.c  |    2 +-
 fs/udf/misc.c      |   27 ++++--
 fs/udf/namei.c     |    8 +-
 fs/udf/partition.c |    8 +-
 fs/udf/super.c     |  237 ++++++++++++++++++++++++++++------------------------
 fs/udf/truncate.c  |   25 +++---
 fs/udf/udfdecl.h   |   40 +++++----
 fs/udf/udftime.c   |    2 +-
 fs/udf/unicode.c   |   36 ++++----
 12 files changed, 255 insertions(+), 213 deletions(-)

diff --git a/fs/udf/balloc.c b/fs/udf/balloc.c
index 95518a9..e9443ba 100644
--- a/fs/udf/balloc.c
+++ b/fs/udf/balloc.c
@@ -59,8 +59,8 @@ static int __load_block_bitmap(struct super_block *sb,
 	int nr_groups = bitmap->s_nr_groups;
 
 	if (block_group >= nr_groups) {
-		udf_debug("block_group (%d) > nr_groups (%d)\n", block_group,
-			  nr_groups);
+		udf_debug("block_group (%d) > nr_groups (%d)\n",
+			block_group, nr_groups);
 	}
 
 	if (bitmap->s_block_bitmap[block_group]) {
@@ -126,8 +126,9 @@ static void udf_bitmap_free_blocks(struct super_block *sb,
 	if (bloc->logicalBlockNum + count < count ||
 	    (bloc->logicalBlockNum + count) > partmap->s_partition_len) {
 		udf_debug("%d < %d || %d + %d > %d\n",
-			  bloc->logicalBlockNum, 0, bloc->logicalBlockNum,
-			  count, partmap->s_partition_len);
+			bloc->logicalBlockNum, 0,
+			bloc->logicalBlockNum, count,
+			partmap->s_partition_len);
 		goto error_return;
 	}
 
@@ -369,8 +370,8 @@ static void udf_table_free_blocks(struct super_block *sb,
 	if (bloc->logicalBlockNum + count < count ||
 	    (bloc->logicalBlockNum + count) > partmap->s_partition_len) {
 		udf_debug("%d < %d || %d + %d > %d\n",
-			  bloc->logicalBlockNum, 0, bloc->logicalBlockNum, count,
-			  partmap->s_partition_len);
+			bloc->logicalBlockNum, 0, bloc->logicalBlockNum, count,
+			partmap->s_partition_len);
 		goto error_return;
 	}
 
@@ -611,7 +612,7 @@ static int udf_table_prealloc_blocks(struct super_block *sb,
 	while (first_block != eloc.logicalBlockNum &&
 	       (etype = udf_next_aext(table, &epos, &eloc, &elen, 1)) != -1) {
 		udf_debug("eloc=%d, elen=%d, first_block=%d\n",
-			  eloc.logicalBlockNum, elen, first_block);
+			eloc.logicalBlockNum, elen, first_block);
 		; /* empty loop body */
 	}
 
diff --git a/fs/udf/directory.c b/fs/udf/directory.c
index 2ffdb67..5aa0059 100644
--- a/fs/udf/directory.c
+++ b/fs/udf/directory.c
@@ -162,8 +162,8 @@ struct fileIdentDesc *udf_get_fileident(void *buffer, int bufsize, int *offset)
 	int padlen;
 
 	if ((!buffer) || (!offset)) {
-		udf_debug("invalidparms\n, buffer=%p, offset=%p\n", buffer,
-			  offset);
+		udf_debug("invalidparms, buffer=%p, offset=%p\n",
+			buffer, offset);
 		return NULL;
 	}
 
@@ -174,10 +174,9 @@ struct fileIdentDesc *udf_get_fileident(void *buffer, int bufsize, int *offset)
 	fi = (struct fileIdentDesc *)ptr;
 	if (fi->descTag.tagIdent != cpu_to_le16(TAG_IDENT_FID)) {
 		udf_debug("0x%x != TAG_IDENT_FID\n",
-			  le16_to_cpu(fi->descTag.tagIdent));
-		udf_debug("offset: %u sizeof: %lu bufsize: %u\n",
-			  *offset, (unsigned long)sizeof(struct fileIdentDesc),
-			  bufsize);
+			le16_to_cpu(fi->descTag.tagIdent));
+		udf_debug("offset: %u sizeof: %zu bufsize: %u\n",
+			*offset, sizeof(struct fileIdentDesc), bufsize);
 		return NULL;
 	}
 	if ((*offset + sizeof(struct fileIdentDesc)) > bufsize)
@@ -195,13 +194,14 @@ struct fileIdentDesc *udf_get_fileident(void *buffer, int bufsize, int *offset)
 	return fi;
 }
 
-struct short_ad *udf_get_fileshortad(uint8_t *ptr, int maxoffset, uint32_t *offset,
-			      int inc)
+struct short_ad *udf_get_fileshortad(struct inode *inode, uint8_t *ptr,
+				int maxoffset, uint32_t *offset, int inc)
 {
 	struct short_ad *sa;
 
 	if ((!ptr) || (!offset)) {
-		printk(KERN_ERR "udf: udf_get_fileshortad() invalidparms\n");
+		udf_err(inode->i_sb, __func__, "udf_get_fileshortad() "
+			"invalidparms\n");
 		return NULL;
 	}
 
@@ -218,12 +218,14 @@ struct short_ad *udf_get_fileshortad(uint8_t *ptr, int maxoffset, uint32_t *offs
 	return sa;
 }
 
-struct long_ad *udf_get_filelongad(uint8_t *ptr, int maxoffset, uint32_t *offset, int inc)
+struct long_ad *udf_get_filelongad(struct inode *inode, uint8_t *ptr,
+				int maxoffset, uint32_t *offset, int inc)
 {
 	struct long_ad *la;
 
 	if ((!ptr) || (!offset)) {
-		printk(KERN_ERR "udf: udf_get_filelongad() invalidparms\n");
+		udf_err(inode->i_sb, __func__, "udf_get_filelongad() "
+			"invalidparms\n");
 		return NULL;
 	}
 
diff --git a/fs/udf/inode.c b/fs/udf/inode.c
index 1d1358e..ddf3002 100644
--- a/fs/udf/inode.c
+++ b/fs/udf/inode.c
@@ -83,10 +83,10 @@ void udf_evict_inode(struct inode *inode)
 	end_writeback(inode);
 	if (iinfo->i_alloc_type != ICBTAG_FLAG_AD_IN_ICB &&
 	    inode->i_size != iinfo->i_lenExtents) {
-		printk(KERN_WARNING "UDF-fs (%s): Inode %lu (mode %o) has "
+		udf_warn(inode->i_sb, __func__, "Inode %lu (mode %o) has "
 			"inode size %llu different from extent length %llu. "
 			"Filesystem need not be standards compliant.\n",
-			inode->i_sb->s_id, inode->i_ino, inode->i_mode,
+			inode->i_ino, inode->i_mode,
 			(unsigned long long)inode->i_size,
 			(unsigned long long)iinfo->i_lenExtents);
 	}
@@ -1169,16 +1169,18 @@ static void __udf_read_inode(struct inode *inode)
 	 */
 	bh = udf_read_ptagged(inode->i_sb, &iinfo->i_location, 0, &ident);
 	if (!bh) {
-		printk(KERN_ERR "udf: udf_read_inode(ino %ld) failed !bh\n",
-		       inode->i_ino);
+		udf_err(inode->i_sb, __func__, "udf_read_inode(ino %ld) "
+			"failed !bh\n",
+			inode->i_ino);
 		make_bad_inode(inode);
 		return;
 	}
 
 	if (ident != TAG_IDENT_FE && ident != TAG_IDENT_EFE &&
 	    ident != TAG_IDENT_USE) {
-		printk(KERN_ERR "udf: udf_read_inode(ino %ld) "
-				"failed ident=%d\n", inode->i_ino, ident);
+		udf_err(inode->i_sb, __func__, "udf_read_inode(ino %ld) "
+			"failed ident=%d\n",
+			inode->i_ino, ident);
 		brelse(bh);
 		make_bad_inode(inode);
 		return;
@@ -1218,8 +1220,9 @@ static void __udf_read_inode(struct inode *inode)
 		}
 		brelse(ibh);
 	} else if (fe->icbTag.strategyType != cpu_to_le16(4)) {
-		printk(KERN_ERR "udf: unsupported strategy type: %d\n",
-		       le16_to_cpu(fe->icbTag.strategyType));
+		udf_err(inode->i_sb, __func__, "unsupported strategy "
+			"type: %d\n",
+			le16_to_cpu(fe->icbTag.strategyType));
 		brelse(bh);
 		make_bad_inode(inode);
 		return;
@@ -1413,9 +1416,9 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh)
 		udf_debug("METADATA BITMAP FILE-----\n");
 		break;
 	default:
-		printk(KERN_ERR "udf: udf_fill_inode(ino %ld) failed unknown "
-				"file type=%d\n", inode->i_ino,
-				fe->icbTag.fileType);
+		udf_err(inode->i_sb, __func__, "udf_fill_inode(ino %ld) "
+			"failed unknown file type=%d\n",
+			inode->i_ino, fe->icbTag.fileType);
 		make_bad_inode(inode);
 		return;
 	}
@@ -1438,8 +1441,9 @@ static int udf_alloc_i_data(struct inode *inode, size_t size)
 	iinfo->i_ext.i_data = kmalloc(size, GFP_KERNEL);
 
 	if (!iinfo->i_ext.i_data) {
-		printk(KERN_ERR "udf:udf_alloc_i_data (ino %ld) "
-				"no free memory\n", inode->i_ino);
+		udf_err(inode->i_sb, __func__, "udf_alloc_i_data (ino %ld) "
+			"no free memory\n",
+			inode->i_ino);
 		return -ENOMEM;
 	}
 
@@ -1689,9 +1693,9 @@ out:
 	if (do_sync) {
 		sync_dirty_buffer(bh);
 		if (buffer_write_io_error(bh)) {
-			printk(KERN_WARNING "IO error syncing udf inode "
-				"[%s:%08lx]\n", inode->i_sb->s_id,
-				inode->i_ino);
+			udf_warn(inode->i_sb, __func__, "IO error syncing udf "
+				"inode [%s:%08lx]\n",
+				inode->i_sb->s_id, inode->i_ino);
 			err = -EIO;
 		}
 	}
@@ -1720,7 +1724,7 @@ struct inode *udf_iget(struct super_block *sb, struct kernel_lb_addr *ino)
 	if (ino->logicalBlockNum >= UDF_SB(sb)->
 			s_partmaps[ino->partitionReferenceNum].s_partition_len) {
 		udf_debug("block=%d, partition=%d out of range\n",
-			  ino->logicalBlockNum, ino->partitionReferenceNum);
+			ino->logicalBlockNum, ino->partitionReferenceNum);
 		make_bad_inode(inode);
 		goto out_iput;
 	}
@@ -1964,7 +1968,7 @@ int8_t udf_current_aext(struct inode *inode, struct extent_position *epos,
 
 	switch (iinfo->i_alloc_type) {
 	case ICBTAG_FLAG_AD_SHORT:
-		sad = udf_get_fileshortad(ptr, alen, &epos->offset, inc);
+		sad = udf_get_fileshortad(inode, ptr, alen, &epos->offset, inc);
 		if (!sad)
 			return -1;
 		etype = le32_to_cpu(sad->extLength) >> 30;
@@ -1974,7 +1978,7 @@ int8_t udf_current_aext(struct inode *inode, struct extent_position *epos,
 		*elen = le32_to_cpu(sad->extLength) & UDF_EXTENT_LENGTH_MASK;
 		break;
 	case ICBTAG_FLAG_AD_LONG:
-		lad = udf_get_filelongad(ptr, alen, &epos->offset, inc);
+		lad = udf_get_filelongad(inode, ptr, alen, &epos->offset, inc);
 		if (!lad)
 			return -1;
 		etype = le32_to_cpu(lad->extLength) >> 30;
@@ -1983,7 +1987,7 @@ int8_t udf_current_aext(struct inode *inode, struct extent_position *epos,
 		break;
 	default:
 		udf_debug("alloc_type = %d unsupported\n",
-				iinfo->i_alloc_type);
+			iinfo->i_alloc_type);
 		return -1;
 	}
 
diff --git a/fs/udf/lowlevel.c b/fs/udf/lowlevel.c
index 43e24a3..df102a9 100644
--- a/fs/udf/lowlevel.c
+++ b/fs/udf/lowlevel.c
@@ -38,7 +38,7 @@ unsigned int udf_get_last_session(struct super_block *sb)
 
 	if (i == 0) {
 		udf_debug("XA disk: %s, vol_desc_start=%d\n",
-			  (ms_info.xa_flag ? "yes" : "no"), ms_info.addr.lba);
+			(ms_info.xa_flag ? "yes" : "no"), ms_info.addr.lba);
 		if (ms_info.xa_flag) /* necessary for a valid ms_info.addr */
 			vol_desc_start = ms_info.addr.lba;
 	} else {
diff --git a/fs/udf/misc.c b/fs/udf/misc.c
index 9215700..c713eac 100644
--- a/fs/udf/misc.c
+++ b/fs/udf/misc.c
@@ -204,6 +204,7 @@ struct buffer_head *udf_read_tagged(struct super_block *sb, uint32_t block,
 {
 	struct tag *tag_p;
 	struct buffer_head *bh = NULL;
+	u8 checksum;
 
 	/* Read the block */
 	if (block == 0xFFFFFFFF)
@@ -211,8 +212,8 @@ struct buffer_head *udf_read_tagged(struct super_block *sb, uint32_t block,
 
 	bh = udf_tread(sb, block);
 	if (!bh) {
-		udf_debug("block=%d, location=%d: read failed\n",
-			  block, location);
+		udf_err(sb, __func__, "block=%d, location=%d: read failed\n",
+			block, location);
 		return NULL;
 	}
 
@@ -221,22 +222,27 @@ struct buffer_head *udf_read_tagged(struct super_block *sb, uint32_t block,
 	*ident = le16_to_cpu(tag_p->tagIdent);
 
 	if (location != le32_to_cpu(tag_p->tagLocation)) {
-		udf_debug("location mismatch block %u, tag %u != %u\n",
-			  block, le32_to_cpu(tag_p->tagLocation), location);
+		udf_err(sb, __func__, "location mismatch block %u, "
+			"tag %u != %u\n",
+			block, le32_to_cpu(tag_p->tagLocation), location);
 		goto error_out;
 	}
 
 	/* Verify the tag checksum */
-	if (udf_tag_checksum(tag_p) != tag_p->tagChecksum) {
-		printk(KERN_ERR "udf: tag checksum failed block %d\n", block);
+	checksum = udf_tag_checksum(tag_p);
+	if (checksum != tag_p->tagChecksum) {
+		udf_err(sb, __func__, "tag checksum failed block %d, "
+		"checksum 0x%02x != 0x%02x\n",
+		block, checksum, tag_p->tagChecksum);
 		goto error_out;
 	}
 
 	/* Verify the tag version */
 	if (tag_p->descVersion != cpu_to_le16(0x0002U) &&
 	    tag_p->descVersion != cpu_to_le16(0x0003U)) {
-		udf_debug("tag version 0x%04x != 0x0002 || 0x0003 block %d\n",
-			  le16_to_cpu(tag_p->descVersion), block);
+		udf_err(sb, __func__, "tag version 0x%04x != 0x0002 || "
+			"0x0003 block %d\n",
+			le16_to_cpu(tag_p->descVersion), block);
 		goto error_out;
 	}
 
@@ -247,8 +253,9 @@ struct buffer_head *udf_read_tagged(struct super_block *sb, uint32_t block,
 					le16_to_cpu(tag_p->descCRCLength)))
 		return bh;
 
-	udf_debug("Crc failure block %d: crc = %d, crclen = %d\n", block,
-	    le16_to_cpu(tag_p->descCRC), le16_to_cpu(tag_p->descCRCLength));
+	udf_err(sb, __func__, "Crc failure block %d: crc = %d, crclen = %d\n",
+		block, le16_to_cpu(tag_p->descCRC),
+		le16_to_cpu(tag_p->descCRCLength));
 
 error_out:
 	brelse(bh);
diff --git a/fs/udf/namei.c b/fs/udf/namei.c
index f1dce84..53ea8d1 100644
--- a/fs/udf/namei.c
+++ b/fs/udf/namei.c
@@ -799,9 +799,9 @@ static int udf_rmdir(struct inode *dir, struct dentry *dentry)
 	if (retval)
 		goto end_rmdir;
 	if (inode->i_nlink != 2)
-		udf_warning(inode->i_sb, "udf_rmdir",
-			    "empty directory has nlink != 2 (%d)",
-			    inode->i_nlink);
+		udf_warn(inode->i_sb, __func__, "udf_rmdir"
+			"empty directory has nlink != 2 (%d)\n",
+			inode->i_nlink);
 	clear_nlink(inode);
 	inode->i_size = 0;
 	inode_dec_link_count(dir);
@@ -839,7 +839,7 @@ static int udf_unlink(struct inode *dir, struct dentry *dentry)
 
 	if (!inode->i_nlink) {
 		udf_debug("Deleting nonexistent file (%lu), %d\n",
-			  inode->i_ino, inode->i_nlink);
+			inode->i_ino, inode->i_nlink);
 		inode->i_nlink = 1;
 	}
 	retval = udf_delete_entry(dir, fi, &fibh, &cfi);
diff --git a/fs/udf/partition.c b/fs/udf/partition.c
index a71090e..95d6127 100644
--- a/fs/udf/partition.c
+++ b/fs/udf/partition.c
@@ -34,7 +34,8 @@ uint32_t udf_get_pblock(struct super_block *sb, uint32_t block,
 	struct udf_part_map *map;
 	if (partition >= sbi->s_partitions) {
 		udf_debug("block=%d, partition=%d, offset=%d: "
-			  "invalid partition\n", block, partition, offset);
+			"invalid partition\n",
+			block, partition, offset);
 		return 0xFFFFFFFF;
 	}
 	map = &sbi->s_partmaps[partition];
@@ -61,7 +62,8 @@ uint32_t udf_get_pblock_virt15(struct super_block *sb, uint32_t block,
 
 	if (block > vdata->s_num_entries) {
 		udf_debug("Trying to access block beyond end of VAT "
-			  "(%d max %d)\n", block, vdata->s_num_entries);
+			"(%d max %d)\n",
+			block, vdata->s_num_entries);
 		return 0xFFFFFFFF;
 	}
 
@@ -322,7 +324,7 @@ uint32_t udf_get_pblock_meta25(struct super_block *sb, uint32_t block,
 	BUG_ON(!inode);
 	retblk = udf_try_read_meta(inode, block, partition, offset);
 	if (retblk == 0xFFFFFFFF) {
-		udf_warning(sb, __func__, "error reading from METADATA, "
+		udf_warn(sb, __func__, "error reading from METADATA, "
 			"trying to read from MIRROR");
 		inode = mdata->s_mirror_fe;
 		if (!inode)
diff --git a/fs/udf/super.c b/fs/udf/super.c
index 7b27b06..eafb06b 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -75,8 +75,6 @@
 
 #define UDF_DEFAULT_BLOCKSIZE 2048
 
-static char error_buf[1024];
-
 /* These are the "meat" - everything else is stuffing */
 static int udf_fill_super(struct super_block *, void *, int);
 static void udf_put_super(struct super_block *);
@@ -92,8 +90,6 @@ static void udf_close_lvid(struct super_block *);
 static unsigned int udf_count_free(struct super_block *);
 static int udf_statfs(struct dentry *, struct kstatfs *);
 static int udf_show_options(struct seq_file *, struct vfsmount *);
-static void udf_error(struct super_block *sb, const char *function,
-		      const char *fmt, ...);
 
 struct logicalVolIntegrityDescImpUse *udf_sb_lvidiu(struct udf_sb_info *sbi)
 {
@@ -244,9 +240,9 @@ static int udf_sb_alloc_partition_maps(struct super_block *sb, u32 count)
 	sbi->s_partmaps = kcalloc(count, sizeof(struct udf_part_map),
 				  GFP_KERNEL);
 	if (!sbi->s_partmaps) {
-		udf_error(sb, __func__,
-			  "Unable to allocate space for %d partition maps",
-			  count);
+		udf_err(sb, __func__, 
+			"Unable to allocate space for %d partition maps",
+			count);
 		sbi->s_partitions = 0;
 		return -ENOMEM;
 	}
@@ -405,8 +401,8 @@ static const match_table_t tokens = {
 	{Opt_err,	NULL}
 };
 
-static int udf_parse_options(char *options, struct udf_options *uopt,
-			     bool remount)
+static int udf_parse_options(struct super_block *sb, char *options,
+				struct udf_options *uopt, bool remount)
 {
 	char *p;
 	int option;
@@ -550,8 +546,8 @@ static int udf_parse_options(char *options, struct udf_options *uopt,
 			uopt->dmode = option & 0777;
 			break;
 		default:
-			printk(KERN_ERR "udf: bad mount option \"%s\" "
-			       "or missing value\n", p);
+			udf_err(sb, __func__, "bad mount option \"%s\" "
+				"or missing value\n", p);
 			return 0;
 		}
 	}
@@ -571,7 +567,7 @@ static int udf_remount_fs(struct super_block *sb, int *flags, char *options)
 	uopt.fmode = sbi->s_fmode;
 	uopt.dmode = sbi->s_dmode;
 
-	if (!udf_parse_options(options, &uopt, true))
+	if (!udf_parse_options(sb, options, &uopt, true))
 		return -EINVAL;
 
 	write_lock(&sbi->s_cred_lock);
@@ -622,8 +618,8 @@ static loff_t udf_check_vsd(struct super_block *sb)
 	sector += (sbi->s_session << sb->s_blocksize_bits);
 
 	udf_debug("Starting at sector %u (%ld byte sectors)\n",
-		  (unsigned int)(sector >> sb->s_blocksize_bits),
-		  sb->s_blocksize);
+		(unsigned int)(sector >> sb->s_blocksize_bits),
+		sb->s_blocksize);
 	/* Process the sequence (if applicable) */
 	for (; !nsr02 && !nsr03; sector += sectorsize) {
 		/* Read a block */
@@ -770,8 +766,8 @@ static int udf_find_fileset(struct super_block *sb,
 	if ((fileset->logicalBlockNum != 0xFFFFFFFF ||
 	     fileset->partitionReferenceNum != 0xFFFF) && bh) {
 		udf_debug("Fileset at block=%d, partition=%d\n",
-			  fileset->logicalBlockNum,
-			  fileset->partitionReferenceNum);
+			fileset->logicalBlockNum,
+			fileset->partitionReferenceNum);
 
 		sbi->s_partition = fileset->partitionReferenceNum;
 		udf_load_fileset(sb, bh, root);
@@ -809,23 +805,22 @@ static int udf_load_pvoldesc(struct super_block *sb, sector_t block)
 			      pvoldesc->recordingDateAndTime)) {
 #ifdef UDFFS_DEBUG
 		struct timestamp *ts = &pvoldesc->recordingDateAndTime;
-		udf_debug("recording time %04u/%02u/%02u"
-			  " %02u:%02u (%x)\n",
-			  le16_to_cpu(ts->year), ts->month, ts->day, ts->hour,
-			  ts->minute, le16_to_cpu(ts->typeAndTimezone));
+		udf_debug("recording time %04u/%02u/%02u %02u:%02u (%x)\n",
+			le16_to_cpu(ts->year), ts->month, ts->day, ts->hour,
+			ts->minute, le16_to_cpu(ts->typeAndTimezone));
 #endif
 	}
 
 	if (!udf_build_ustr(instr, pvoldesc->volIdent, 32))
-		if (udf_CS0toUTF8(outstr, instr)) {
+		if (udf_CS0toUTF8(sb, outstr, instr)) {
 			strncpy(UDF_SB(sb)->s_volume_ident, outstr->u_name,
 				outstr->u_len > 31 ? 31 : outstr->u_len);
 			udf_debug("volIdent[] = '%s'\n",
-					UDF_SB(sb)->s_volume_ident);
+				UDF_SB(sb)->s_volume_ident);
 		}
 
 	if (!udf_build_ustr(instr, pvoldesc->volSetIdent, 128))
-		if (udf_CS0toUTF8(outstr, instr))
+		if (udf_CS0toUTF8(sb, outstr, instr))
 			udf_debug("volSetIdent[] = '%s'\n", outstr->u_name);
 
 	brelse(bh);
@@ -853,17 +848,17 @@ static int udf_load_metadata_files(struct super_block *sb, int partition)
 	addr.partitionReferenceNum = map->s_partition_num;
 
 	udf_debug("Metadata file location: block = %d part = %d\n",
-			  addr.logicalBlockNum, addr.partitionReferenceNum);
+		addr.logicalBlockNum, addr.partitionReferenceNum);
 
 	mdata->s_metadata_fe = udf_iget(sb, &addr);
 
 	if (mdata->s_metadata_fe == NULL) {
-		udf_warning(sb, __func__, "metadata inode efe not found, "
-				"will try mirror inode.");
+		udf_warn(sb, __func__, "metadata inode efe not found, "
+			"will try mirror inode.");
 		fe_error = 1;
 	} else if (UDF_I(mdata->s_metadata_fe)->i_alloc_type !=
 		 ICBTAG_FLAG_AD_SHORT) {
-		udf_warning(sb, __func__, "metadata inode efe does not have "
+		udf_warn(sb, __func__, "metadata inode efe does not have "
 			"short allocation descriptors!");
 		fe_error = 1;
 		iput(mdata->s_metadata_fe);
@@ -875,21 +870,21 @@ static int udf_load_metadata_files(struct super_block *sb, int partition)
 	addr.partitionReferenceNum = map->s_partition_num;
 
 	udf_debug("Mirror metadata file location: block = %d part = %d\n",
-			  addr.logicalBlockNum, addr.partitionReferenceNum);
+		addr.logicalBlockNum, addr.partitionReferenceNum);
 
 	mdata->s_mirror_fe = udf_iget(sb, &addr);
 
 	if (mdata->s_mirror_fe == NULL) {
 		if (fe_error) {
-			udf_error(sb, __func__, "mirror inode efe not found "
-			"and metadata inode is missing too, exiting...");
+			udf_err(sb, __func__, "mirror inode efe not found and "
+				"metadata inode is missing too, exiting...");
 			goto error_exit;
 		} else
-			udf_warning(sb, __func__, "mirror inode efe not found,"
-					" but metadata inode is OK");
+			udf_warn(sb, __func__, "mirror inode efe not found,"
+				" but metadata inode is OK");
 	} else if (UDF_I(mdata->s_mirror_fe)->i_alloc_type !=
 		 ICBTAG_FLAG_AD_SHORT) {
-		udf_warning(sb, __func__, "mirror inode efe does not have "
+		udf_warn(sb, __func__, "mirror inode efe does not have "
 			"short allocation descriptors!");
 		iput(mdata->s_mirror_fe);
 		mdata->s_mirror_fe = NULL;
@@ -913,11 +908,11 @@ static int udf_load_metadata_files(struct super_block *sb, int partition)
 
 		if (mdata->s_bitmap_fe == NULL) {
 			if (sb->s_flags & MS_RDONLY)
-				udf_warning(sb, __func__, "bitmap inode efe "
+				udf_warn(sb, __func__, "bitmap inode efe "
 					"not found but it's ok since the disc"
 					" is mounted read-only");
 			else {
-				udf_error(sb, __func__, "bitmap inode efe not "
+				udf_err(sb, __func__, "bitmap inode efe not "
 					"found and attempted read-write mount");
 				goto error_exit;
 			}
@@ -944,7 +939,7 @@ static void udf_load_fileset(struct super_block *sb, struct buffer_head *bh,
 	UDF_SB(sb)->s_serial_number = le16_to_cpu(fset->descTag.tagSerialNum);
 
 	udf_debug("Rootdir at block=%d, partition=%d\n",
-		  root->logicalBlockNum, root->partitionReferenceNum);
+		root->logicalBlockNum, root->partitionReferenceNum);
 }
 
 int udf_compute_nr_groups(struct super_block *sb, u32 partition)
@@ -971,9 +966,10 @@ static struct udf_bitmap *udf_sb_alloc_bitmap(struct super_block *sb, u32 index)
 		bitmap = vzalloc(size); /* TODO: get rid of vzalloc */
 
 	if (bitmap == NULL) {
-		udf_error(sb, __func__,
-			  "Unable to allocate space for bitmap "
-			  "and %d buffer_head pointers", nr_groups);
+		udf_err(sb, __func__,
+			"Unable to allocate space for bitmap "
+			"and %d buffer_head pointers\n",
+			nr_groups);
 		return NULL;
 	}
 
@@ -1004,9 +1000,9 @@ static int udf_fill_partdesc_info(struct super_block *sb,
 		map->s_partition_flags |= UDF_PART_FLAG_OVERWRITABLE;
 
 	udf_debug("Partition (%d type %x) starts at physical %d, "
-		  "block length %d\n", p_index,
-		  map->s_partition_type, map->s_partition_root,
-		  map->s_partition_len);
+		"block length %d\n",
+		p_index, map->s_partition_type,
+		map->s_partition_root, map->s_partition_len);
 
 	if (strcmp(p->partitionContents.ident, PD_PARTITION_CONTENTS_NSR02) &&
 	    strcmp(p->partitionContents.ident, PD_PARTITION_CONTENTS_NSR03))
@@ -1023,12 +1019,12 @@ static int udf_fill_partdesc_info(struct super_block *sb,
 		map->s_uspace.s_table = udf_iget(sb, &loc);
 		if (!map->s_uspace.s_table) {
 			udf_debug("cannot load unallocSpaceTable (part %d)\n",
-					p_index);
+				p_index);
 			return 1;
 		}
 		map->s_partition_flags |= UDF_PART_FLAG_UNALLOC_TABLE;
 		udf_debug("unallocSpaceTable (part %d) @ %ld\n",
-				p_index, map->s_uspace.s_table->i_ino);
+			p_index, map->s_uspace.s_table->i_ino);
 	}
 
 	if (phd->unallocSpaceBitmap.extLength) {
@@ -1041,8 +1037,8 @@ static int udf_fill_partdesc_info(struct super_block *sb,
 		bitmap->s_extPosition = le32_to_cpu(
 				phd->unallocSpaceBitmap.extPosition);
 		map->s_partition_flags |= UDF_PART_FLAG_UNALLOC_BITMAP;
-		udf_debug("unallocSpaceBitmap (part %d) @ %d\n", p_index,
-						bitmap->s_extPosition);
+		udf_debug("unallocSpaceBitmap (part %d) @ %d\n",
+			p_index, bitmap->s_extPosition);
 	}
 
 	if (phd->partitionIntegrityTable.extLength)
@@ -1064,7 +1060,7 @@ static int udf_fill_partdesc_info(struct super_block *sb,
 
 		map->s_partition_flags |= UDF_PART_FLAG_FREED_TABLE;
 		udf_debug("freedSpaceTable (part %d) @ %ld\n",
-				p_index, map->s_fspace.s_table->i_ino);
+			p_index, map->s_fspace.s_table->i_ino);
 	}
 
 	if (phd->freedSpaceBitmap.extLength) {
@@ -1077,8 +1073,8 @@ static int udf_fill_partdesc_info(struct super_block *sb,
 		bitmap->s_extPosition = le32_to_cpu(
 				phd->freedSpaceBitmap.extPosition);
 		map->s_partition_flags |= UDF_PART_FLAG_FREED_BITMAP;
-		udf_debug("freedSpaceBitmap (part %d) @ %d\n", p_index,
-					bitmap->s_extPosition);
+		udf_debug("freedSpaceBitmap (part %d) @ %d\n",
+			p_index, bitmap->s_extPosition);
 	}
 	return 0;
 }
@@ -1118,11 +1114,11 @@ static int udf_load_vat(struct super_block *sb, int p_index, int type1_index)
 	udf_find_vat_block(sb, p_index, type1_index, sbi->s_last_block);
 	if (!sbi->s_vat_inode &&
 	    sbi->s_last_block != blocks - 1) {
-		printk(KERN_NOTICE "UDF-fs: Failed to read VAT inode from the"
-		       " last recorded block (%lu), retrying with the last "
-		       "block of the device (%lu).\n",
-		       (unsigned long)sbi->s_last_block,
-		       (unsigned long)blocks - 1);
+		udf_info(sb, "Failed to read VAT inode from the"
+			" last recorded block (%lu), retrying with the last "
+			"block of the device (%lu).\n",
+			(unsigned long)sbi->s_last_block,
+			(unsigned long)blocks - 1);
 		udf_find_vat_block(sb, p_index, type1_index, blocks - 1);
 	}
 	if (!sbi->s_vat_inode)
@@ -1180,7 +1176,7 @@ static int udf_load_partdesc(struct super_block *sb, sector_t block)
 	for (i = 0; i < sbi->s_partitions; i++) {
 		map = &sbi->s_partmaps[i];
 		udf_debug("Searching map: (%d == %d)\n",
-			  map->s_partition_num, partitionNumber);
+			map->s_partition_num, partitionNumber);
 		if (map->s_partition_num == partitionNumber &&
 		    (map->s_partition_type == UDF_TYPE1_MAP15 ||
 		     map->s_partition_type == UDF_SPARABLE_MAP15))
@@ -1189,7 +1185,7 @@ static int udf_load_partdesc(struct super_block *sb, sector_t block)
 
 	if (i >= sbi->s_partitions) {
 		udf_debug("Partition (%d) not found in partition map\n",
-			  partitionNumber);
+			partitionNumber);
 		goto out_bh;
 	}
 
@@ -1220,8 +1216,9 @@ static int udf_load_partdesc(struct super_block *sb, sector_t block)
 	if (map->s_partition_type == UDF_METADATA_MAP25) {
 		ret = udf_load_metadata_files(sb, i);
 		if (ret) {
-			printk(KERN_ERR "UDF-fs: error loading MetaData "
-			"partition map %d\n", i);
+			udf_err(sb, __func__, "loading MetaData "
+				"partition map %d\n",
+				i);
 			goto out_bh;
 		}
 	} else {
@@ -1234,7 +1231,7 @@ static int udf_load_partdesc(struct super_block *sb, sector_t block)
 		 * overwrite blocks instead of relocating them).
 		 */
 		sb->s_flags |= MS_RDONLY;
-		printk(KERN_NOTICE "UDF-fs: Filesystem marked read-only "
+		udf_info(sb, "Filesystem marked read-only "
 			"because writing to pseudooverwrite partition is "
 			"not implemented.\n");
 	}
@@ -1345,8 +1342,8 @@ static int udf_load_logicalvol(struct super_block *sb, sector_t block,
 						(struct metadataPartitionMap *)
 						&(lvd->partitionMaps[offset]);
 				udf_debug("Parsing Logical vol part %d "
-					"type %d  id=%s\n", i, type,
-					UDF_ID_METADATA);
+					"type %d  id=%s\n",
+					i, type, UDF_ID_METADATA);
 
 				map->s_partition_type = UDF_METADATA_MAP25;
 				map->s_partition_func = udf_get_pblock_meta25;
@@ -1365,9 +1362,8 @@ static int udf_load_logicalvol(struct super_block *sb, sector_t block,
 					mdm->flags & 0x01;
 
 				udf_debug("Metadata Ident suffix=0x%x\n",
-					(le16_to_cpu(
-					 ((__le16 *)
-					      mdm->partIdent.identSuffix)[0])));
+					(le16_to_cpu(((__le16 *)
+					mdm->partIdent.identSuffix)[0])));
 				udf_debug("Metadata part num=%d\n",
 					le16_to_cpu(mdm->partitionNum));
 				udf_debug("Metadata part alloc unit size=%d\n",
@@ -1382,15 +1378,14 @@ static int udf_load_logicalvol(struct super_block *sb, sector_t block,
 					mdata->s_dup_md_flag, mdm->flags);
 			} else {
 				udf_debug("Unknown ident: %s\n",
-					  upm2->partIdent.ident);
+					upm2->partIdent.ident);
 				continue;
 			}
 			map->s_volumeseqnum = le16_to_cpu(upm2->volSeqNum);
 			map->s_partition_num = le16_to_cpu(upm2->partitionNum);
 		}
 		udf_debug("Partition (%d:%d) type %d on volume %d\n",
-			  i, map->s_partition_num, type,
-			  map->s_volumeseqnum);
+			i, map->s_partition_num, type, map->s_volumeseqnum);
 	}
 
 	if (fileset) {
@@ -1398,8 +1393,9 @@ static int udf_load_logicalvol(struct super_block *sb, sector_t block,
 
 		*fileset = lelb_to_cpu(la->extLocation);
 		udf_debug("FileSet found in LogicalVolDesc at block=%d, "
-			  "partition=%d\n", fileset->logicalBlockNum,
-			  fileset->partitionReferenceNum);
+			"partition=%d\n",
+			fileset->logicalBlockNum,
+			fileset->partitionReferenceNum);
 	}
 	if (lvd->integritySeqExt.extLength)
 		udf_load_logicalvolint(sb, leea_to_cpu(lvd->integritySeqExt));
@@ -1478,9 +1474,9 @@ static noinline int udf_process_sequence(struct super_block *sb, long block,
 
 		bh = udf_read_tagged(sb, block, block, &ident);
 		if (!bh) {
-			printk(KERN_ERR "udf: Block %Lu of volume descriptor "
-			       "sequence is corrupted or we could not read "
-			       "it.\n", (unsigned long long)block);
+			udf_err(sb, __func__, "Block %Lu of volume descriptor "
+				"sequence is corrupted or we could not read "
+				"it.\n", (unsigned long long)block);
 			return 1;
 		}
 
@@ -1553,7 +1549,7 @@ static noinline int udf_process_sequence(struct super_block *sb, long block,
 	 * in a suitable order
 	 */
 	if (!vds[VDS_POS_PRIMARY_VOL_DESC].block) {
-		printk(KERN_ERR "udf: Primary Volume Descriptor not found!\n");
+		udf_err(sb, __func__, "Primary Volume Descriptor not found!\n");
 		return 1;
 	}
 	if (udf_load_pvoldesc(sb, vds[VDS_POS_PRIMARY_VOL_DESC].block))
@@ -1740,7 +1736,7 @@ static int udf_load_vrs(struct super_block *sb, struct udf_options *uopt,
 
 	if (!sb_set_blocksize(sb, uopt->blocksize)) {
 		if (!silent)
-			printk(KERN_WARNING "UDF-fs: Bad block size\n");
+			udf_warn(sb, __func__, "Bad block size\n");
 		return 0;
 	}
 	sbi->s_last_block = uopt->lastblock;
@@ -1749,12 +1745,12 @@ static int udf_load_vrs(struct super_block *sb, struct udf_options *uopt,
 		nsr_off = udf_check_vsd(sb);
 		if (!nsr_off) {
 			if (!silent)
-				printk(KERN_WARNING "UDF-fs: No VRS found\n");
+				udf_warn(sb, __func__, "No VRS found\n");
 			return 0;
 		}
 		if (nsr_off == -1)
 			udf_debug("Failed to read byte 32768. Assuming open "
-				  "disc. Skipping validity check\n");
+				"disc. Skipping validity check\n");
 		if (!sbi->s_last_block)
 			sbi->s_last_block = udf_get_last_block(sb);
 	} else {
@@ -1765,7 +1761,7 @@ static int udf_load_vrs(struct super_block *sb, struct udf_options *uopt,
 	sbi->s_anchor = uopt->anchor;
 	if (!udf_find_anchor(sb, fileset)) {
 		if (!silent)
-			printk(KERN_WARNING "UDF-fs: No anchor found\n");
+			udf_warn(sb, __func__, "No anchor found\n");
 		return 0;
 	}
 	return 1;
@@ -1932,13 +1928,13 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
 
 	mutex_init(&sbi->s_alloc_mutex);
 
-	if (!udf_parse_options((char *)options, &uopt, false))
+	if (!udf_parse_options(sb, (char *)options, &uopt, false))
 		goto error_out;
 
 	if (uopt.flags & (1 << UDF_FLAG_UTF8) &&
 	    uopt.flags & (1 << UDF_FLAG_NLS_MAP)) {
-		udf_error(sb, "udf_read_super",
-			  "utf8 cannot be combined with iocharset\n");
+		udf_err(sb, __func__, "udf_read_super"
+			"utf8 cannot be combined with iocharset\n");
 		goto error_out;
 	}
 #ifdef CONFIG_UDF_NLS
@@ -1987,15 +1983,14 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
 		ret = udf_load_vrs(sb, &uopt, silent, &fileset);
 		if (!ret && uopt.blocksize != UDF_DEFAULT_BLOCKSIZE) {
 			if (!silent)
-				printk(KERN_NOTICE
-				       "UDF-fs: Rescanning with blocksize "
-				       "%d\n", UDF_DEFAULT_BLOCKSIZE);
+				udf_info(sb, "Rescanning with blocksize %d\n",
+					UDF_DEFAULT_BLOCKSIZE);
 			uopt.blocksize = UDF_DEFAULT_BLOCKSIZE;
 			ret = udf_load_vrs(sb, &uopt, silent, &fileset);
 		}
 	}
 	if (!ret) {
-		printk(KERN_WARNING "UDF-fs: No partition found (1)\n");
+		udf_warn(sb, __func__, "No partition found (1)\n");
 		goto error_out;
 	}
 
@@ -2010,10 +2005,9 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
 				le16_to_cpu(lvidiu->maxUDFWriteRev); */
 
 		if (minUDFReadRev > UDF_MAX_READ_VERSION) {
-			printk(KERN_ERR "UDF-fs: minUDFReadRev=%x "
-					"(max is %x)\n",
-			       le16_to_cpu(lvidiu->minUDFReadRev),
-			       UDF_MAX_READ_VERSION);
+			udf_err(sb, __func__, "minUDFReadRev=%x (max is %x)\n",
+				le16_to_cpu(lvidiu->minUDFReadRev),
+				UDF_MAX_READ_VERSION);
 			goto error_out;
 		} else if (minUDFWriteRev > UDF_MAX_WRITE_VERSION)
 			sb->s_flags |= MS_RDONLY;
@@ -2027,29 +2021,30 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
 	}
 
 	if (!sbi->s_partitions) {
-		printk(KERN_WARNING "UDF-fs: No partition found (2)\n");
+		udf_warn(sb, __func__, "No partition found (2)\n");
 		goto error_out;
 	}
 
 	if (sbi->s_partmaps[sbi->s_partition].s_partition_flags &
 			UDF_PART_FLAG_READ_ONLY) {
-		printk(KERN_NOTICE "UDF-fs: Partition marked readonly; "
-				   "forcing readonly mount\n");
+		udf_info(sb, "Partition marked readonly; "
+			"forcing readonly mount\n");
 		sb->s_flags |= MS_RDONLY;
 	}
 
 	if (udf_find_fileset(sb, &fileset, &rootdir)) {
-		printk(KERN_WARNING "UDF-fs: No fileset found\n");
+		udf_warn(sb, __func__, "No fileset found\n");
 		goto error_out;
 	}
 
 	if (!silent) {
 		struct timestamp ts;
 		udf_time_to_disk_stamp(&ts, sbi->s_record_time);
-		udf_info("UDF: Mounting volume '%s', "
-			 "timestamp %04u/%02u/%02u %02u:%02u (%x)\n",
-			 sbi->s_volume_ident, le16_to_cpu(ts.year), ts.month, ts.day,
-			 ts.hour, ts.minute, le16_to_cpu(ts.typeAndTimezone));
+		udf_info(sb, "Mounting volume '%s', "
+			"timestamp %04u/%02u/%02u %02u:%02u (%x)\n",
+			sbi->s_volume_ident, le16_to_cpu(ts.year), ts.month,
+			ts.day, ts.hour, ts.minute,
+			le16_to_cpu(ts.typeAndTimezone));
 	}
 	if (!(sb->s_flags & MS_RDONLY))
 		udf_open_lvid(sb);
@@ -2059,16 +2054,16 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
 	/* perhaps it's not extensible enough, but for now ... */
 	inode = udf_iget(sb, &rootdir);
 	if (!inode) {
-		printk(KERN_ERR "UDF-fs: Error in udf_iget, block=%d, "
-				"partition=%d\n",
-		       rootdir.logicalBlockNum, rootdir.partitionReferenceNum);
+		udf_err(sb, __func__, "Error in udf_iget, block=%d, "
+			"partition=%d\n",
+			rootdir.logicalBlockNum, rootdir.partitionReferenceNum);
 		goto error_out;
 	}
 
 	/* Allocate a dentry for the root inode */
 	sb->s_root = d_alloc_root(inode);
 	if (!sb->s_root) {
-		printk(KERN_ERR "UDF-fs: Couldn't allocate root dentry\n");
+		udf_err(sb, __func__, "Couldn't allocate root dentry\n");
 		iput(inode);
 		goto error_out;
 	}
@@ -2096,32 +2091,52 @@ error_out:
 	return -EINVAL;
 }
 
-static void udf_error(struct super_block *sb, const char *function,
+void udf_err(struct super_block *sb, const char *function,
 		      const char *fmt, ...)
 {
+	struct va_format vaf;
 	va_list args;
 
+	va_start(args, fmt);
+	vaf.fmt = fmt;
+	vaf.va = &args;
+
 	if (!(sb->s_flags & MS_RDONLY)) {
 		/* mark sb error */
 		sb->s_dirt = 1;
 	}
+
+	pr_crit("error (device %s): %s: %pV", sb->s_id, function, &vaf);
+	va_end(args);
+}
+
+void udf_warn(struct super_block *sb, const char *function,
+		const char *fmt, ...)
+{
+	struct va_format vaf;
+	va_list args;
+
 	va_start(args, fmt);
-	vsnprintf(error_buf, sizeof(error_buf), fmt, args);
+
+	vaf.fmt = fmt;
+	vaf.va = &args;
+
+	pr_warn("warning (device %s): %s: %pV", sb->s_id, function, &vaf);
 	va_end(args);
-	printk(KERN_CRIT "UDF-fs error (device %s): %s: %s\n",
-		sb->s_id, function, error_buf);
 }
 
-void udf_warning(struct super_block *sb, const char *function,
-		 const char *fmt, ...)
+void udf_info(struct super_block *sb, const char *fmt, ...)
 {
+	struct va_format vaf;
 	va_list args;
 
 	va_start(args, fmt);
-	vsnprintf(error_buf, sizeof(error_buf), fmt, args);
+
+	vaf.fmt = fmt;
+	vaf.va = &args;
+
+	pr_info("info (device %s): %pV", sb->s_id, &vaf);
 	va_end(args);
-	printk(KERN_WARNING "UDF-fs warning (device %s): %s: %s\n",
-	       sb->s_id, function, error_buf);
 }
 
 static void udf_put_super(struct super_block *sb)
@@ -2213,11 +2228,11 @@ static unsigned int udf_count_free_bitmap(struct super_block *sb,
 	bh = udf_read_ptagged(sb, &loc, 0, &ident);
 
 	if (!bh) {
-		printk(KERN_ERR "udf: udf_count_free failed\n");
+		udf_err(sb, __func__, "udf_count_free failed\n");
 		goto out;
 	} else if (ident != TAG_IDENT_SBD) {
 		brelse(bh);
-		printk(KERN_ERR "udf: udf_count_free failed\n");
+		udf_err(sb, __func__, "udf_count_free failed\n");
 		goto out;
 	}
 
diff --git a/fs/udf/truncate.c b/fs/udf/truncate.c
index 8424308..f07ef23 100644
--- a/fs/udf/truncate.c
+++ b/fs/udf/truncate.c
@@ -95,23 +95,24 @@ void udf_truncate_tail_extent(struct inode *inode)
 		lbcount += elen;
 		if (lbcount > inode->i_size) {
 			if (lbcount - inode->i_size >= inode->i_sb->s_blocksize)
-				printk(KERN_WARNING
-				       "udf_truncate_tail_extent(): Too long "
-				       "extent after EOF in inode %u: i_size: "
-				       "%Ld lbcount: %Ld extent %u+%u\n",
-				       (unsigned)inode->i_ino,
-				       (long long)inode->i_size,
-				       (long long)lbcount,
-				       (unsigned)eloc.logicalBlockNum,
-				       (unsigned)elen);
+				udf_warn(inode->i_sb, __func__,
+					"udf_truncate_tail_extent(): Too long "
+					"extent after EOF in inode %u: i_size: "
+					"%Ld lbcount: %Ld extent %u+%u\n",
+					(unsigned)inode->i_ino,
+					(long long)inode->i_size,
+					(long long)lbcount,
+					(unsigned)eloc.logicalBlockNum,
+					(unsigned)elen);
 			nelen = elen - (lbcount - inode->i_size);
 			epos.offset -= adsize;
 			extent_trunc(inode, &epos, &eloc, etype, elen, nelen);
 			epos.offset += adsize;
 			if (udf_next_aext(inode, &epos, &eloc, &elen, 1) != -1)
-				printk(KERN_ERR "udf_truncate_tail_extent(): "
-				       "Extent after EOF in inode %u.\n",
-				       (unsigned)inode->i_ino);
+				udf_warn(inode->i_sb, __func__,
+					"udf_truncate_tail_extent(): "
+					"Extent after EOF in inode %u.\n",
+					(unsigned)inode->i_ino);
 			break;
 		}
 	}
diff --git a/fs/udf/udfdecl.h b/fs/udf/udfdecl.h
index dbd52d4b..abd6e69 100644
--- a/fs/udf/udfdecl.h
+++ b/fs/udf/udfdecl.h
@@ -1,6 +1,8 @@
 #ifndef __UDF_DECL_H
 #define __UDF_DECL_H
 
+#define pr_fmt(fmt) "UDF-fs " fmt
+
 #include "ecma_167.h"
 #include "osta_udf.h"
 
@@ -16,23 +18,28 @@
 #define UDF_PREALLOCATE
 #define UDF_DEFAULT_PREALLOC_BLOCKS	8
 
+__attribute__((format(printf, 3, 4)))
+void udf_err(struct super_block *sb, const char *function,
+		const char *fmt, ...);
+
+__attribute__((format(printf, 3, 4)))
+void udf_warn(struct super_block *sb, const char *function,
+		const char *fmt, ...);
+
+__attribute__((format(printf, 2, 3)))
+void udf_info(struct super_block *sb, const char *fmt, ...);
+
 #undef UDFFS_DEBUG
 
 #ifdef UDFFS_DEBUG
-#define udf_debug(f, a...) \
-do { \
-	printk(KERN_DEBUG "UDF-fs DEBUG %s:%d:%s: ", \
-		__FILE__, __LINE__, __func__); \
-	printk(f, ##a); \
-} while (0)
+#define udf_debug(fmt, ...)	\
+	pr_debug("debug %s:%d:%s: " fmt,	\
+		__FILE__, __LINE__, __func__, ##__VA_ARGS__)
 #else
-#define udf_debug(f, a...) /**/
+#define udf_debug(fmt, ...)	\
+	no_printk(KERN_DEBUG fmt, ##__VA_ARGS__)
 #endif
 
-#define udf_info(f, a...) \
-	printk(KERN_INFO "UDF-fs INFO " f, ##a);
-
-
 #define udf_fixed_to_variable(x) ( ( ( (x) >> 5 ) * 39 ) + ( (x) & 0x0000001F ) )
 #define udf_variable_to_fixed(x) ( ( ( (x) / 39 ) << 5 ) + ( (x) % 39 ) )
 
@@ -112,8 +119,6 @@ struct extent_position {
 
 /* super.c */
 
-__attribute__((format(printf, 3, 4)))
-extern void udf_warning(struct super_block *, const char *, const char *, ...);
 static inline void udf_updated_lvid(struct super_block *sb)
 {
 	struct buffer_head *bh = UDF_SB(sb)->s_lvid_bh;
@@ -202,7 +207,8 @@ extern int udf_get_filename(struct super_block *, uint8_t *, uint8_t *, int);
 extern int udf_put_filename(struct super_block *, const uint8_t *, uint8_t *,
 			    int);
 extern int udf_build_ustr(struct ustr *, dstring *, int);
-extern int udf_CS0toUTF8(struct ustr *, const struct ustr *);
+extern int udf_CS0toUTF8(struct super_block *, struct ustr *,
+			const struct ustr *);
 
 /* ialloc.c */
 extern void udf_free_inode(struct inode *);
@@ -230,8 +236,10 @@ extern struct fileIdentDesc *udf_fileident_read(struct inode *, loff_t *,
 						sector_t *);
 extern struct fileIdentDesc *udf_get_fileident(void *buffer, int bufsize,
 					       int *offset);
-extern struct long_ad *udf_get_filelongad(uint8_t *, int, uint32_t *, int);
-extern struct short_ad *udf_get_fileshortad(uint8_t *, int, uint32_t *, int);
+extern struct long_ad *udf_get_filelongad(struct inode *, uint8_t *, int,
+						uint32_t *, int);
+extern struct short_ad *udf_get_fileshortad(struct inode *, uint8_t *, int,
+						uint32_t *, int);
 
 /* udftime.c */
 extern struct timespec *udf_disk_stamp_to_time(struct timespec *dest,
diff --git a/fs/udf/udftime.c b/fs/udf/udftime.c
index b8c828c..927c931 100644
--- a/fs/udf/udftime.c
+++ b/fs/udf/udftime.c
@@ -34,9 +34,9 @@
  * http://www.boulder.nist.gov/timefreq/pubs/bulletin/leapsecond.htm
  */
 
+#include "udfdecl.h"
 #include <linux/types.h>
 #include <linux/kernel.h>
-#include "udfdecl.h"
 
 #define EPOCH_YEAR 1970
 
diff --git a/fs/udf/unicode.c b/fs/udf/unicode.c
index d03a90b..426f8f3 100644
--- a/fs/udf/unicode.c
+++ b/fs/udf/unicode.c
@@ -99,7 +99,8 @@ static int udf_build_ustr_exact(struct ustr *dest, dstring *ptr, int exactsize)
  *	November 12, 1997 - Andrew E. Mileski
  *	Written, tested, and released.
  */
-int udf_CS0toUTF8(struct ustr *utf_o, const struct ustr *ocu_i)
+int udf_CS0toUTF8(struct super_block *sb, struct ustr *utf_o,
+			const struct ustr *ocu_i)
 {
 	const uint8_t *ocu;
 	uint8_t cmp_id, ocu_len;
@@ -114,8 +115,8 @@ int udf_CS0toUTF8(struct ustr *utf_o, const struct ustr *ocu_i)
 	cmp_id = ocu_i->u_cmpID;
 	if (cmp_id != 8 && cmp_id != 16) {
 		memset(utf_o, 0, sizeof(struct ustr));
-		printk(KERN_ERR "udf: unknown compression code (%d) stri=%s\n",
-		       cmp_id, ocu_i->u_name);
+		udf_err(sb, __func__, "unknown compression code (%d) stri=%s\n",
+			cmp_id, ocu_i->u_name);
 		return 0;
 	}
 
@@ -174,7 +175,8 @@ int udf_CS0toUTF8(struct ustr *utf_o, const struct ustr *ocu_i)
  *	November 12, 1997 - Andrew E. Mileski
  *	Written, tested, and released.
  */
-static int udf_UTF8toCS0(dstring *ocu, struct ustr *utf, int length)
+static int udf_UTF8toCS0(struct super_block *sb, dstring *ocu, struct ustr *utf,
+			int length)
 {
 	unsigned c, i, max_val, utf_char;
 	int utf_cnt, u_len;
@@ -242,7 +244,7 @@ try_again:
 	if (utf_cnt) {
 error_out:
 		ocu[++u_len] = '?';
-		printk(KERN_DEBUG "udf: bad UTF-8 character\n");
+		udf_debug("bad UTF-8 character\n");
 	}
 
 	ocu[length - 1] = (uint8_t)u_len + 1;
@@ -250,8 +252,8 @@ error_out:
 	return u_len + 1;
 }
 
-static int udf_CS0toNLS(struct nls_table *nls, struct ustr *utf_o,
-			const struct ustr *ocu_i)
+static int udf_CS0toNLS(struct super_block *sb, struct nls_table *nls,
+			struct ustr *utf_o, const struct ustr *ocu_i)
 {
 	const uint8_t *ocu;
 	uint8_t cmp_id, ocu_len;
@@ -267,8 +269,8 @@ static int udf_CS0toNLS(struct nls_table *nls, struct ustr *utf_o,
 	cmp_id = ocu_i->u_cmpID;
 	if (cmp_id != 8 && cmp_id != 16) {
 		memset(utf_o, 0, sizeof(struct ustr));
-		printk(KERN_ERR "udf: unknown compression code (%d) stri=%s\n",
-		       cmp_id, ocu_i->u_name);
+		udf_err(sb, __func__, "unknown compression code (%d) stri=%s\n",
+			cmp_id, ocu_i->u_name);
 		return 0;
 	}
 
@@ -293,8 +295,8 @@ static int udf_CS0toNLS(struct nls_table *nls, struct ustr *utf_o,
 	return utf_o->u_len;
 }
 
-static int udf_NLStoCS0(struct nls_table *nls, dstring *ocu, struct ustr *uni,
-			int length)
+static int udf_NLStoCS0(struct super_block *sb, struct nls_table *nls,
+			dstring *ocu, struct ustr *uni, int length)
 {
 	int len;
 	unsigned i, max_val;
@@ -351,16 +353,16 @@ int udf_get_filename(struct super_block *sb, uint8_t *sname, uint8_t *dname,
 		goto out2;
 
 	if (UDF_QUERY_FLAG(sb, UDF_FLAG_UTF8)) {
-		if (!udf_CS0toUTF8(filename, unifilename)) {
+		if (!udf_CS0toUTF8(sb, filename, unifilename)) {
 			udf_debug("Failed in udf_get_filename: sname = %s\n",
-				  sname);
+				sname);
 			goto out2;
 		}
 	} else if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP)) {
-		if (!udf_CS0toNLS(UDF_SB(sb)->s_nls_map, filename,
+		if (!udf_CS0toNLS(sb, UDF_SB(sb)->s_nls_map, filename,
 				  unifilename)) {
 			udf_debug("Failed in udf_get_filename: sname = %s\n",
-				  sname);
+				sname);
 			goto out2;
 		}
 	} else
@@ -385,11 +387,11 @@ int udf_put_filename(struct super_block *sb, const uint8_t *sname,
 		return 0;
 
 	if (UDF_QUERY_FLAG(sb, UDF_FLAG_UTF8)) {
-		namelen = udf_UTF8toCS0(dname, &unifilename, UDF_NAME_LEN);
+		namelen = udf_UTF8toCS0(sb, dname, &unifilename, UDF_NAME_LEN);
 		if (!namelen)
 			return 0;
 	} else if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP)) {
-		namelen = udf_NLStoCS0(UDF_SB(sb)->s_nls_map, dname,
+		namelen = udf_NLStoCS0(sb, UDF_SB(sb)->s_nls_map, dname,
 					&unifilename, UDF_NAME_LEN);
 		if (!namelen)
 			return 0;
-- 
1.7.4.4


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* Re: [PATCH 1/2 v3] udf : enable error print in udf_read_tagged().
  2011-10-09  3:16       ` NamJae Jeon
@ 2011-10-09  3:29         ` Joe Perches
  2011-10-09  4:44           ` NamJae Jeon
  0 siblings, 1 reply; 36+ messages in thread
From: Joe Perches @ 2011-10-09  3:29 UTC (permalink / raw)
  To: NamJae Jeon; +Cc: Jan Kara, linux-kernel

On Sun, 2011-10-09 at 12:16 +0900, NamJae Jeon wrote:
> 2011/10/7 Jan Kara <jack@suse.cz>:
> > On Wed 05-10-11 15:19:58, Joe Perches wrote:
> >> On Thu, 2011-10-06 at 00:08 +0200, Jan Kara wrote:
> >> > Hello,
> >> >
> >> > On Mon 03-10-11 22:53:57, Namjae Jeon wrote:
> >> > > While reading metadata, if a problem occurs, Print out only one of the
> >> > > five case.(It also does not show a checksum properly.) Because currently
> >> > > it have been disable by undef udf_debug.  If there is a problem with
> >> > > scratched disc or loader, the user needs to know which error happened.
> >> > > And I use pr_fmt instead of printk by joe's suggestion. I try to modify
> >> > > totally it to pr_fmt also.
> >>
> >> >   Thanks for the patch. I'm willing to take the patch since it's an
> >> > improvement but what would be even nicer is to have error reporting like in
> >> > ext3 / ext4. We would have functions udf_info, udf_warn, udf_err which
> >> > also print sb->s_id with each error so that user can better identify on
> >> > which filesystem error happened.
> >>
> >> Modifying the follow-on patch I sent would be pretty trivial.
> >  Sure, I can do that but if Namjae is willing to do it, I'd have less work
> > :).
> Hi. Jan.
> 
> Currently I can not send a patch using git send-email.
> maybe it is the problem related with git or patch size...
> So I attach a patch. Is it okay? or I resend a patch again..
> plz review attach patch.
> Thanks.

Not a good patch I think.

You've broken format strings when they should be coalesced
and the alignment looks odd.

udf_debug should also add
	struct super_block *sb, const char *function,
as the leading arguments.


^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 1/2 v3] udf : enable error print in udf_read_tagged().
  2011-10-09  3:29         ` Joe Perches
@ 2011-10-09  4:44           ` NamJae Jeon
  2011-10-09  4:56             ` Joe Perches
  0 siblings, 1 reply; 36+ messages in thread
From: NamJae Jeon @ 2011-10-09  4:44 UTC (permalink / raw)
  To: Joe Perches; +Cc: Jan Kara, linux-kernel

2011/10/9 Joe Perches <joe@perches.com>:
> On Sun, 2011-10-09 at 12:16 +0900, NamJae Jeon wrote:
>> 2011/10/7 Jan Kara <jack@suse.cz>:
>> > On Wed 05-10-11 15:19:58, Joe Perches wrote:
>> >> On Thu, 2011-10-06 at 00:08 +0200, Jan Kara wrote:
>> >> > Hello,
>> >> >
>> >> > On Mon 03-10-11 22:53:57, Namjae Jeon wrote:
>> >> > > While reading metadata, if a problem occurs, Print out only one of the
>> >> > > five case.(It also does not show a checksum properly.) Because currently
>> >> > > it have been disable by undef udf_debug.  If there is a problem with
>> >> > > scratched disc or loader, the user needs to know which error happened.
>> >> > > And I use pr_fmt instead of printk by joe's suggestion. I try to modify
>> >> > > totally it to pr_fmt also.
>> >>
>> >> >   Thanks for the patch. I'm willing to take the patch since it's an
>> >> > improvement but what would be even nicer is to have error reporting like in
>> >> > ext3 / ext4. We would have functions udf_info, udf_warn, udf_err which
>> >> > also print sb->s_id with each error so that user can better identify on
>> >> > which filesystem error happened.
>> >>
>> >> Modifying the follow-on patch I sent would be pretty trivial.
>> >  Sure, I can do that but if Namjae is willing to do it, I'd have less work
>> > :).
>> Hi. Jan.
>>
>> Currently I can not send a patch using git send-email.
>> maybe it is the problem related with git or patch size...
>> So I attach a patch. Is it okay? or I resend a patch again..
>> plz review attach patch.
>> Thanks.
>
Hi. Joe.
> Not a good patch I think.
>
> You've broken format strings when they should be coalesced
> and the alignment looks odd.
Would you explain more ? I didn't understand your meaning yet.

>
> udf_debug should also add
>        struct super_block *sb, const char *function,
> as the leading arguments.
okay. I will~
Thanks for your review.
>
>

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 1/2 v3] udf : enable error print in udf_read_tagged().
  2011-10-09  4:44           ` NamJae Jeon
@ 2011-10-09  4:56             ` Joe Perches
  2011-10-09  6:25               ` NamJae Jeon
  0 siblings, 1 reply; 36+ messages in thread
From: Joe Perches @ 2011-10-09  4:56 UTC (permalink / raw)
  To: NamJae Jeon; +Cc: Jan Kara, linux-kernel

On Sun, 2011-10-09 at 13:44 +0900, NamJae Jeon wrote:
> 2011/10/9 Joe Perches <joe@perches.com>:
> > Not a good patch I think.
> > You've broken format strings when they should be coalesced
> > and the alignment looks odd.
> Would you explain more ? I didn't understand your meaning yet.

Format strings are allowed to exceed 80 columns.
Arguments should be aligned to the open parenthesis

For example:
	pr_err("some really long format string longer than "
		"80 columns and not broken into pieces, Count: %d\n",
		count);
is better as:
	pr_err("some really long format string longer than 80 columns and not broken into pieces, Count: %d\n",
	       count);

Coalesced format strings makes dmesg output easier to grep.
count is not indented by 2 tabs, but 1 tab and 7 spaces.

There's no hard and fast rule on the indentation.

The patch I sent coalesced all format strings and
used that alignment style.


^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 1/2 v3] udf : enable error print in udf_read_tagged().
  2011-10-09  4:56             ` Joe Perches
@ 2011-10-09  6:25               ` NamJae Jeon
  2011-10-09 14:07                 ` NamJae Jeon
  0 siblings, 1 reply; 36+ messages in thread
From: NamJae Jeon @ 2011-10-09  6:25 UTC (permalink / raw)
  To: Joe Perches; +Cc: Jan Kara, linux-kernel

2011/10/9 Joe Perches <joe@perches.com>:
> On Sun, 2011-10-09 at 13:44 +0900, NamJae Jeon wrote:
>> 2011/10/9 Joe Perches <joe@perches.com>:
>> > Not a good patch I think.
>> > You've broken format strings when they should be coalesced
>> > and the alignment looks odd.
>> Would you explain more ? I didn't understand your meaning yet.
>
> Format strings are allowed to exceed 80 columns.
> Arguments should be aligned to the open parenthesis
>
> For example:
>        pr_err("some really long format string longer than "
>                "80 columns and not broken into pieces, Count: %d\n",
>                count);
> is better as:
>        pr_err("some really long format string longer than 80 columns and not broken into pieces, Count: %d\n",
>               count);
>
> Coalesced format strings makes dmesg output easier to grep.
> count is not indented by 2 tabs, but 1 tab and 7 spaces.
>
> There's no hard and fast rule on the indentation.
>
> The patch I sent coalesced all format strings and
> used that alignment style.
Clear~ I will do it as your guide.
Thanks very much. joe~
>
>

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 1/2 v3] udf : enable error print in udf_read_tagged().
  2011-10-09  6:25               ` NamJae Jeon
@ 2011-10-09 14:07                 ` NamJae Jeon
  2011-10-10  8:08                   ` [PATCH 0/6] udf: Change some KERN_<level>s and logging neatening Joe Perches
  0 siblings, 1 reply; 36+ messages in thread
From: NamJae Jeon @ 2011-10-09 14:07 UTC (permalink / raw)
  To: Joe Perches; +Cc: Jan Kara, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1294 bytes --]

2011/10/9 NamJae Jeon <linkinjeon@gmail.com>:
> 2011/10/9 Joe Perches <joe@perches.com>:
>> On Sun, 2011-10-09 at 13:44 +0900, NamJae Jeon wrote:
>>> 2011/10/9 Joe Perches <joe@perches.com>:
>>> > Not a good patch I think.
>>> > You've broken format strings when they should be coalesced
>>> > and the alignment looks odd.
>>> Would you explain more ? I didn't understand your meaning yet.
>>
>> Format strings are allowed to exceed 80 columns.
>> Arguments should be aligned to the open parenthesis
>>
>> For example:
>>        pr_err("some really long format string longer than "
>>                "80 columns and not broken into pieces, Count: %d\n",
>>                count);
>> is better as:
>>        pr_err("some really long format string longer than 80 columns and not broken into pieces, Count: %d\n",
>>               count);
>>
>> Coalesced format strings makes dmesg output easier to grep.
>> count is not indented by 2 tabs, but 1 tab and 7 spaces.
>>
>> There's no hard and fast rule on the indentation.
>>
>> The patch I sent coalesced all format strings and
>> used that alignment style.
> Clear~ I will do it as your guide.
> Thanks very much. joe~

Hi. joe.
I attach v5 patch.
plz review it.
Thanks.
>>
>>
>

[-- Attachment #2: 0001-udf-enable-error-print-in-udf_read_tagged.patch --]
[-- Type: application/octet-stream, Size: 59455 bytes --]

From 0fb1239f662c26b80b62241f7a137485ce523f40 Mon Sep 17 00:00:00 2001
From: Namjae Jeon <linkinjeon@gmail.com>
Date: Sun, 9 Oct 2011 22:54:51 +0900
Subject: [PATCH v5] udf : enable error print in udf_read_tagged().

While reading metadata, if a problem occurs, Print out only one of the five case.(It also does not show a checksum properly.)
Because currently it have been disable by undef udf_debug.
If there is a problem with scratched disc or loader, the user needs to know which error happened.
And I use pr_fmt instead of printk by joe's suggestion. I try to modify totally it to pr_fmt also.

Signed-off-by: Namjae Jeon <linkinjeon@gmail.com>
---
 fs/udf/balloc.c    |   30 +++--
 fs/udf/directory.c |   35 +++--
 fs/udf/file.c      |   11 +-
 fs/udf/inode.c     |   61 +++++----
 fs/udf/lowlevel.c  |    8 +-
 fs/udf/misc.c      |   28 +++--
 fs/udf/namei.c     |   15 +-
 fs/udf/partition.c |   23 ++--
 fs/udf/super.c     |  389 ++++++++++++++++++++++++++++++----------------------
 fs/udf/truncate.c  |   25 ++--
 fs/udf/udfdecl.h   |   43 +++---
 fs/udf/udftime.c   |    2 +-
 fs/udf/unicode.c   |   42 +++---
 13 files changed, 406 insertions(+), 306 deletions(-)

diff --git a/fs/udf/balloc.c b/fs/udf/balloc.c
index 95518a9..8cbc2a1 100644
--- a/fs/udf/balloc.c
+++ b/fs/udf/balloc.c
@@ -59,8 +59,8 @@ static int __load_block_bitmap(struct super_block *sb,
 	int nr_groups = bitmap->s_nr_groups;
 
 	if (block_group >= nr_groups) {
-		udf_debug("block_group (%d) > nr_groups (%d)\n", block_group,
-			  nr_groups);
+		udf_debug(sb, __func__, "block_group (%d) > nr_groups (%d)\n",
+			block_group, nr_groups);
 	}
 
 	if (bitmap->s_block_bitmap[block_group]) {
@@ -125,9 +125,10 @@ static void udf_bitmap_free_blocks(struct super_block *sb,
 	partmap = &sbi->s_partmaps[bloc->partitionReferenceNum];
 	if (bloc->logicalBlockNum + count < count ||
 	    (bloc->logicalBlockNum + count) > partmap->s_partition_len) {
-		udf_debug("%d < %d || %d + %d > %d\n",
-			  bloc->logicalBlockNum, 0, bloc->logicalBlockNum,
-			  count, partmap->s_partition_len);
+		udf_debug(sb, __func__, "%d < %d || %d + %d > %d\n",
+			bloc->logicalBlockNum, 0,
+			bloc->logicalBlockNum, count,
+			partmap->s_partition_len);
 		goto error_return;
 	}
 
@@ -153,8 +154,10 @@ static void udf_bitmap_free_blocks(struct super_block *sb,
 		bh = bitmap->s_block_bitmap[bitmap_nr];
 		for (i = 0; i < count; i++) {
 			if (udf_set_bit(bit + i, bh->b_data)) {
-				udf_debug("bit %ld already set\n", bit + i);
-				udf_debug("byte=%2x\n",
+				udf_debug(sb, __func__,
+					"bit %ld already set\n",
+					bit + i);
+				udf_debug(sb, __func__, "byte=%2x\n",
 					((char *)bh->b_data)[(bit + i) >> 3]);
 			}
 		}
@@ -330,7 +333,8 @@ got_block:
 		(sizeof(struct spaceBitmapDesc) << 3);
 
 	if (!udf_clear_bit(bit, bh->b_data)) {
-		udf_debug("bit already cleared for block %d\n", bit);
+		udf_debug(sb, __func__, "bit already cleared for block %d\n",
+			bit);
 		goto repeat;
 	}
 
@@ -368,9 +372,9 @@ static void udf_table_free_blocks(struct super_block *sb,
 	partmap = &sbi->s_partmaps[bloc->partitionReferenceNum];
 	if (bloc->logicalBlockNum + count < count ||
 	    (bloc->logicalBlockNum + count) > partmap->s_partition_len) {
-		udf_debug("%d < %d || %d + %d > %d\n",
-			  bloc->logicalBlockNum, 0, bloc->logicalBlockNum, count,
-			  partmap->s_partition_len);
+		udf_debug(sb, __func__, "%d < %d || %d + %d > %d\n",
+			bloc->logicalBlockNum, 0, bloc->logicalBlockNum, count,
+			partmap->s_partition_len);
 		goto error_return;
 	}
 
@@ -610,8 +614,8 @@ static int udf_table_prealloc_blocks(struct super_block *sb,
 
 	while (first_block != eloc.logicalBlockNum &&
 	       (etype = udf_next_aext(table, &epos, &eloc, &elen, 1)) != -1) {
-		udf_debug("eloc=%d, elen=%d, first_block=%d\n",
-			  eloc.logicalBlockNum, elen, first_block);
+		udf_debug(sb, __func__, "eloc=%d, elen=%d, first_block=%d\n",
+			eloc.logicalBlockNum, elen, first_block);
 		; /* empty loop body */
 	}
 
diff --git a/fs/udf/directory.c b/fs/udf/directory.c
index 2ffdb67..a89d3ac 100644
--- a/fs/udf/directory.c
+++ b/fs/udf/directory.c
@@ -33,7 +33,7 @@ struct fileIdentDesc *udf_fileident_read(struct inode *dir, loff_t *nf_pos,
 	fibh->soffset = fibh->eoffset;
 
 	if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) {
-		fi = udf_get_fileident(iinfo->i_ext.i_data -
+		fi = udf_get_fileident(dir, iinfo->i_ext.i_data -
 				       (iinfo->i_efe ?
 					sizeof(struct extendedFileEntry) :
 					sizeof(struct fileEntry)),
@@ -98,7 +98,7 @@ struct fileIdentDesc *udf_fileident_read(struct inode *dir, loff_t *nf_pos,
 		fibh->sbh = fibh->ebh;
 	}
 
-	fi = udf_get_fileident(fibh->sbh->b_data, dir->i_sb->s_blocksize,
+	fi = udf_get_fileident(dir, fibh->sbh->b_data, dir->i_sb->s_blocksize,
 			       &(fibh->eoffset));
 
 	if (!fi)
@@ -154,7 +154,8 @@ struct fileIdentDesc *udf_fileident_read(struct inode *dir, loff_t *nf_pos,
 	return fi;
 }
 
-struct fileIdentDesc *udf_get_fileident(void *buffer, int bufsize, int *offset)
+struct fileIdentDesc *udf_get_fileident(struct inode *inode, void *buffer,
+					int bufsize, int *offset)
 {
 	struct fileIdentDesc *fi;
 	int lengthThisIdent;
@@ -162,8 +163,9 @@ struct fileIdentDesc *udf_get_fileident(void *buffer, int bufsize, int *offset)
 	int padlen;
 
 	if ((!buffer) || (!offset)) {
-		udf_debug("invalidparms\n, buffer=%p, offset=%p\n", buffer,
-			  offset);
+		udf_debug(inode->i_sb, __func__,
+			"invalidparms, buffer=%p, offset=%p\n",
+			buffer, offset);
 		return NULL;
 	}
 
@@ -173,11 +175,11 @@ struct fileIdentDesc *udf_get_fileident(void *buffer, int bufsize, int *offset)
 		ptr += *offset;
 	fi = (struct fileIdentDesc *)ptr;
 	if (fi->descTag.tagIdent != cpu_to_le16(TAG_IDENT_FID)) {
-		udf_debug("0x%x != TAG_IDENT_FID\n",
-			  le16_to_cpu(fi->descTag.tagIdent));
-		udf_debug("offset: %u sizeof: %lu bufsize: %u\n",
-			  *offset, (unsigned long)sizeof(struct fileIdentDesc),
-			  bufsize);
+		udf_debug(inode->i_sb, __func__, "0x%x != TAG_IDENT_FID\n",
+			le16_to_cpu(fi->descTag.tagIdent));
+		udf_debug(inode->i_sb, __func__,
+			"offset: %u sizeof: %zu bufsize: %u\n",
+			*offset, sizeof(struct fileIdentDesc), bufsize);
 		return NULL;
 	}
 	if ((*offset + sizeof(struct fileIdentDesc)) > bufsize)
@@ -195,13 +197,14 @@ struct fileIdentDesc *udf_get_fileident(void *buffer, int bufsize, int *offset)
 	return fi;
 }
 
-struct short_ad *udf_get_fileshortad(uint8_t *ptr, int maxoffset, uint32_t *offset,
-			      int inc)
+struct short_ad *udf_get_fileshortad(struct inode *inode, uint8_t *ptr,
+				int maxoffset, uint32_t *offset, int inc)
 {
 	struct short_ad *sa;
 
 	if ((!ptr) || (!offset)) {
-		printk(KERN_ERR "udf: udf_get_fileshortad() invalidparms\n");
+		udf_err(inode->i_sb, __func__,
+			"udf_get_fileshortad() invalidparms\n");
 		return NULL;
 	}
 
@@ -218,12 +221,14 @@ struct short_ad *udf_get_fileshortad(uint8_t *ptr, int maxoffset, uint32_t *offs
 	return sa;
 }
 
-struct long_ad *udf_get_filelongad(uint8_t *ptr, int maxoffset, uint32_t *offset, int inc)
+struct long_ad *udf_get_filelongad(struct inode *inode, uint8_t *ptr,
+				int maxoffset, uint32_t *offset, int inc)
 {
 	struct long_ad *la;
 
 	if ((!ptr) || (!offset)) {
-		printk(KERN_ERR "udf: udf_get_filelongad() invalidparms\n");
+		udf_err(inode->i_sb, __func__,
+			"udf_get_filelongad() invalidparms\n");
 		return NULL;
 	}
 
diff --git a/fs/udf/file.c b/fs/udf/file.c
index d8ffa7c..fccca11 100644
--- a/fs/udf/file.c
+++ b/fs/udf/file.c
@@ -124,7 +124,9 @@ static ssize_t udf_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
 						pos + count)) {
 			err = udf_expand_file_adinicb(inode);
 			if (err) {
-				udf_debug("udf_expand_adinicb: err=%d\n", err);
+				udf_debug(inode->i_sb, __func__,
+					"udf_expand_adinicb: err=%d\n",
+					err);
 				up_write(&iinfo->i_data_sem);
 				return err;
 			}
@@ -151,13 +153,16 @@ long udf_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 	int result = -EINVAL;
 
 	if (inode_permission(inode, MAY_READ) != 0) {
-		udf_debug("no permission to access inode %lu\n", inode->i_ino);
+		udf_debug(inode->i_sb, __func__,
+			"no permission to access inode %lu\n",
+			inode->i_ino);
 		result = -EPERM;
 		goto out;
 	}
 
 	if (!arg) {
-		udf_debug("invalid argument to udf_ioctl\n");
+		udf_debug(inode->i_sb, __func__,
+			"invalid argument to udf_ioctl\n");
 		result = -EINVAL;
 		goto out;
 	}
diff --git a/fs/udf/inode.c b/fs/udf/inode.c
index 1d1358e..bd0afa0 100644
--- a/fs/udf/inode.c
+++ b/fs/udf/inode.c
@@ -83,10 +83,10 @@ void udf_evict_inode(struct inode *inode)
 	end_writeback(inode);
 	if (iinfo->i_alloc_type != ICBTAG_FLAG_AD_IN_ICB &&
 	    inode->i_size != iinfo->i_lenExtents) {
-		printk(KERN_WARNING "UDF-fs (%s): Inode %lu (mode %o) has "
+		udf_warn(inode->i_sb, __func__, "Inode %lu (mode %o) has "
 			"inode size %llu different from extent length %llu. "
 			"Filesystem need not be standards compliant.\n",
-			inode->i_sb->s_id, inode->i_ino, inode->i_mode,
+			inode->i_ino, inode->i_mode,
 			(unsigned long long)inode->i_size,
 			(unsigned long long)iinfo->i_lenExtents);
 	}
@@ -1169,16 +1169,18 @@ static void __udf_read_inode(struct inode *inode)
 	 */
 	bh = udf_read_ptagged(inode->i_sb, &iinfo->i_location, 0, &ident);
 	if (!bh) {
-		printk(KERN_ERR "udf: udf_read_inode(ino %ld) failed !bh\n",
-		       inode->i_ino);
+		udf_err(inode->i_sb, __func__, "udf_read_inode(ino %ld) "
+			"failed !bh\n",
+			inode->i_ino);
 		make_bad_inode(inode);
 		return;
 	}
 
 	if (ident != TAG_IDENT_FE && ident != TAG_IDENT_EFE &&
 	    ident != TAG_IDENT_USE) {
-		printk(KERN_ERR "udf: udf_read_inode(ino %ld) "
-				"failed ident=%d\n", inode->i_ino, ident);
+		udf_err(inode->i_sb, __func__, "udf_read_inode(ino %ld) "
+			"failed ident=%d\n",
+			inode->i_ino, ident);
 		brelse(bh);
 		make_bad_inode(inode);
 		return;
@@ -1218,8 +1220,9 @@ static void __udf_read_inode(struct inode *inode)
 		}
 		brelse(ibh);
 	} else if (fe->icbTag.strategyType != cpu_to_le16(4)) {
-		printk(KERN_ERR "udf: unsupported strategy type: %d\n",
-		       le16_to_cpu(fe->icbTag.strategyType));
+		udf_err(inode->i_sb, __func__, "unsupported strategy "
+			"type: %d\n",
+			le16_to_cpu(fe->icbTag.strategyType));
 		brelse(bh);
 		make_bad_inode(inode);
 		return;
@@ -1404,18 +1407,18 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh)
 		inode->i_mode = S_IFLNK | S_IRWXUGO;
 		break;
 	case ICBTAG_FILE_TYPE_MAIN:
-		udf_debug("METADATA FILE-----\n");
+		udf_debug(inode->i_sb, __func__, "METADATA FILE-----\n");
 		break;
 	case ICBTAG_FILE_TYPE_MIRROR:
-		udf_debug("METADATA MIRROR FILE-----\n");
+		udf_debug(inode->i_sb, __func__, "METADATA MIRROR FILE-----\n");
 		break;
 	case ICBTAG_FILE_TYPE_BITMAP:
-		udf_debug("METADATA BITMAP FILE-----\n");
+		udf_debug(inode->i_sb, __func__, "METADATA BITMAP FILE-----\n");
 		break;
 	default:
-		printk(KERN_ERR "udf: udf_fill_inode(ino %ld) failed unknown "
-				"file type=%d\n", inode->i_ino,
-				fe->icbTag.fileType);
+		udf_err(inode->i_sb, __func__, "udf_fill_inode(ino %ld) "
+			"failed unknown file type=%d\n",
+			inode->i_ino, fe->icbTag.fileType);
 		make_bad_inode(inode);
 		return;
 	}
@@ -1438,8 +1441,9 @@ static int udf_alloc_i_data(struct inode *inode, size_t size)
 	iinfo->i_ext.i_data = kmalloc(size, GFP_KERNEL);
 
 	if (!iinfo->i_ext.i_data) {
-		printk(KERN_ERR "udf:udf_alloc_i_data (ino %ld) "
-				"no free memory\n", inode->i_ino);
+		udf_err(inode->i_sb, __func__, "udf_alloc_i_data (ino %ld) "
+			"no free memory\n",
+			inode->i_ino);
 		return -ENOMEM;
 	}
 
@@ -1491,7 +1495,7 @@ static int udf_update_inode(struct inode *inode, int do_sync)
 	bh = udf_tgetblk(inode->i_sb,
 			udf_get_lb_pblock(inode->i_sb, &iinfo->i_location, 0));
 	if (!bh) {
-		udf_debug("getblk failure\n");
+		udf_debug(inode->i_sb, __func__, "getblk failure\n");
 		return -ENOMEM;
 	}
 
@@ -1689,9 +1693,9 @@ out:
 	if (do_sync) {
 		sync_dirty_buffer(bh);
 		if (buffer_write_io_error(bh)) {
-			printk(KERN_WARNING "IO error syncing udf inode "
-				"[%s:%08lx]\n", inode->i_sb->s_id,
-				inode->i_ino);
+			udf_warn(inode->i_sb, __func__, "IO error syncing udf "
+				"inode [%s:%08lx]\n",
+				inode->i_sb->s_id, inode->i_ino);
 			err = -EIO;
 		}
 	}
@@ -1719,8 +1723,8 @@ struct inode *udf_iget(struct super_block *sb, struct kernel_lb_addr *ino)
 
 	if (ino->logicalBlockNum >= UDF_SB(sb)->
 			s_partmaps[ino->partitionReferenceNum].s_partition_len) {
-		udf_debug("block=%d, partition=%d out of range\n",
-			  ino->logicalBlockNum, ino->partitionReferenceNum);
+		udf_debug(sb, __func__, "block=%d, partition=%d out of range\n",
+			ino->logicalBlockNum, ino->partitionReferenceNum);
 		make_bad_inode(inode);
 		goto out_iput;
 	}
@@ -1927,7 +1931,9 @@ int8_t udf_next_aext(struct inode *inode, struct extent_position *epos,
 		block = udf_get_lb_pblock(inode->i_sb, &epos->block, 0);
 		epos->bh = udf_tread(inode->i_sb, block);
 		if (!epos->bh) {
-			udf_debug("reading block %d failed!\n", block);
+			udf_debug(inode->i_sb, __func__,
+				"reading block %d failed!\n",
+				block);
 			return -1;
 		}
 	}
@@ -1964,7 +1970,7 @@ int8_t udf_current_aext(struct inode *inode, struct extent_position *epos,
 
 	switch (iinfo->i_alloc_type) {
 	case ICBTAG_FLAG_AD_SHORT:
-		sad = udf_get_fileshortad(ptr, alen, &epos->offset, inc);
+		sad = udf_get_fileshortad(inode, ptr, alen, &epos->offset, inc);
 		if (!sad)
 			return -1;
 		etype = le32_to_cpu(sad->extLength) >> 30;
@@ -1974,7 +1980,7 @@ int8_t udf_current_aext(struct inode *inode, struct extent_position *epos,
 		*elen = le32_to_cpu(sad->extLength) & UDF_EXTENT_LENGTH_MASK;
 		break;
 	case ICBTAG_FLAG_AD_LONG:
-		lad = udf_get_filelongad(ptr, alen, &epos->offset, inc);
+		lad = udf_get_filelongad(inode, ptr, alen, &epos->offset, inc);
 		if (!lad)
 			return -1;
 		etype = le32_to_cpu(lad->extLength) >> 30;
@@ -1982,8 +1988,9 @@ int8_t udf_current_aext(struct inode *inode, struct extent_position *epos,
 		*elen = le32_to_cpu(lad->extLength) & UDF_EXTENT_LENGTH_MASK;
 		break;
 	default:
-		udf_debug("alloc_type = %d unsupported\n",
-				iinfo->i_alloc_type);
+		udf_debug(inode->i_sb, __func__,
+			"alloc_type = %d unsupported\n",
+			iinfo->i_alloc_type);
 		return -1;
 	}
 
diff --git a/fs/udf/lowlevel.c b/fs/udf/lowlevel.c
index 43e24a3..4f6e689 100644
--- a/fs/udf/lowlevel.c
+++ b/fs/udf/lowlevel.c
@@ -37,12 +37,14 @@ unsigned int udf_get_last_session(struct super_block *sb)
 	i = ioctl_by_bdev(bdev, CDROMMULTISESSION, (unsigned long)&ms_info);
 
 	if (i == 0) {
-		udf_debug("XA disk: %s, vol_desc_start=%d\n",
-			  (ms_info.xa_flag ? "yes" : "no"), ms_info.addr.lba);
+		udf_debug(sb, __func__, "XA disk: %s, vol_desc_start=%d\n",
+			(ms_info.xa_flag ? "yes" : "no"), ms_info.addr.lba);
 		if (ms_info.xa_flag) /* necessary for a valid ms_info.addr */
 			vol_desc_start = ms_info.addr.lba;
 	} else {
-		udf_debug("CDROMMULTISESSION not supported: rc=%d\n", i);
+		udf_debug(sb, __func__,
+			"CDROMMULTISESSION not supported: rc=%d\n",
+			i);
 	}
 	return vol_desc_start;
 }
diff --git a/fs/udf/misc.c b/fs/udf/misc.c
index 9215700..45d4b4c 100644
--- a/fs/udf/misc.c
+++ b/fs/udf/misc.c
@@ -204,6 +204,7 @@ struct buffer_head *udf_read_tagged(struct super_block *sb, uint32_t block,
 {
 	struct tag *tag_p;
 	struct buffer_head *bh = NULL;
+	u8 checksum;
 
 	/* Read the block */
 	if (block == 0xFFFFFFFF)
@@ -211,8 +212,8 @@ struct buffer_head *udf_read_tagged(struct super_block *sb, uint32_t block,
 
 	bh = udf_tread(sb, block);
 	if (!bh) {
-		udf_debug("block=%d, location=%d: read failed\n",
-			  block, location);
+		udf_err(sb, __func__, "block=%d, location=%d: read failed\n",
+			block, location);
 		return NULL;
 	}
 
@@ -221,22 +222,27 @@ struct buffer_head *udf_read_tagged(struct super_block *sb, uint32_t block,
 	*ident = le16_to_cpu(tag_p->tagIdent);
 
 	if (location != le32_to_cpu(tag_p->tagLocation)) {
-		udf_debug("location mismatch block %u, tag %u != %u\n",
-			  block, le32_to_cpu(tag_p->tagLocation), location);
+		udf_err(sb, __func__,
+			"location mismatch block %u, tag %u != %u\n",
+			block, le32_to_cpu(tag_p->tagLocation), location);
 		goto error_out;
 	}
 
 	/* Verify the tag checksum */
-	if (udf_tag_checksum(tag_p) != tag_p->tagChecksum) {
-		printk(KERN_ERR "udf: tag checksum failed block %d\n", block);
+	checksum = udf_tag_checksum(tag_p);
+	if (checksum != tag_p->tagChecksum) {
+		udf_err(sb, __func__,
+			"tag checksum failed block %d, checksum 0x%02x != 0x%02x\n",
+			block, checksum, tag_p->tagChecksum);
 		goto error_out;
 	}
 
 	/* Verify the tag version */
 	if (tag_p->descVersion != cpu_to_le16(0x0002U) &&
 	    tag_p->descVersion != cpu_to_le16(0x0003U)) {
-		udf_debug("tag version 0x%04x != 0x0002 || 0x0003 block %d\n",
-			  le16_to_cpu(tag_p->descVersion), block);
+		udf_err(sb, __func__,
+			"tag version 0x%04x != 0x0002 || 0x0003 block %d\n",
+			le16_to_cpu(tag_p->descVersion), block);
 		goto error_out;
 	}
 
@@ -247,8 +253,10 @@ struct buffer_head *udf_read_tagged(struct super_block *sb, uint32_t block,
 					le16_to_cpu(tag_p->descCRCLength)))
 		return bh;
 
-	udf_debug("Crc failure block %d: crc = %d, crclen = %d\n", block,
-	    le16_to_cpu(tag_p->descCRC), le16_to_cpu(tag_p->descCRCLength));
+	udf_err(sb, __func__,
+		"Crc failure block %d: crc = %d, crclen = %d\n",
+		block, le16_to_cpu(tag_p->descCRC),
+		le16_to_cpu(tag_p->descCRCLength));
 
 error_out:
 	brelse(bh);
diff --git a/fs/udf/namei.c b/fs/udf/namei.c
index f1dce84..f2a1614 100644
--- a/fs/udf/namei.c
+++ b/fs/udf/namei.c
@@ -799,9 +799,9 @@ static int udf_rmdir(struct inode *dir, struct dentry *dentry)
 	if (retval)
 		goto end_rmdir;
 	if (inode->i_nlink != 2)
-		udf_warning(inode->i_sb, "udf_rmdir",
-			    "empty directory has nlink != 2 (%d)",
-			    inode->i_nlink);
+		udf_warn(inode->i_sb, __func__,
+			"empty directory has nlink != 2 (%d)\n",
+			inode->i_nlink);
 	clear_nlink(inode);
 	inode->i_size = 0;
 	inode_dec_link_count(dir);
@@ -838,8 +838,9 @@ static int udf_unlink(struct inode *dir, struct dentry *dentry)
 		goto end_unlink;
 
 	if (!inode->i_nlink) {
-		udf_debug("Deleting nonexistent file (%lu), %d\n",
-			  inode->i_ino, inode->i_nlink);
+		udf_debug(dir->i_sb, __func__,
+			"Deleting nonexistent file (%lu), %d\n",
+			inode->i_ino, inode->i_nlink);
 		inode->i_nlink = 1;
 	}
 	retval = udf_delete_entry(dir, fi, &fibh, &cfi);
@@ -1111,7 +1112,7 @@ static int udf_rename(struct inode *old_dir, struct dentry *old_dentry,
 		}
 		retval = -EIO;
 		if (old_iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) {
-			dir_fi = udf_get_fileident(
+			dir_fi = udf_get_fileident(old_inode,
 					old_iinfo->i_ext.i_data -
 					  (old_iinfo->i_efe ?
 					   sizeof(struct extendedFileEntry) :
@@ -1121,7 +1122,7 @@ static int udf_rename(struct inode *old_dir, struct dentry *old_dentry,
 			dir_bh = udf_bread(old_inode, 0, 0, &retval);
 			if (!dir_bh)
 				goto end_rename;
-			dir_fi = udf_get_fileident(dir_bh->b_data,
+			dir_fi = udf_get_fileident(old_inode, dir_bh->b_data,
 					old_inode->i_sb->s_blocksize, &offset);
 		}
 		if (!dir_fi)
diff --git a/fs/udf/partition.c b/fs/udf/partition.c
index a71090e..5fb4dcf 100644
--- a/fs/udf/partition.c
+++ b/fs/udf/partition.c
@@ -33,8 +33,9 @@ uint32_t udf_get_pblock(struct super_block *sb, uint32_t block,
 	struct udf_sb_info *sbi = UDF_SB(sb);
 	struct udf_part_map *map;
 	if (partition >= sbi->s_partitions) {
-		udf_debug("block=%d, partition=%d, offset=%d: "
-			  "invalid partition\n", block, partition, offset);
+		udf_debug(sb, __func__,
+			"block=%d, partition=%d, offset=%d: invalid partition\n",
+			block, partition, offset);
 		return 0xFFFFFFFF;
 	}
 	map = &sbi->s_partmaps[partition];
@@ -60,8 +61,9 @@ uint32_t udf_get_pblock_virt15(struct super_block *sb, uint32_t block,
 	vdata = &map->s_type_specific.s_virtual;
 
 	if (block > vdata->s_num_entries) {
-		udf_debug("Trying to access block beyond end of VAT "
-			  "(%d max %d)\n", block, vdata->s_num_entries);
+		udf_debug(sb, __func__,
+			"Trying to access block beyond end of VAT (%d max %d)\n",
+			block, vdata->s_num_entries);
 		return 0xFFFFFFFF;
 	}
 
@@ -84,8 +86,9 @@ uint32_t udf_get_pblock_virt15(struct super_block *sb, uint32_t block,
 
 	bh = sb_bread(sb, loc);
 	if (!bh) {
-		udf_debug("get_pblock(UDF_VIRTUAL_MAP:%p,%d,%d) VAT: %d[%d]\n",
-			  sb, block, partition, loc, index);
+		udf_debug(sb, __func__,
+			"get_pblock(UDF_VIRTUAL_MAP:%p,%d,%d) VAT: %d[%d]\n",
+			sb, block, partition, loc, index);
 		return 0xFFFFFFFF;
 	}
 
@@ -95,7 +98,7 @@ uint32_t udf_get_pblock_virt15(struct super_block *sb, uint32_t block,
 
 translate:
 	if (iinfo->i_location.partitionReferenceNum == partition) {
-		udf_debug("recursive call to udf_get_pblock!\n");
+		udf_debug(sb, __func__, "recursive call to udf_get_pblock!\n");
 		return 0xFFFFFFFF;
 	}
 
@@ -312,7 +315,7 @@ uint32_t udf_get_pblock_meta25(struct super_block *sb, uint32_t block,
 	uint32_t retblk;
 	struct inode *inode;
 
-	udf_debug("READING from METADATA\n");
+	udf_debug(sb, __func__, "READING from METADATA\n");
 
 	map = &sbi->s_partmaps[partition];
 	mdata = &map->s_type_specific.s_metadata;
@@ -322,8 +325,8 @@ uint32_t udf_get_pblock_meta25(struct super_block *sb, uint32_t block,
 	BUG_ON(!inode);
 	retblk = udf_try_read_meta(inode, block, partition, offset);
 	if (retblk == 0xFFFFFFFF) {
-		udf_warning(sb, __func__, "error reading from METADATA, "
-			"trying to read from MIRROR");
+		udf_warn(sb, __func__,
+			"error reading from METADATA, trying to read from MIRROR");
 		inode = mdata->s_mirror_fe;
 		if (!inode)
 			return 0xFFFFFFFF;
diff --git a/fs/udf/super.c b/fs/udf/super.c
index 7b27b06..a12cd28 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -75,8 +75,6 @@
 
 #define UDF_DEFAULT_BLOCKSIZE 2048
 
-static char error_buf[1024];
-
 /* These are the "meat" - everything else is stuffing */
 static int udf_fill_super(struct super_block *, void *, int);
 static void udf_put_super(struct super_block *);
@@ -92,8 +90,6 @@ static void udf_close_lvid(struct super_block *);
 static unsigned int udf_count_free(struct super_block *);
 static int udf_statfs(struct dentry *, struct kstatfs *);
 static int udf_show_options(struct seq_file *, struct vfsmount *);
-static void udf_error(struct super_block *sb, const char *function,
-		      const char *fmt, ...);
 
 struct logicalVolIntegrityDescImpUse *udf_sb_lvidiu(struct udf_sb_info *sbi)
 {
@@ -244,9 +240,9 @@ static int udf_sb_alloc_partition_maps(struct super_block *sb, u32 count)
 	sbi->s_partmaps = kcalloc(count, sizeof(struct udf_part_map),
 				  GFP_KERNEL);
 	if (!sbi->s_partmaps) {
-		udf_error(sb, __func__,
-			  "Unable to allocate space for %d partition maps",
-			  count);
+		udf_err(sb, __func__,
+			"Unable to allocate space for %d partition maps",
+			count);
 		sbi->s_partitions = 0;
 		return -ENOMEM;
 	}
@@ -405,8 +401,8 @@ static const match_table_t tokens = {
 	{Opt_err,	NULL}
 };
 
-static int udf_parse_options(char *options, struct udf_options *uopt,
-			     bool remount)
+static int udf_parse_options(struct super_block *sb, char *options,
+				struct udf_options *uopt, bool remount)
 {
 	char *p;
 	int option;
@@ -550,8 +546,9 @@ static int udf_parse_options(char *options, struct udf_options *uopt,
 			uopt->dmode = option & 0777;
 			break;
 		default:
-			printk(KERN_ERR "udf: bad mount option \"%s\" "
-			       "or missing value\n", p);
+			udf_err(sb, __func__,
+				"bad mount option \"%s\" or missing value\n",
+				p);
 			return 0;
 		}
 	}
@@ -571,7 +568,7 @@ static int udf_remount_fs(struct super_block *sb, int *flags, char *options)
 	uopt.fmode = sbi->s_fmode;
 	uopt.dmode = sbi->s_dmode;
 
-	if (!udf_parse_options(options, &uopt, true))
+	if (!udf_parse_options(sb, options, &uopt, true))
 		return -EINVAL;
 
 	write_lock(&sbi->s_cred_lock);
@@ -621,9 +618,9 @@ static loff_t udf_check_vsd(struct super_block *sb)
 
 	sector += (sbi->s_session << sb->s_blocksize_bits);
 
-	udf_debug("Starting at sector %u (%ld byte sectors)\n",
-		  (unsigned int)(sector >> sb->s_blocksize_bits),
-		  sb->s_blocksize);
+	udf_debug(sb, __func__, "Starting at sector %u (%ld byte sectors)\n",
+		(unsigned int)(sector >> sb->s_blocksize_bits),
+		sb->s_blocksize);
 	/* Process the sequence (if applicable) */
 	for (; !nsr02 && !nsr03; sector += sectorsize) {
 		/* Read a block */
@@ -642,27 +639,29 @@ static loff_t udf_check_vsd(struct super_block *sb)
 				    VSD_STD_ID_LEN)) {
 			switch (vsd->structType) {
 			case 0:
-				udf_debug("ISO9660 Boot Record found\n");
+				udf_debug(sb, __func__,
+					"ISO9660 Boot Record found\n");
 				break;
 			case 1:
-				udf_debug("ISO9660 Primary Volume Descriptor "
-					  "found\n");
+				udf_debug(sb, __func__,
+					"ISO9660 Primary Volume Descriptor found\n");
 				break;
 			case 2:
-				udf_debug("ISO9660 Supplementary Volume "
-					  "Descriptor found\n");
+				udf_debug(sb, __func__,
+					"ISO9660 Supplementary Volume Descriptor found\n");
 				break;
 			case 3:
-				udf_debug("ISO9660 Volume Partition Descriptor "
-					  "found\n");
+				udf_debug(sb, __func__,
+					"ISO9660 Volume Partition Descriptor found\n");
 				break;
 			case 255:
-				udf_debug("ISO9660 Volume Descriptor Set "
-					  "Terminator found\n");
+				udf_debug(sb, __func__,
+					"ISO9660 Volume Descriptor Set Terminator found\n");
 				break;
 			default:
-				udf_debug("ISO9660 VRS (%u) found\n",
-					  vsd->structType);
+				udf_debug(sb, __func__,
+					"ISO9660 VRS (%u) found\n",
+					vsd->structType);
 				break;
 			}
 		} else if (!strncmp(vsd->stdIdent, VSD_STD_ID_BEA01,
@@ -769,9 +768,9 @@ static int udf_find_fileset(struct super_block *sb,
 
 	if ((fileset->logicalBlockNum != 0xFFFFFFFF ||
 	     fileset->partitionReferenceNum != 0xFFFF) && bh) {
-		udf_debug("Fileset at block=%d, partition=%d\n",
-			  fileset->logicalBlockNum,
-			  fileset->partitionReferenceNum);
+		udf_debug(sb, __func__, "Fileset at block=%d, partition=%d\n",
+			fileset->logicalBlockNum,
+			fileset->partitionReferenceNum);
 
 		sbi->s_partition = fileset->partitionReferenceNum;
 		udf_load_fileset(sb, bh, root);
@@ -809,24 +808,25 @@ static int udf_load_pvoldesc(struct super_block *sb, sector_t block)
 			      pvoldesc->recordingDateAndTime)) {
 #ifdef UDFFS_DEBUG
 		struct timestamp *ts = &pvoldesc->recordingDateAndTime;
-		udf_debug("recording time %04u/%02u/%02u"
-			  " %02u:%02u (%x)\n",
-			  le16_to_cpu(ts->year), ts->month, ts->day, ts->hour,
-			  ts->minute, le16_to_cpu(ts->typeAndTimezone));
+		udf_debug(sb, __func__,
+			"recording time %04u/%02u/%02u %02u:%02u (%x)\n",
+			le16_to_cpu(ts->year), ts->month, ts->day, ts->hour,
+			ts->minute, le16_to_cpu(ts->typeAndTimezone));
 #endif
 	}
 
 	if (!udf_build_ustr(instr, pvoldesc->volIdent, 32))
-		if (udf_CS0toUTF8(outstr, instr)) {
+		if (udf_CS0toUTF8(sb, outstr, instr)) {
 			strncpy(UDF_SB(sb)->s_volume_ident, outstr->u_name,
 				outstr->u_len > 31 ? 31 : outstr->u_len);
-			udf_debug("volIdent[] = '%s'\n",
-					UDF_SB(sb)->s_volume_ident);
+			udf_debug(sb, __func__, "volIdent[] = '%s'\n",
+				UDF_SB(sb)->s_volume_ident);
 		}
 
 	if (!udf_build_ustr(instr, pvoldesc->volSetIdent, 128))
-		if (udf_CS0toUTF8(outstr, instr))
-			udf_debug("volSetIdent[] = '%s'\n", outstr->u_name);
+		if (udf_CS0toUTF8(sb, outstr, instr))
+			udf_debug(sb, __func__,
+				"volSetIdent[] = '%s'\n", outstr->u_name);
 
 	brelse(bh);
 	ret = 0;
@@ -852,19 +852,20 @@ static int udf_load_metadata_files(struct super_block *sb, int partition)
 	addr.logicalBlockNum =  mdata->s_meta_file_loc;
 	addr.partitionReferenceNum = map->s_partition_num;
 
-	udf_debug("Metadata file location: block = %d part = %d\n",
-			  addr.logicalBlockNum, addr.partitionReferenceNum);
+	udf_debug(sb, __func__,
+		"Metadata file location: block = %d part = %d\n",
+		addr.logicalBlockNum, addr.partitionReferenceNum);
 
 	mdata->s_metadata_fe = udf_iget(sb, &addr);
 
 	if (mdata->s_metadata_fe == NULL) {
-		udf_warning(sb, __func__, "metadata inode efe not found, "
-				"will try mirror inode.");
+		udf_warn(sb, __func__,
+			"metadata inode efe not found, will try mirror inode.");
 		fe_error = 1;
 	} else if (UDF_I(mdata->s_metadata_fe)->i_alloc_type !=
 		 ICBTAG_FLAG_AD_SHORT) {
-		udf_warning(sb, __func__, "metadata inode efe does not have "
-			"short allocation descriptors!");
+		udf_warn(sb, __func__,
+			"metadata inode efe does not have short allocation descriptors!");
 		fe_error = 1;
 		iput(mdata->s_metadata_fe);
 		mdata->s_metadata_fe = NULL;
@@ -874,23 +875,24 @@ static int udf_load_metadata_files(struct super_block *sb, int partition)
 	addr.logicalBlockNum = mdata->s_mirror_file_loc;
 	addr.partitionReferenceNum = map->s_partition_num;
 
-	udf_debug("Mirror metadata file location: block = %d part = %d\n",
-			  addr.logicalBlockNum, addr.partitionReferenceNum);
+	udf_debug(sb, __func__,
+		"Mirror metadata file location: block = %d part = %d\n",
+		addr.logicalBlockNum, addr.partitionReferenceNum);
 
 	mdata->s_mirror_fe = udf_iget(sb, &addr);
 
 	if (mdata->s_mirror_fe == NULL) {
 		if (fe_error) {
-			udf_error(sb, __func__, "mirror inode efe not found "
-			"and metadata inode is missing too, exiting...");
+			udf_err(sb, __func__,
+				"mirror inode efe not found and metadata inode is missing too, exiting...");
 			goto error_exit;
 		} else
-			udf_warning(sb, __func__, "mirror inode efe not found,"
-					" but metadata inode is OK");
+			udf_warn(sb, __func__,
+				"mirror inode efe not found, but metadata inode is OK");
 	} else if (UDF_I(mdata->s_mirror_fe)->i_alloc_type !=
 		 ICBTAG_FLAG_AD_SHORT) {
-		udf_warning(sb, __func__, "mirror inode efe does not have "
-			"short allocation descriptors!");
+		udf_warn(sb, __func__,
+			"mirror inode efe does not have short allocation descriptors!");
 		iput(mdata->s_mirror_fe);
 		mdata->s_mirror_fe = NULL;
 		if (fe_error)
@@ -906,25 +908,25 @@ static int udf_load_metadata_files(struct super_block *sb, int partition)
 		addr.logicalBlockNum = mdata->s_bitmap_file_loc;
 		addr.partitionReferenceNum = map->s_partition_num;
 
-		udf_debug("Bitmap file location: block = %d part = %d\n",
+		udf_debug(sb, __func__,
+			"Bitmap file location: block = %d part = %d\n",
 			addr.logicalBlockNum, addr.partitionReferenceNum);
 
 		mdata->s_bitmap_fe = udf_iget(sb, &addr);
 
 		if (mdata->s_bitmap_fe == NULL) {
 			if (sb->s_flags & MS_RDONLY)
-				udf_warning(sb, __func__, "bitmap inode efe "
-					"not found but it's ok since the disc"
-					" is mounted read-only");
+				udf_warn(sb, __func__,
+					"bitmap inode efe not found but it's ok since the disc is mounted read-only");
 			else {
-				udf_error(sb, __func__, "bitmap inode efe not "
-					"found and attempted read-write mount");
+				udf_err(sb, __func__,
+					"bitmap inode efe not found and attempted read-write mount");
 				goto error_exit;
 			}
 		}
 	}
 
-	udf_debug("udf_load_metadata_files Ok\n");
+	udf_debug(sb, __func__, "udf_load_metadata_files Ok\n");
 
 	return 0;
 
@@ -943,8 +945,8 @@ static void udf_load_fileset(struct super_block *sb, struct buffer_head *bh,
 
 	UDF_SB(sb)->s_serial_number = le16_to_cpu(fset->descTag.tagSerialNum);
 
-	udf_debug("Rootdir at block=%d, partition=%d\n",
-		  root->logicalBlockNum, root->partitionReferenceNum);
+	udf_debug(sb, __func__, "Rootdir at block=%d, partition=%d\n",
+		root->logicalBlockNum, root->partitionReferenceNum);
 }
 
 int udf_compute_nr_groups(struct super_block *sb, u32 partition)
@@ -971,9 +973,9 @@ static struct udf_bitmap *udf_sb_alloc_bitmap(struct super_block *sb, u32 index)
 		bitmap = vzalloc(size); /* TODO: get rid of vzalloc */
 
 	if (bitmap == NULL) {
-		udf_error(sb, __func__,
-			  "Unable to allocate space for bitmap "
-			  "and %d buffer_head pointers", nr_groups);
+		udf_err(sb, __func__,
+			"Unable to allocate space for bitmap and %d buffer_head pointers\n",
+			nr_groups);
 		return NULL;
 	}
 
@@ -1003,10 +1005,10 @@ static int udf_fill_partdesc_info(struct super_block *sb,
 	if (p->accessType == cpu_to_le32(PD_ACCESS_TYPE_OVERWRITABLE))
 		map->s_partition_flags |= UDF_PART_FLAG_OVERWRITABLE;
 
-	udf_debug("Partition (%d type %x) starts at physical %d, "
-		  "block length %d\n", p_index,
-		  map->s_partition_type, map->s_partition_root,
-		  map->s_partition_len);
+	udf_debug(sb, __func__,
+		"Partition (%d type %x) starts at physical %d, block length %d\n",
+		p_index, map->s_partition_type,
+		map->s_partition_root, map->s_partition_len);
 
 	if (strcmp(p->partitionContents.ident, PD_PARTITION_CONTENTS_NSR02) &&
 	    strcmp(p->partitionContents.ident, PD_PARTITION_CONTENTS_NSR03))
@@ -1022,13 +1024,14 @@ static int udf_fill_partdesc_info(struct super_block *sb,
 
 		map->s_uspace.s_table = udf_iget(sb, &loc);
 		if (!map->s_uspace.s_table) {
-			udf_debug("cannot load unallocSpaceTable (part %d)\n",
-					p_index);
+			udf_debug(sb, __func__,
+				"cannot load unallocSpaceTable (part %d)\n",
+				p_index);
 			return 1;
 		}
 		map->s_partition_flags |= UDF_PART_FLAG_UNALLOC_TABLE;
-		udf_debug("unallocSpaceTable (part %d) @ %ld\n",
-				p_index, map->s_uspace.s_table->i_ino);
+		udf_debug(sb, __func__, "unallocSpaceTable (part %d) @ %ld\n",
+			p_index, map->s_uspace.s_table->i_ino);
 	}
 
 	if (phd->unallocSpaceBitmap.extLength) {
@@ -1041,12 +1044,14 @@ static int udf_fill_partdesc_info(struct super_block *sb,
 		bitmap->s_extPosition = le32_to_cpu(
 				phd->unallocSpaceBitmap.extPosition);
 		map->s_partition_flags |= UDF_PART_FLAG_UNALLOC_BITMAP;
-		udf_debug("unallocSpaceBitmap (part %d) @ %d\n", p_index,
-						bitmap->s_extPosition);
+		udf_debug(sb, __func__, "unallocSpaceBitmap (part %d) @ %d\n",
+			p_index, bitmap->s_extPosition);
 	}
 
 	if (phd->partitionIntegrityTable.extLength)
-		udf_debug("partitionIntegrityTable (part %d)\n", p_index);
+		udf_debug(sb, __func__,
+			"partitionIntegrityTable (part %d)\n",
+			p_index);
 
 	if (phd->freedSpaceTable.extLength) {
 		struct kernel_lb_addr loc = {
@@ -1057,14 +1062,15 @@ static int udf_fill_partdesc_info(struct super_block *sb,
 
 		map->s_fspace.s_table = udf_iget(sb, &loc);
 		if (!map->s_fspace.s_table) {
-			udf_debug("cannot load freedSpaceTable (part %d)\n",
+			udf_debug(sb, __func__,
+				"cannot load freedSpaceTable (part %d)\n",
 				p_index);
 			return 1;
 		}
 
 		map->s_partition_flags |= UDF_PART_FLAG_FREED_TABLE;
-		udf_debug("freedSpaceTable (part %d) @ %ld\n",
-				p_index, map->s_fspace.s_table->i_ino);
+		udf_debug(sb, __func__, "freedSpaceTable (part %d) @ %ld\n",
+			p_index, map->s_fspace.s_table->i_ino);
 	}
 
 	if (phd->freedSpaceBitmap.extLength) {
@@ -1077,8 +1083,8 @@ static int udf_fill_partdesc_info(struct super_block *sb,
 		bitmap->s_extPosition = le32_to_cpu(
 				phd->freedSpaceBitmap.extPosition);
 		map->s_partition_flags |= UDF_PART_FLAG_FREED_BITMAP;
-		udf_debug("freedSpaceBitmap (part %d) @ %d\n", p_index,
-					bitmap->s_extPosition);
+		udf_debug(sb, __func__, "freedSpaceBitmap (part %d) @ %d\n",
+			p_index, bitmap->s_extPosition);
 	}
 	return 0;
 }
@@ -1118,11 +1124,10 @@ static int udf_load_vat(struct super_block *sb, int p_index, int type1_index)
 	udf_find_vat_block(sb, p_index, type1_index, sbi->s_last_block);
 	if (!sbi->s_vat_inode &&
 	    sbi->s_last_block != blocks - 1) {
-		printk(KERN_NOTICE "UDF-fs: Failed to read VAT inode from the"
-		       " last recorded block (%lu), retrying with the last "
-		       "block of the device (%lu).\n",
-		       (unsigned long)sbi->s_last_block,
-		       (unsigned long)blocks - 1);
+		udf_info(sb,
+			"Failed to read VAT inode from the last recorded block (%lu), retrying with the last block of the device (%lu).\n",
+			(unsigned long)sbi->s_last_block,
+			(unsigned long)blocks - 1);
 		udf_find_vat_block(sb, p_index, type1_index, blocks - 1);
 	}
 	if (!sbi->s_vat_inode)
@@ -1179,8 +1184,8 @@ static int udf_load_partdesc(struct super_block *sb, sector_t block)
 	/* First scan for TYPE1, SPARABLE and METADATA partitions */
 	for (i = 0; i < sbi->s_partitions; i++) {
 		map = &sbi->s_partmaps[i];
-		udf_debug("Searching map: (%d == %d)\n",
-			  map->s_partition_num, partitionNumber);
+		udf_debug(sb, __func__, "Searching map: (%d == %d)\n",
+			map->s_partition_num, partitionNumber);
 		if (map->s_partition_num == partitionNumber &&
 		    (map->s_partition_type == UDF_TYPE1_MAP15 ||
 		     map->s_partition_type == UDF_SPARABLE_MAP15))
@@ -1188,8 +1193,9 @@ static int udf_load_partdesc(struct super_block *sb, sector_t block)
 	}
 
 	if (i >= sbi->s_partitions) {
-		udf_debug("Partition (%d) not found in partition map\n",
-			  partitionNumber);
+		udf_debug(sb, __func__,
+			"Partition (%d) not found in partition map\n",
+			partitionNumber);
 		goto out_bh;
 	}
 
@@ -1220,8 +1226,9 @@ static int udf_load_partdesc(struct super_block *sb, sector_t block)
 	if (map->s_partition_type == UDF_METADATA_MAP25) {
 		ret = udf_load_metadata_files(sb, i);
 		if (ret) {
-			printk(KERN_ERR "UDF-fs: error loading MetaData "
-			"partition map %d\n", i);
+			udf_err(sb, __func__,
+				"loading MetaData partition map %d\n",
+				i);
 			goto out_bh;
 		}
 	} else {
@@ -1234,9 +1241,8 @@ static int udf_load_partdesc(struct super_block *sb, sector_t block)
 		 * overwrite blocks instead of relocating them).
 		 */
 		sb->s_flags |= MS_RDONLY;
-		printk(KERN_NOTICE "UDF-fs: Filesystem marked read-only "
-			"because writing to pseudooverwrite partition is "
-			"not implemented.\n");
+		udf_info(sb,
+			"Filesystem marked read-only because writing to pseudooverwrite partition is not implemented.\n");
 	}
 out_bh:
 	/* In case loading failed, we handle cleanup in udf_fill_super */
@@ -1344,9 +1350,9 @@ static int udf_load_logicalvol(struct super_block *sb, sector_t block,
 				struct metadataPartitionMap *mdm =
 						(struct metadataPartitionMap *)
 						&(lvd->partitionMaps[offset]);
-				udf_debug("Parsing Logical vol part %d "
-					"type %d  id=%s\n", i, type,
-					UDF_ID_METADATA);
+				udf_debug(sb, __func__,
+					"Parsing Logical vol part %d type %d  id=%s\n",
+					i, type, UDF_ID_METADATA);
 
 				map->s_partition_type = UDF_METADATA_MAP25;
 				map->s_partition_func = udf_get_pblock_meta25;
@@ -1364,42 +1370,50 @@ static int udf_load_logicalvol(struct super_block *sb, sector_t block,
 				mdata->s_dup_md_flag 	 =
 					mdm->flags & 0x01;
 
-				udf_debug("Metadata Ident suffix=0x%x\n",
-					(le16_to_cpu(
-					 ((__le16 *)
-					      mdm->partIdent.identSuffix)[0])));
-				udf_debug("Metadata part num=%d\n",
+				udf_debug(sb, __func__,
+					"Metadata Ident suffix=0x%x\n",
+					(le16_to_cpu(((__le16 *)
+					mdm->partIdent.identSuffix)[0])));
+				udf_debug(sb, __func__,
+					"Metadata part num=%d\n",
 					le16_to_cpu(mdm->partitionNum));
-				udf_debug("Metadata part alloc unit size=%d\n",
+				udf_debug(sb, __func__,
+					"Metadata part alloc unit size=%d\n",
 					le32_to_cpu(mdm->allocUnitSize));
-				udf_debug("Metadata file loc=%d\n",
+				udf_debug(sb, __func__,
+					"Metadata file loc=%d\n",
 					le32_to_cpu(mdm->metadataFileLoc));
-				udf_debug("Mirror file loc=%d\n",
-				       le32_to_cpu(mdm->metadataMirrorFileLoc));
-				udf_debug("Bitmap file loc=%d\n",
-				       le32_to_cpu(mdm->metadataBitmapFileLoc));
-				udf_debug("Duplicate Flag: %d %d\n",
+				udf_debug(sb, __func__,
+					"Mirror file loc=%d\n",
+					le32_to_cpu(
+					mdm->metadataMirrorFileLoc));
+				udf_debug(sb, __func__, "Bitmap file loc=%d\n",
+					le32_to_cpu(
+					mdm->metadataBitmapFileLoc));
+				udf_debug(sb, __func__,
+					"Duplicate Flag: %d %d\n",
 					mdata->s_dup_md_flag, mdm->flags);
 			} else {
-				udf_debug("Unknown ident: %s\n",
-					  upm2->partIdent.ident);
+				udf_debug(sb, __func__, "Unknown ident: %s\n",
+					upm2->partIdent.ident);
 				continue;
 			}
 			map->s_volumeseqnum = le16_to_cpu(upm2->volSeqNum);
 			map->s_partition_num = le16_to_cpu(upm2->partitionNum);
 		}
-		udf_debug("Partition (%d:%d) type %d on volume %d\n",
-			  i, map->s_partition_num, type,
-			  map->s_volumeseqnum);
+		udf_debug(sb, __func__,
+			"Partition (%d:%d) type %d on volume %d\n",
+			i, map->s_partition_num, type, map->s_volumeseqnum);
 	}
 
 	if (fileset) {
 		struct long_ad *la = (struct long_ad *)&(lvd->logicalVolContentsUse[0]);
 
 		*fileset = lelb_to_cpu(la->extLocation);
-		udf_debug("FileSet found in LogicalVolDesc at block=%d, "
-			  "partition=%d\n", fileset->logicalBlockNum,
-			  fileset->partitionReferenceNum);
+		udf_debug(sb, __func__,
+			"FileSet found in LogicalVolDesc at block=%d, partition=%d\n",
+			fileset->logicalBlockNum,
+			fileset->partitionReferenceNum);
 	}
 	if (lvd->integritySeqExt.extLength)
 		udf_load_logicalvolint(sb, leea_to_cpu(lvd->integritySeqExt));
@@ -1478,9 +1492,9 @@ static noinline int udf_process_sequence(struct super_block *sb, long block,
 
 		bh = udf_read_tagged(sb, block, block, &ident);
 		if (!bh) {
-			printk(KERN_ERR "udf: Block %Lu of volume descriptor "
-			       "sequence is corrupted or we could not read "
-			       "it.\n", (unsigned long long)block);
+			udf_err(sb, __func__,
+				"Block %llu of volume descriptor sequence is corrupted or we could not read it.\n",
+				(unsigned long long)block);
 			return 1;
 		}
 
@@ -1553,7 +1567,7 @@ static noinline int udf_process_sequence(struct super_block *sb, long block,
 	 * in a suitable order
 	 */
 	if (!vds[VDS_POS_PRIMARY_VOL_DESC].block) {
-		printk(KERN_ERR "udf: Primary Volume Descriptor not found!\n");
+		udf_err(sb, __func__, "Primary Volume Descriptor not found!\n");
 		return 1;
 	}
 	if (udf_load_pvoldesc(sb, vds[VDS_POS_PRIMARY_VOL_DESC].block))
@@ -1740,7 +1754,7 @@ static int udf_load_vrs(struct super_block *sb, struct udf_options *uopt,
 
 	if (!sb_set_blocksize(sb, uopt->blocksize)) {
 		if (!silent)
-			printk(KERN_WARNING "UDF-fs: Bad block size\n");
+			udf_warn(sb, __func__, "Bad block size\n");
 		return 0;
 	}
 	sbi->s_last_block = uopt->lastblock;
@@ -1749,23 +1763,24 @@ static int udf_load_vrs(struct super_block *sb, struct udf_options *uopt,
 		nsr_off = udf_check_vsd(sb);
 		if (!nsr_off) {
 			if (!silent)
-				printk(KERN_WARNING "UDF-fs: No VRS found\n");
+				udf_warn(sb, __func__, "No VRS found\n");
 			return 0;
 		}
 		if (nsr_off == -1)
-			udf_debug("Failed to read byte 32768. Assuming open "
-				  "disc. Skipping validity check\n");
+			udf_debug(sb, __func__,
+				"Failed to read byte 32768. Assuming open disc. Skipping validity check\n");
 		if (!sbi->s_last_block)
 			sbi->s_last_block = udf_get_last_block(sb);
 	} else {
-		udf_debug("Validity check skipped because of novrs option\n");
+		udf_debug(sb, __func__,
+			"Validity check skipped because of novrs option\n");
 	}
 
 	/* Look for anchor block and load Volume Descriptor Sequence */
 	sbi->s_anchor = uopt->anchor;
 	if (!udf_find_anchor(sb, fileset)) {
 		if (!silent)
-			printk(KERN_WARNING "UDF-fs: No anchor found\n");
+			udf_warn(sb, __func__, "No anchor found\n");
 		return 0;
 	}
 	return 1;
@@ -1932,13 +1947,13 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
 
 	mutex_init(&sbi->s_alloc_mutex);
 
-	if (!udf_parse_options((char *)options, &uopt, false))
+	if (!udf_parse_options(sb, (char *)options, &uopt, false))
 		goto error_out;
 
 	if (uopt.flags & (1 << UDF_FLAG_UTF8) &&
 	    uopt.flags & (1 << UDF_FLAG_NLS_MAP)) {
-		udf_error(sb, "udf_read_super",
-			  "utf8 cannot be combined with iocharset\n");
+		udf_err(sb, __func__,
+			"utf8 cannot be combined with iocharset\n");
 		goto error_out;
 	}
 #ifdef CONFIG_UDF_NLS
@@ -1947,7 +1962,7 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
 		if (!uopt.nls_map)
 			uopt.flags &= ~(1 << UDF_FLAG_NLS_MAP);
 		else
-			udf_debug("Using default NLS map\n");
+			udf_debug(sb, __func__, "Using default NLS map\n");
 	}
 #endif
 	if (!(uopt.flags & (1 << UDF_FLAG_NLS_MAP)))
@@ -1970,7 +1985,7 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
 	else
 		sbi->s_session = uopt.session;
 
-	udf_debug("Multi-session=%d\n", sbi->s_session);
+	udf_debug(sb, __func__, "Multi-session=%d\n", sbi->s_session);
 
 	/* Fill in the rest of the superblock */
 	sb->s_op = &udf_sb_ops;
@@ -1987,19 +2002,18 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
 		ret = udf_load_vrs(sb, &uopt, silent, &fileset);
 		if (!ret && uopt.blocksize != UDF_DEFAULT_BLOCKSIZE) {
 			if (!silent)
-				printk(KERN_NOTICE
-				       "UDF-fs: Rescanning with blocksize "
-				       "%d\n", UDF_DEFAULT_BLOCKSIZE);
+				udf_info(sb, "Rescanning with blocksize %d\n",
+					UDF_DEFAULT_BLOCKSIZE);
 			uopt.blocksize = UDF_DEFAULT_BLOCKSIZE;
 			ret = udf_load_vrs(sb, &uopt, silent, &fileset);
 		}
 	}
 	if (!ret) {
-		printk(KERN_WARNING "UDF-fs: No partition found (1)\n");
+		udf_warn(sb, __func__, "No partition found (1)\n");
 		goto error_out;
 	}
 
-	udf_debug("Lastblock=%d\n", sbi->s_last_block);
+	udf_debug(sb, __func__, "Lastblock=%d\n", sbi->s_last_block);
 
 	if (sbi->s_lvid_bh) {
 		struct logicalVolIntegrityDescImpUse *lvidiu =
@@ -2010,10 +2024,9 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
 				le16_to_cpu(lvidiu->maxUDFWriteRev); */
 
 		if (minUDFReadRev > UDF_MAX_READ_VERSION) {
-			printk(KERN_ERR "UDF-fs: minUDFReadRev=%x "
-					"(max is %x)\n",
-			       le16_to_cpu(lvidiu->minUDFReadRev),
-			       UDF_MAX_READ_VERSION);
+			udf_err(sb, __func__, "minUDFReadRev=%x (max is %x)\n",
+				le16_to_cpu(lvidiu->minUDFReadRev),
+				UDF_MAX_READ_VERSION);
 			goto error_out;
 		} else if (minUDFWriteRev > UDF_MAX_WRITE_VERSION)
 			sb->s_flags |= MS_RDONLY;
@@ -2027,29 +2040,30 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
 	}
 
 	if (!sbi->s_partitions) {
-		printk(KERN_WARNING "UDF-fs: No partition found (2)\n");
+		udf_warn(sb, __func__, "No partition found (2)\n");
 		goto error_out;
 	}
 
 	if (sbi->s_partmaps[sbi->s_partition].s_partition_flags &
 			UDF_PART_FLAG_READ_ONLY) {
-		printk(KERN_NOTICE "UDF-fs: Partition marked readonly; "
-				   "forcing readonly mount\n");
+		udf_info(sb,
+			"Partition marked readonly; forcing readonly mount\n");
 		sb->s_flags |= MS_RDONLY;
 	}
 
 	if (udf_find_fileset(sb, &fileset, &rootdir)) {
-		printk(KERN_WARNING "UDF-fs: No fileset found\n");
+		udf_warn(sb, __func__, "No fileset found\n");
 		goto error_out;
 	}
 
 	if (!silent) {
 		struct timestamp ts;
 		udf_time_to_disk_stamp(&ts, sbi->s_record_time);
-		udf_info("UDF: Mounting volume '%s', "
-			 "timestamp %04u/%02u/%02u %02u:%02u (%x)\n",
-			 sbi->s_volume_ident, le16_to_cpu(ts.year), ts.month, ts.day,
-			 ts.hour, ts.minute, le16_to_cpu(ts.typeAndTimezone));
+		udf_info(sb,
+			"Mounting volume '%s', timestamp %04u/%02u/%02u %02u:%02u (%x)\n",
+			sbi->s_volume_ident, le16_to_cpu(ts.year), ts.month,
+			ts.day, ts.hour, ts.minute,
+			le16_to_cpu(ts.typeAndTimezone));
 	}
 	if (!(sb->s_flags & MS_RDONLY))
 		udf_open_lvid(sb);
@@ -2059,16 +2073,16 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
 	/* perhaps it's not extensible enough, but for now ... */
 	inode = udf_iget(sb, &rootdir);
 	if (!inode) {
-		printk(KERN_ERR "UDF-fs: Error in udf_iget, block=%d, "
-				"partition=%d\n",
-		       rootdir.logicalBlockNum, rootdir.partitionReferenceNum);
+		udf_err(sb, __func__,
+			"Error in udf_iget, block=%d, partition=%d\n",
+			rootdir.logicalBlockNum, rootdir.partitionReferenceNum);
 		goto error_out;
 	}
 
 	/* Allocate a dentry for the root inode */
 	sb->s_root = d_alloc_root(inode);
 	if (!sb->s_root) {
-		printk(KERN_ERR "UDF-fs: Couldn't allocate root dentry\n");
+		udf_err(sb, __func__, "Couldn't allocate root dentry\n");
 		iput(inode);
 		goto error_out;
 	}
@@ -2096,34 +2110,77 @@ error_out:
 	return -EINVAL;
 }
 
-static void udf_error(struct super_block *sb, const char *function,
-		      const char *fmt, ...)
+void udf_err(struct super_block *sb, const char *function,
+		const char *fmt, ...)
 {
+	struct va_format vaf;
 	va_list args;
 
+	va_start(args, fmt);
+	vaf.fmt = fmt;
+	vaf.va = &args;
+
 	if (!(sb->s_flags & MS_RDONLY)) {
 		/* mark sb error */
 		sb->s_dirt = 1;
 	}
+
+	pr_crit("error (device %s): %s: %pV", sb->s_id, function, &vaf);
+	va_end(args);
+}
+
+void udf_warn(struct super_block *sb, const char *function,
+		const char *fmt, ...)
+{
+	struct va_format vaf;
+	va_list args;
+
 	va_start(args, fmt);
-	vsnprintf(error_buf, sizeof(error_buf), fmt, args);
+
+	vaf.fmt = fmt;
+	vaf.va = &args;
+
+	pr_warn("warning (device %s): %s: %pV", sb->s_id, function, &vaf);
 	va_end(args);
-	printk(KERN_CRIT "UDF-fs error (device %s): %s: %s\n",
-		sb->s_id, function, error_buf);
 }
 
-void udf_warning(struct super_block *sb, const char *function,
-		 const char *fmt, ...)
+void udf_info(struct super_block *sb, const char *fmt, ...)
 {
+	struct va_format vaf;
 	va_list args;
 
 	va_start(args, fmt);
-	vsnprintf(error_buf, sizeof(error_buf), fmt, args);
+
+	vaf.fmt = fmt;
+	vaf.va = &args;
+
+	pr_info("info (device %s): %pV", sb->s_id, &vaf);
 	va_end(args);
-	printk(KERN_WARNING "UDF-fs warning (device %s): %s: %s\n",
-	       sb->s_id, function, error_buf);
 }
 
+#ifdef udf_debug
+void udf_debug(struct super_block *sb, const char *function,
+		const char *fmt, ...)
+{
+	struct va_format vaf;
+	va_list args;
+
+	va_start(args, fmt);
+
+	vaf.fmt = fmt;
+	vaf.va = &args;
+
+	pr_debug("debug (device %s): %s: %pV", sb->s_id, function, &vaf);
+	va_end(args);
+}
+#else
+void udf_debug(struct super_block *sb, const char *function,
+		const char *fmt, ...)
+{
+	return;
+}
+#endif
+
 static void udf_put_super(struct super_block *sb)
 {
 	int i;
@@ -2213,11 +2270,11 @@ static unsigned int udf_count_free_bitmap(struct super_block *sb,
 	bh = udf_read_ptagged(sb, &loc, 0, &ident);
 
 	if (!bh) {
-		printk(KERN_ERR "udf: udf_count_free failed\n");
+		udf_err(sb, __func__, "udf_count_free failed\n");
 		goto out;
 	} else if (ident != TAG_IDENT_SBD) {
 		brelse(bh);
-		printk(KERN_ERR "udf: udf_count_free failed\n");
+		udf_err(sb, __func__, "udf_count_free failed\n");
 		goto out;
 	}
 
@@ -2236,7 +2293,7 @@ static unsigned int udf_count_free_bitmap(struct super_block *sb,
 			newblock = udf_get_lb_pblock(sb, &loc, ++block);
 			bh = udf_tread(sb, newblock);
 			if (!bh) {
-				udf_debug("read failed\n");
+				udf_debug(sb, __func__, "read failed\n");
 				goto out;
 			}
 			index = 0;
diff --git a/fs/udf/truncate.c b/fs/udf/truncate.c
index 8424308..f07ef23 100644
--- a/fs/udf/truncate.c
+++ b/fs/udf/truncate.c
@@ -95,23 +95,24 @@ void udf_truncate_tail_extent(struct inode *inode)
 		lbcount += elen;
 		if (lbcount > inode->i_size) {
 			if (lbcount - inode->i_size >= inode->i_sb->s_blocksize)
-				printk(KERN_WARNING
-				       "udf_truncate_tail_extent(): Too long "
-				       "extent after EOF in inode %u: i_size: "
-				       "%Ld lbcount: %Ld extent %u+%u\n",
-				       (unsigned)inode->i_ino,
-				       (long long)inode->i_size,
-				       (long long)lbcount,
-				       (unsigned)eloc.logicalBlockNum,
-				       (unsigned)elen);
+				udf_warn(inode->i_sb, __func__,
+					"udf_truncate_tail_extent(): Too long "
+					"extent after EOF in inode %u: i_size: "
+					"%lld lbcount: %lld extent %u+%u\n",
+					(unsigned)inode->i_ino,
+					(long long)inode->i_size,
+					(long long)lbcount,
+					(unsigned)eloc.logicalBlockNum,
+					(unsigned)elen);
 			nelen = elen - (lbcount - inode->i_size);
 			epos.offset -= adsize;
 			extent_trunc(inode, &epos, &eloc, etype, elen, nelen);
 			epos.offset += adsize;
 			if (udf_next_aext(inode, &epos, &eloc, &elen, 1) != -1)
-				printk(KERN_ERR "udf_truncate_tail_extent(): "
-				       "Extent after EOF in inode %u.\n",
-				       (unsigned)inode->i_ino);
+				udf_warn(inode->i_sb, __func__,
+					"udf_truncate_tail_extent(): "
+					"Extent after EOF in inode %u.\n",
+					(unsigned)inode->i_ino);
 			break;
 		}
 	}
diff --git a/fs/udf/udfdecl.h b/fs/udf/udfdecl.h
index dbd52d4b..3d4cc4d 100644
--- a/fs/udf/udfdecl.h
+++ b/fs/udf/udfdecl.h
@@ -1,6 +1,8 @@
 #ifndef __UDF_DECL_H
 #define __UDF_DECL_H
 
+#define pr_fmt(fmt) "UDF-fs " fmt
+
 #include "ecma_167.h"
 #include "osta_udf.h"
 
@@ -16,22 +18,22 @@
 #define UDF_PREALLOCATE
 #define UDF_DEFAULT_PREALLOC_BLOCKS	8
 
-#undef UDFFS_DEBUG
+__attribute__((format(printf, 3, 4)))
+void udf_err(struct super_block *sb, const char *function,
+		const char *fmt, ...);
+
+__attribute__((format(printf, 3, 4)))
+void udf_warn(struct super_block *sb, const char *function,
+		const char *fmt, ...);
 
-#ifdef UDFFS_DEBUG
-#define udf_debug(f, a...) \
-do { \
-	printk(KERN_DEBUG "UDF-fs DEBUG %s:%d:%s: ", \
-		__FILE__, __LINE__, __func__); \
-	printk(f, ##a); \
-} while (0)
-#else
-#define udf_debug(f, a...) /**/
-#endif
+__attribute__((format(printf, 2, 3)))
+void udf_info(struct super_block *sb, const char *fmt, ...);
 
-#define udf_info(f, a...) \
-	printk(KERN_INFO "UDF-fs INFO " f, ##a);
+#undef UDFFS_DEBUG
 
+__attribute__((format(printf, 3, 4)))
+void udf_debug(struct super_block *sb, const char *function,
+		const char *fmt, ...);
 
 #define udf_fixed_to_variable(x) ( ( ( (x) >> 5 ) * 39 ) + ( (x) & 0x0000001F ) )
 #define udf_variable_to_fixed(x) ( ( ( (x) / 39 ) << 5 ) + ( (x) % 39 ) )
@@ -112,8 +114,6 @@ struct extent_position {
 
 /* super.c */
 
-__attribute__((format(printf, 3, 4)))
-extern void udf_warning(struct super_block *, const char *, const char *, ...);
 static inline void udf_updated_lvid(struct super_block *sb)
 {
 	struct buffer_head *bh = UDF_SB(sb)->s_lvid_bh;
@@ -202,7 +202,8 @@ extern int udf_get_filename(struct super_block *, uint8_t *, uint8_t *, int);
 extern int udf_put_filename(struct super_block *, const uint8_t *, uint8_t *,
 			    int);
 extern int udf_build_ustr(struct ustr *, dstring *, int);
-extern int udf_CS0toUTF8(struct ustr *, const struct ustr *);
+extern int udf_CS0toUTF8(struct super_block *, struct ustr *,
+			const struct ustr *);
 
 /* ialloc.c */
 extern void udf_free_inode(struct inode *);
@@ -228,10 +229,12 @@ extern struct fileIdentDesc *udf_fileident_read(struct inode *, loff_t *,
 						struct extent_position *,
 						struct kernel_lb_addr *, uint32_t *,
 						sector_t *);
-extern struct fileIdentDesc *udf_get_fileident(void *buffer, int bufsize,
-					       int *offset);
-extern struct long_ad *udf_get_filelongad(uint8_t *, int, uint32_t *, int);
-extern struct short_ad *udf_get_fileshortad(uint8_t *, int, uint32_t *, int);
+extern struct fileIdentDesc *udf_get_fileident(struct inode *, void *buffer,
+						int bufsize, int *offset);
+extern struct long_ad *udf_get_filelongad(struct inode *, uint8_t *, int,
+						uint32_t *, int);
+extern struct short_ad *udf_get_fileshortad(struct inode *, uint8_t *, int,
+						uint32_t *, int);
 
 /* udftime.c */
 extern struct timespec *udf_disk_stamp_to_time(struct timespec *dest,
diff --git a/fs/udf/udftime.c b/fs/udf/udftime.c
index b8c828c..927c931 100644
--- a/fs/udf/udftime.c
+++ b/fs/udf/udftime.c
@@ -34,9 +34,9 @@
  * http://www.boulder.nist.gov/timefreq/pubs/bulletin/leapsecond.htm
  */
 
+#include "udfdecl.h"
 #include <linux/types.h>
 #include <linux/kernel.h>
-#include "udfdecl.h"
 
 #define EPOCH_YEAR 1970
 
diff --git a/fs/udf/unicode.c b/fs/udf/unicode.c
index d03a90b..9ce8b95 100644
--- a/fs/udf/unicode.c
+++ b/fs/udf/unicode.c
@@ -99,7 +99,8 @@ static int udf_build_ustr_exact(struct ustr *dest, dstring *ptr, int exactsize)
  *	November 12, 1997 - Andrew E. Mileski
  *	Written, tested, and released.
  */
-int udf_CS0toUTF8(struct ustr *utf_o, const struct ustr *ocu_i)
+int udf_CS0toUTF8(struct super_block *sb, struct ustr *utf_o,
+			const struct ustr *ocu_i)
 {
 	const uint8_t *ocu;
 	uint8_t cmp_id, ocu_len;
@@ -114,8 +115,8 @@ int udf_CS0toUTF8(struct ustr *utf_o, const struct ustr *ocu_i)
 	cmp_id = ocu_i->u_cmpID;
 	if (cmp_id != 8 && cmp_id != 16) {
 		memset(utf_o, 0, sizeof(struct ustr));
-		printk(KERN_ERR "udf: unknown compression code (%d) stri=%s\n",
-		       cmp_id, ocu_i->u_name);
+		udf_err(sb, __func__, "unknown compression code (%d) stri=%s\n",
+			cmp_id, ocu_i->u_name);
 		return 0;
 	}
 
@@ -174,7 +175,8 @@ int udf_CS0toUTF8(struct ustr *utf_o, const struct ustr *ocu_i)
  *	November 12, 1997 - Andrew E. Mileski
  *	Written, tested, and released.
  */
-static int udf_UTF8toCS0(dstring *ocu, struct ustr *utf, int length)
+static int udf_UTF8toCS0(struct super_block *sb, dstring *ocu, struct ustr *utf,
+			int length)
 {
 	unsigned c, i, max_val, utf_char;
 	int utf_cnt, u_len;
@@ -242,7 +244,7 @@ try_again:
 	if (utf_cnt) {
 error_out:
 		ocu[++u_len] = '?';
-		printk(KERN_DEBUG "udf: bad UTF-8 character\n");
+		udf_debug(sb, __func__, "bad UTF-8 character\n");
 	}
 
 	ocu[length - 1] = (uint8_t)u_len + 1;
@@ -250,8 +252,8 @@ error_out:
 	return u_len + 1;
 }
 
-static int udf_CS0toNLS(struct nls_table *nls, struct ustr *utf_o,
-			const struct ustr *ocu_i)
+static int udf_CS0toNLS(struct super_block *sb, struct nls_table *nls,
+			struct ustr *utf_o, const struct ustr *ocu_i)
 {
 	const uint8_t *ocu;
 	uint8_t cmp_id, ocu_len;
@@ -267,8 +269,8 @@ static int udf_CS0toNLS(struct nls_table *nls, struct ustr *utf_o,
 	cmp_id = ocu_i->u_cmpID;
 	if (cmp_id != 8 && cmp_id != 16) {
 		memset(utf_o, 0, sizeof(struct ustr));
-		printk(KERN_ERR "udf: unknown compression code (%d) stri=%s\n",
-		       cmp_id, ocu_i->u_name);
+		udf_err(sb, __func__, "unknown compression code (%d) stri=%s\n",
+			cmp_id, ocu_i->u_name);
 		return 0;
 	}
 
@@ -293,8 +295,8 @@ static int udf_CS0toNLS(struct nls_table *nls, struct ustr *utf_o,
 	return utf_o->u_len;
 }
 
-static int udf_NLStoCS0(struct nls_table *nls, dstring *ocu, struct ustr *uni,
-			int length)
+static int udf_NLStoCS0(struct super_block *sb, struct nls_table *nls,
+			dstring *ocu, struct ustr *uni, int length)
 {
 	int len;
 	unsigned i, max_val;
@@ -351,16 +353,18 @@ int udf_get_filename(struct super_block *sb, uint8_t *sname, uint8_t *dname,
 		goto out2;
 
 	if (UDF_QUERY_FLAG(sb, UDF_FLAG_UTF8)) {
-		if (!udf_CS0toUTF8(filename, unifilename)) {
-			udf_debug("Failed in udf_get_filename: sname = %s\n",
-				  sname);
+		if (!udf_CS0toUTF8(sb, filename, unifilename)) {
+			udf_debug(sb, __func__,
+				"Failed in udf_get_filename: sname = %s\n",
+				sname);
 			goto out2;
 		}
 	} else if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP)) {
-		if (!udf_CS0toNLS(UDF_SB(sb)->s_nls_map, filename,
+		if (!udf_CS0toNLS(sb, UDF_SB(sb)->s_nls_map, filename,
 				  unifilename)) {
-			udf_debug("Failed in udf_get_filename: sname = %s\n",
-				  sname);
+			udf_debug(sb, __func__,
+				"Failed in udf_get_filename: sname = %s\n",
+				sname);
 			goto out2;
 		}
 	} else
@@ -385,11 +389,11 @@ int udf_put_filename(struct super_block *sb, const uint8_t *sname,
 		return 0;
 
 	if (UDF_QUERY_FLAG(sb, UDF_FLAG_UTF8)) {
-		namelen = udf_UTF8toCS0(dname, &unifilename, UDF_NAME_LEN);
+		namelen = udf_UTF8toCS0(sb, dname, &unifilename, UDF_NAME_LEN);
 		if (!namelen)
 			return 0;
 	} else if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP)) {
-		namelen = udf_NLStoCS0(UDF_SB(sb)->s_nls_map, dname,
+		namelen = udf_NLStoCS0(sb, UDF_SB(sb)->s_nls_map, dname,
 					&unifilename, UDF_NAME_LEN);
 		if (!namelen)
 			return 0;
-- 
1.7.4.4


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH 0/6] udf: Change some KERN_<level>s and logging neatening
  2011-10-09 14:07                 ` NamJae Jeon
@ 2011-10-10  8:08                   ` Joe Perches
  2011-10-10  8:08                     ` [PATCH 1/6] udf: Promote some debugging messages to udf_error Joe Perches
                                       ` (7 more replies)
  0 siblings, 8 replies; 36+ messages in thread
From: Joe Perches @ 2011-10-10  8:08 UTC (permalink / raw)
  To: Jan Kara; +Cc: NamJae Jeon, linux-kernel

I reviewed your patch and think it's too large
for others to review because it combines multiple
things into a single patch.

I think that adding struct super_block * to udb_debug
isn't necessary or particularly useful.

Here are the changes to your original patch that I made:

Separate a single large patch into reviewable chunks.
Don't convert every message type to udf_<foo>.

Joe Perches (6):
  udf: Promote some debugging messages to udf_error
  udf: Rename udf_error to udf_err
  udf: Rename udf_warn to udf_warn
  udf: Convert printks to pr_<level>
  udf: Neaten logging output, use vsprintf extension %pV
  udf: Neaten udf_debug uses

 fs/udf/balloc.c    |   14 ++--
 fs/udf/directory.c |    8 +-
 fs/udf/inode.c     |   36 ++++-----
 fs/udf/lowlevel.c  |    2 +-
 fs/udf/misc.c      |   24 ++++---
 fs/udf/namei.c     |    5 +-
 fs/udf/partition.c |   11 +--
 fs/udf/super.c     |  214 +++++++++++++++++++++++-----------------------------
 fs/udf/truncate.c  |   21 ++---
 fs/udf/udfdecl.h   |   35 ++++++---
 fs/udf/udftime.c   |    3 +-
 fs/udf/unicode.c   |    6 +-
 12 files changed, 178 insertions(+), 201 deletions(-)

-- 
1.7.6.405.gc1be0


^ permalink raw reply	[flat|nested] 36+ messages in thread

* [PATCH 1/6] udf: Promote some debugging messages to udf_error
  2011-10-10  8:08                   ` [PATCH 0/6] udf: Change some KERN_<level>s and logging neatening Joe Perches
@ 2011-10-10  8:08                     ` Joe Perches
  2011-10-10 10:06                       ` NamJae Jeon
  2011-10-10 17:32                       ` Jan Kara
  2011-10-10  8:08                     ` [PATCH 2/6] udf: Rename udf_error to udf_err Joe Perches
                                       ` (6 subsequent siblings)
  7 siblings, 2 replies; 36+ messages in thread
From: Joe Perches @ 2011-10-10  8:08 UTC (permalink / raw)
  To: Jan Kara; +Cc: NamJae Jeon, linux-kernel

If there is a problem with a scratched disc or loader,
it's valuable to know which error occurred.

Convert some debug messages to udf_error, neaten those messages too.
Add the calculated tag checksum and the read checksum to error message.
Make udf_error a public function and move the logging prototypes together.

Original-patch-by: NamJae Jeon <linkinjeon@gmail.com>
Signed-off-by: Joe Perches <joe@perches.com>
---
 fs/udf/misc.c    |   21 ++++++++++++++-------
 fs/udf/super.c   |    6 ++----
 fs/udf/udfdecl.h |    9 +++++++--
 3 files changed, 23 insertions(+), 13 deletions(-)

diff --git a/fs/udf/misc.c b/fs/udf/misc.c
index 9215700..87667f8 100644
--- a/fs/udf/misc.c
+++ b/fs/udf/misc.c
@@ -204,6 +204,7 @@ struct buffer_head *udf_read_tagged(struct super_block *sb, uint32_t block,
 {
 	struct tag *tag_p;
 	struct buffer_head *bh = NULL;
+	u8 checksum;
 
 	/* Read the block */
 	if (block == 0xFFFFFFFF)
@@ -211,7 +212,7 @@ struct buffer_head *udf_read_tagged(struct super_block *sb, uint32_t block,
 
 	bh = udf_tread(sb, block);
 	if (!bh) {
-		udf_debug("block=%d, location=%d: read failed\n",
+		udf_error(sb, __func__, "read failed, block=%u, location=%d\n",
 			  block, location);
 		return NULL;
 	}
@@ -221,21 +222,26 @@ struct buffer_head *udf_read_tagged(struct super_block *sb, uint32_t block,
 	*ident = le16_to_cpu(tag_p->tagIdent);
 
 	if (location != le32_to_cpu(tag_p->tagLocation)) {
-		udf_debug("location mismatch block %u, tag %u != %u\n",
+		udf_error(sb, __func__,
+			  "location mismatch, block %u, tag %u != %u\n",
 			  block, le32_to_cpu(tag_p->tagLocation), location);
 		goto error_out;
 	}
 
 	/* Verify the tag checksum */
-	if (udf_tag_checksum(tag_p) != tag_p->tagChecksum) {
-		printk(KERN_ERR "udf: tag checksum failed block %d\n", block);
+	checksum = udf_tag_checksum(tag_p);
+	if (checksum != tag_p->tagChecksum) {
+		udf_error(sb, __func__,
+			  "tag checksum failed, block %u: 0x%02x != 0x%02x\n",
+			  block, checksum, tag_p->tagChecksum);
 		goto error_out;
 	}
 
 	/* Verify the tag version */
 	if (tag_p->descVersion != cpu_to_le16(0x0002U) &&
 	    tag_p->descVersion != cpu_to_le16(0x0003U)) {
-		udf_debug("tag version 0x%04x != 0x0002 || 0x0003 block %d\n",
+		udf_error(sb, __func__,
+			  "tag version 0x%04x != 0x0002 || 0x0003, block %u\n",
 			  le16_to_cpu(tag_p->descVersion), block);
 		goto error_out;
 	}
@@ -247,8 +253,9 @@ struct buffer_head *udf_read_tagged(struct super_block *sb, uint32_t block,
 					le16_to_cpu(tag_p->descCRCLength)))
 		return bh;
 
-	udf_debug("Crc failure block %d: crc = %d, crclen = %d\n", block,
-	    le16_to_cpu(tag_p->descCRC), le16_to_cpu(tag_p->descCRCLength));
+	udf_error(sb, __func__, "crc failure, block %u: crc = %d, crclen = %d\n",
+		  block, le16_to_cpu(tag_p->descCRC),
+		  le16_to_cpu(tag_p->descCRCLength));
 
 error_out:
 	brelse(bh);
diff --git a/fs/udf/super.c b/fs/udf/super.c
index 7b27b06..80f47ce 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -92,8 +92,6 @@ static void udf_close_lvid(struct super_block *);
 static unsigned int udf_count_free(struct super_block *);
 static int udf_statfs(struct dentry *, struct kstatfs *);
 static int udf_show_options(struct seq_file *, struct vfsmount *);
-static void udf_error(struct super_block *sb, const char *function,
-		      const char *fmt, ...);
 
 struct logicalVolIntegrityDescImpUse *udf_sb_lvidiu(struct udf_sb_info *sbi)
 {
@@ -2096,8 +2094,8 @@ error_out:
 	return -EINVAL;
 }
 
-static void udf_error(struct super_block *sb, const char *function,
-		      const char *fmt, ...)
+void udf_error(struct super_block *sb, const char *function,
+	       const char *fmt, ...)
 {
 	va_list args;
 
diff --git a/fs/udf/udfdecl.h b/fs/udf/udfdecl.h
index dbd52d4b..81e66af 100644
--- a/fs/udf/udfdecl.h
+++ b/fs/udf/udfdecl.h
@@ -29,6 +29,13 @@ do { \
 #define udf_debug(f, a...) /**/
 #endif
 
+__attribute__((format(printf, 3, 4)))
+extern void udf_warning(struct super_block *, const char *, const char *, ...);
+
+__attribute__((format(printf, 3, 4)))
+extern void udf_error(struct super_block *sb, const char *function,
+		      const char *fmt, ...);
+
 #define udf_info(f, a...) \
 	printk(KERN_INFO "UDF-fs INFO " f, ##a);
 
@@ -112,8 +119,6 @@ struct extent_position {
 
 /* super.c */
 
-__attribute__((format(printf, 3, 4)))
-extern void udf_warning(struct super_block *, const char *, const char *, ...);
 static inline void udf_updated_lvid(struct super_block *sb)
 {
 	struct buffer_head *bh = UDF_SB(sb)->s_lvid_bh;
-- 
1.7.6.405.gc1be0


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH 2/6] udf: Rename udf_error to udf_err
  2011-10-10  8:08                   ` [PATCH 0/6] udf: Change some KERN_<level>s and logging neatening Joe Perches
  2011-10-10  8:08                     ` [PATCH 1/6] udf: Promote some debugging messages to udf_error Joe Perches
@ 2011-10-10  8:08                     ` Joe Perches
  2011-10-10 10:18                       ` NamJae Jeon
  2011-10-10  8:08                     ` [PATCH 3/6] udf: Rename udf_warn to udf_warn Joe Perches
                                       ` (5 subsequent siblings)
  7 siblings, 1 reply; 36+ messages in thread
From: Joe Perches @ 2011-10-10  8:08 UTC (permalink / raw)
  To: Jan Kara; +Cc: NamJae Jeon, linux-kernel

Rename udf_error to udf_err for consistency with normal logging
uses of pr_err.

Rename function udf_err to _udf_err.
Remove __func__ from uses and move __func__ to a new udf_err
macro that calls _udf_err.
Some of the udf_error uses had \n terminations, some did not so
standardize \n's to udf_err uses, remove \n from _udf_err function.
Coalesce udf_err formats.
One message prefixed with udf_read_super is now prefixed with
udf_fill_super.

Signed-off-by: Joe Perches <joe@perches.com>
---
 fs/udf/misc.c    |   25 +++++++++++--------------
 fs/udf/super.c   |   27 +++++++++++----------------
 fs/udf/udfdecl.h |    7 ++++---
 3 files changed, 26 insertions(+), 33 deletions(-)

diff --git a/fs/udf/misc.c b/fs/udf/misc.c
index 87667f8..645f02d 100644
--- a/fs/udf/misc.c
+++ b/fs/udf/misc.c
@@ -212,8 +212,8 @@ struct buffer_head *udf_read_tagged(struct super_block *sb, uint32_t block,
 
 	bh = udf_tread(sb, block);
 	if (!bh) {
-		udf_error(sb, __func__, "read failed, block=%u, location=%d\n",
-			  block, location);
+		udf_err(sb, "read failed, block=%u, location=%d\n",
+			block, location);
 		return NULL;
 	}
 
@@ -222,27 +222,24 @@ struct buffer_head *udf_read_tagged(struct super_block *sb, uint32_t block,
 	*ident = le16_to_cpu(tag_p->tagIdent);
 
 	if (location != le32_to_cpu(tag_p->tagLocation)) {
-		udf_error(sb, __func__,
-			  "location mismatch, block %u, tag %u != %u\n",
-			  block, le32_to_cpu(tag_p->tagLocation), location);
+		udf_err(sb, "location mismatch, block %u, tag %u != %u\n",
+			block, le32_to_cpu(tag_p->tagLocation), location);
 		goto error_out;
 	}
 
 	/* Verify the tag checksum */
 	checksum = udf_tag_checksum(tag_p);
 	if (checksum != tag_p->tagChecksum) {
-		udf_error(sb, __func__,
-			  "tag checksum failed, block %u: 0x%02x != 0x%02x\n",
-			  block, checksum, tag_p->tagChecksum);
+		udf_err(sb, "tag checksum failed, block %u: 0x%02x != 0x%02x\n",
+			block, checksum, tag_p->tagChecksum);
 		goto error_out;
 	}
 
 	/* Verify the tag version */
 	if (tag_p->descVersion != cpu_to_le16(0x0002U) &&
 	    tag_p->descVersion != cpu_to_le16(0x0003U)) {
-		udf_error(sb, __func__,
-			  "tag version 0x%04x != 0x0002 || 0x0003, block %u\n",
-			  le16_to_cpu(tag_p->descVersion), block);
+		udf_err(sb, "tag version 0x%04x != 0x0002 || 0x0003, block %u\n",
+			le16_to_cpu(tag_p->descVersion), block);
 		goto error_out;
 	}
 
@@ -253,9 +250,9 @@ struct buffer_head *udf_read_tagged(struct super_block *sb, uint32_t block,
 					le16_to_cpu(tag_p->descCRCLength)))
 		return bh;
 
-	udf_error(sb, __func__, "crc failure, block %u: crc = %d, crclen = %d\n",
-		  block, le16_to_cpu(tag_p->descCRC),
-		  le16_to_cpu(tag_p->descCRCLength));
+	udf_err(sb, "crc failure, block %u: crc = %d, crclen = %d\n",
+		block, le16_to_cpu(tag_p->descCRC),
+		le16_to_cpu(tag_p->descCRCLength));
 
 error_out:
 	brelse(bh);
diff --git a/fs/udf/super.c b/fs/udf/super.c
index 80f47ce..76cc08f 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -242,9 +242,8 @@ static int udf_sb_alloc_partition_maps(struct super_block *sb, u32 count)
 	sbi->s_partmaps = kcalloc(count, sizeof(struct udf_part_map),
 				  GFP_KERNEL);
 	if (!sbi->s_partmaps) {
-		udf_error(sb, __func__,
-			  "Unable to allocate space for %d partition maps",
-			  count);
+		udf_err(sb, "Unable to allocate space for %d partition maps\n",
+			count);
 		sbi->s_partitions = 0;
 		return -ENOMEM;
 	}
@@ -879,8 +878,7 @@ static int udf_load_metadata_files(struct super_block *sb, int partition)
 
 	if (mdata->s_mirror_fe == NULL) {
 		if (fe_error) {
-			udf_error(sb, __func__, "mirror inode efe not found "
-			"and metadata inode is missing too, exiting...");
+			udf_err(sb, "mirror inode efe not found and metadata inode is missing too, exiting...\n");
 			goto error_exit;
 		} else
 			udf_warning(sb, __func__, "mirror inode efe not found,"
@@ -915,8 +913,7 @@ static int udf_load_metadata_files(struct super_block *sb, int partition)
 					"not found but it's ok since the disc"
 					" is mounted read-only");
 			else {
-				udf_error(sb, __func__, "bitmap inode efe not "
-					"found and attempted read-write mount");
+				udf_err(sb, "bitmap inode efe not found and attempted read-write mount\n");
 				goto error_exit;
 			}
 		}
@@ -969,9 +966,8 @@ static struct udf_bitmap *udf_sb_alloc_bitmap(struct super_block *sb, u32 index)
 		bitmap = vzalloc(size); /* TODO: get rid of vzalloc */
 
 	if (bitmap == NULL) {
-		udf_error(sb, __func__,
-			  "Unable to allocate space for bitmap "
-			  "and %d buffer_head pointers", nr_groups);
+		udf_err(sb, "Unable to allocate space for bitmap and %d buffer_head pointers\n",
+			nr_groups);
 		return NULL;
 	}
 
@@ -1935,8 +1931,7 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
 
 	if (uopt.flags & (1 << UDF_FLAG_UTF8) &&
 	    uopt.flags & (1 << UDF_FLAG_NLS_MAP)) {
-		udf_error(sb, "udf_read_super",
-			  "utf8 cannot be combined with iocharset\n");
+		udf_err(sb, "utf8 cannot be combined with iocharset\n");
 		goto error_out;
 	}
 #ifdef CONFIG_UDF_NLS
@@ -2094,8 +2089,8 @@ error_out:
 	return -EINVAL;
 }
 
-void udf_error(struct super_block *sb, const char *function,
-	       const char *fmt, ...)
+void _udf_err(struct super_block *sb, const char *function,
+	      const char *fmt, ...)
 {
 	va_list args;
 
@@ -2106,8 +2101,8 @@ void udf_error(struct super_block *sb, const char *function,
 	va_start(args, fmt);
 	vsnprintf(error_buf, sizeof(error_buf), fmt, args);
 	va_end(args);
-	printk(KERN_CRIT "UDF-fs error (device %s): %s: %s\n",
-		sb->s_id, function, error_buf);
+	printk(KERN_CRIT "UDF-fs error (device %s): %s: %s",
+	       sb->s_id, function, error_buf);
 }
 
 void udf_warning(struct super_block *sb, const char *function,
diff --git a/fs/udf/udfdecl.h b/fs/udf/udfdecl.h
index 81e66af..7bc3ba1 100644
--- a/fs/udf/udfdecl.h
+++ b/fs/udf/udfdecl.h
@@ -33,13 +33,14 @@ __attribute__((format(printf, 3, 4)))
 extern void udf_warning(struct super_block *, const char *, const char *, ...);
 
 __attribute__((format(printf, 3, 4)))
-extern void udf_error(struct super_block *sb, const char *function,
-		      const char *fmt, ...);
+extern void _udf_err(struct super_block *sb, const char *function,
+		     const char *fmt, ...);
+#define udf_err(sb, fmt, ...)					\
+	_udf_err(sb, __func__, fmt, ##__VA_ARGS__)
 
 #define udf_info(f, a...) \
 	printk(KERN_INFO "UDF-fs INFO " f, ##a);
 
-
 #define udf_fixed_to_variable(x) ( ( ( (x) >> 5 ) * 39 ) + ( (x) & 0x0000001F ) )
 #define udf_variable_to_fixed(x) ( ( ( (x) / 39 ) << 5 ) + ( (x) % 39 ) )
 
-- 
1.7.6.405.gc1be0


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH 3/6] udf: Rename udf_warn to udf_warn
  2011-10-10  8:08                   ` [PATCH 0/6] udf: Change some KERN_<level>s and logging neatening Joe Perches
  2011-10-10  8:08                     ` [PATCH 1/6] udf: Promote some debugging messages to udf_error Joe Perches
  2011-10-10  8:08                     ` [PATCH 2/6] udf: Rename udf_error to udf_err Joe Perches
@ 2011-10-10  8:08                     ` Joe Perches
  2011-10-10 10:18                       ` NamJae Jeon
  2011-10-10 18:25                       ` Paul Bolle
  2011-10-10  8:08                     ` [PATCH 4/6] udf: Convert printks to pr_<level> Joe Perches
                                       ` (4 subsequent siblings)
  7 siblings, 2 replies; 36+ messages in thread
From: Joe Perches @ 2011-10-10  8:08 UTC (permalink / raw)
  To: Jan Kara; +Cc: NamJae Jeon, linux-kernel

Rename udf_warning to udf_warn for consistency with normal logging
uses of pr_warn.

Rename function udf_warning to _udf_warn.
Remove __func__ from uses and move __func__ to a new udf_warn
macro that calls _udf_warn.
Add \n's to uses of udf_warn, remove \n from _udf_warn.
Coalesce formats.

Signed-off-by: Joe Perches <joe@perches.com>
---
 fs/udf/namei.c     |    5 ++---
 fs/udf/partition.c |    3 +--
 fs/udf/super.c     |   22 ++++++++--------------
 fs/udf/udfdecl.h   |    5 ++++-
 4 files changed, 15 insertions(+), 20 deletions(-)

diff --git a/fs/udf/namei.c b/fs/udf/namei.c
index f1dce84..78d59eb 100644
--- a/fs/udf/namei.c
+++ b/fs/udf/namei.c
@@ -799,9 +799,8 @@ static int udf_rmdir(struct inode *dir, struct dentry *dentry)
 	if (retval)
 		goto end_rmdir;
 	if (inode->i_nlink != 2)
-		udf_warning(inode->i_sb, "udf_rmdir",
-			    "empty directory has nlink != 2 (%d)",
-			    inode->i_nlink);
+		udf_warn(inode->i_sb, "empty directory has nlink != 2 (%d)\n",
+			 inode->i_nlink);
 	clear_nlink(inode);
 	inode->i_size = 0;
 	inode_dec_link_count(dir);
diff --git a/fs/udf/partition.c b/fs/udf/partition.c
index a71090e..c72edb2 100644
--- a/fs/udf/partition.c
+++ b/fs/udf/partition.c
@@ -322,8 +322,7 @@ uint32_t udf_get_pblock_meta25(struct super_block *sb, uint32_t block,
 	BUG_ON(!inode);
 	retblk = udf_try_read_meta(inode, block, partition, offset);
 	if (retblk == 0xFFFFFFFF) {
-		udf_warning(sb, __func__, "error reading from METADATA, "
-			"trying to read from MIRROR");
+		udf_warn(sb, "error reading from METADATA, trying to read from MIRROR\n");
 		inode = mdata->s_mirror_fe;
 		if (!inode)
 			return 0xFFFFFFFF;
diff --git a/fs/udf/super.c b/fs/udf/super.c
index 76cc08f..622331f 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -855,13 +855,11 @@ static int udf_load_metadata_files(struct super_block *sb, int partition)
 	mdata->s_metadata_fe = udf_iget(sb, &addr);
 
 	if (mdata->s_metadata_fe == NULL) {
-		udf_warning(sb, __func__, "metadata inode efe not found, "
-				"will try mirror inode.");
+		udf_warn(sb, "metadata inode efe not found, will try mirror inode\n");
 		fe_error = 1;
 	} else if (UDF_I(mdata->s_metadata_fe)->i_alloc_type !=
 		 ICBTAG_FLAG_AD_SHORT) {
-		udf_warning(sb, __func__, "metadata inode efe does not have "
-			"short allocation descriptors!");
+		udf_warn(sb, "metadata inode efe does not have short allocation descriptors!\n");
 		fe_error = 1;
 		iput(mdata->s_metadata_fe);
 		mdata->s_metadata_fe = NULL;
@@ -881,12 +879,10 @@ static int udf_load_metadata_files(struct super_block *sb, int partition)
 			udf_err(sb, "mirror inode efe not found and metadata inode is missing too, exiting...\n");
 			goto error_exit;
 		} else
-			udf_warning(sb, __func__, "mirror inode efe not found,"
-					" but metadata inode is OK");
+			udf_warn(sb, "mirror inode efe not found, but metadata inode is OK\n");
 	} else if (UDF_I(mdata->s_mirror_fe)->i_alloc_type !=
 		 ICBTAG_FLAG_AD_SHORT) {
-		udf_warning(sb, __func__, "mirror inode efe does not have "
-			"short allocation descriptors!");
+		udf_warn(sb, "mirror inode efe does not have short allocation descriptors!\n");
 		iput(mdata->s_mirror_fe);
 		mdata->s_mirror_fe = NULL;
 		if (fe_error)
@@ -909,9 +905,7 @@ static int udf_load_metadata_files(struct super_block *sb, int partition)
 
 		if (mdata->s_bitmap_fe == NULL) {
 			if (sb->s_flags & MS_RDONLY)
-				udf_warning(sb, __func__, "bitmap inode efe "
-					"not found but it's ok since the disc"
-					" is mounted read-only");
+				udf_warn(sb, "bitmap inode efe not found but it's ok since the disc is mounted read-only\n");
 			else {
 				udf_err(sb, "bitmap inode efe not found and attempted read-write mount\n");
 				goto error_exit;
@@ -2105,15 +2099,15 @@ void _udf_err(struct super_block *sb, const char *function,
 	       sb->s_id, function, error_buf);
 }
 
-void udf_warning(struct super_block *sb, const char *function,
-		 const char *fmt, ...)
+void _udf_warn(struct super_block *sb, const char *function,
+	       const char *fmt, ...)
 {
 	va_list args;
 
 	va_start(args, fmt);
 	vsnprintf(error_buf, sizeof(error_buf), fmt, args);
 	va_end(args);
-	printk(KERN_WARNING "UDF-fs warning (device %s): %s: %s\n",
+	printk(KERN_WARNING "UDF-fs warning (device %s): %s: %s",
 	       sb->s_id, function, error_buf);
 }
 
diff --git a/fs/udf/udfdecl.h b/fs/udf/udfdecl.h
index 7bc3ba1..85e15ed 100644
--- a/fs/udf/udfdecl.h
+++ b/fs/udf/udfdecl.h
@@ -30,7 +30,10 @@ do { \
 #endif
 
 __attribute__((format(printf, 3, 4)))
-extern void udf_warning(struct super_block *, const char *, const char *, ...);
+extern void _udf_warn(struct super_block *sb, const char *function,
+		      const char *fmt, ...);
+#define udf_warn(sb, fmt, ...)					\
+	_udf_warn(sb, __func__, fmt, ##__VA_ARGS__)
 
 __attribute__((format(printf, 3, 4)))
 extern void _udf_err(struct super_block *sb, const char *function,
-- 
1.7.6.405.gc1be0


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH 4/6] udf: Convert printks to pr_<level>
  2011-10-10  8:08                   ` [PATCH 0/6] udf: Change some KERN_<level>s and logging neatening Joe Perches
                                       ` (2 preceding siblings ...)
  2011-10-10  8:08                     ` [PATCH 3/6] udf: Rename udf_warn to udf_warn Joe Perches
@ 2011-10-10  8:08                     ` Joe Perches
  2011-10-10 10:21                       ` NamJae Jeon
  2011-10-10 14:59                       ` Jan Kara
  2011-10-10  8:08                     ` [PATCH 5/6] udf: Neaten logging output, use vsprintf extension %pV Joe Perches
                                       ` (3 subsequent siblings)
  7 siblings, 2 replies; 36+ messages in thread
From: Joe Perches @ 2011-10-10  8:08 UTC (permalink / raw)
  To: Jan Kara; +Cc: NamJae Jeon, linux-kernel

Use the current logging styles.

Convert a few printks that should have been udf_warn and udf_err.
Coalesce formats.  Add #define pr_fmt.
Move an #include "udfdecls.h" above other includes in udftime.c
so pr_fmt works correctly.  Strip prefixes from conversions as appropriate.
Reorder logging definitions in udfdecl.h

Signed-off-by: Joe Perches <joe@perches.com>
---
 fs/udf/directory.c |    4 +-
 fs/udf/inode.c     |   33 +++++++++++--------------
 fs/udf/super.c     |   67 +++++++++++++++++++++------------------------------
 fs/udf/truncate.c  |   21 +++++++---------
 fs/udf/udfdecl.h   |   38 ++++++++++++++--------------
 fs/udf/udftime.c   |    3 +-
 fs/udf/unicode.c   |    6 ++--
 7 files changed, 77 insertions(+), 95 deletions(-)

diff --git a/fs/udf/directory.c b/fs/udf/directory.c
index 2ffdb67..4e08438 100644
--- a/fs/udf/directory.c
+++ b/fs/udf/directory.c
@@ -201,7 +201,7 @@ struct short_ad *udf_get_fileshortad(uint8_t *ptr, int maxoffset, uint32_t *offs
 	struct short_ad *sa;
 
 	if ((!ptr) || (!offset)) {
-		printk(KERN_ERR "udf: udf_get_fileshortad() invalidparms\n");
+		pr_err("%s: invalidparms\n", __func__);
 		return NULL;
 	}
 
@@ -223,7 +223,7 @@ struct long_ad *udf_get_filelongad(uint8_t *ptr, int maxoffset, uint32_t *offset
 	struct long_ad *la;
 
 	if ((!ptr) || (!offset)) {
-		printk(KERN_ERR "udf: udf_get_filelongad() invalidparms\n");
+		pr_err("%s: invalidparms\n", __func__);
 		return NULL;
 	}
 
diff --git a/fs/udf/inode.c b/fs/udf/inode.c
index 1d1358e..663b04b 100644
--- a/fs/udf/inode.c
+++ b/fs/udf/inode.c
@@ -83,12 +83,10 @@ void udf_evict_inode(struct inode *inode)
 	end_writeback(inode);
 	if (iinfo->i_alloc_type != ICBTAG_FLAG_AD_IN_ICB &&
 	    inode->i_size != iinfo->i_lenExtents) {
-		printk(KERN_WARNING "UDF-fs (%s): Inode %lu (mode %o) has "
-			"inode size %llu different from extent length %llu. "
-			"Filesystem need not be standards compliant.\n",
-			inode->i_sb->s_id, inode->i_ino, inode->i_mode,
-			(unsigned long long)inode->i_size,
-			(unsigned long long)iinfo->i_lenExtents);
+		udf_warn(inode->i_sb, "Inode %lu (mode %o) has inode size %llu different from extent length %llu. Filesystem need not be standards compliant.\n",
+			 inode->i_ino, inode->i_mode,
+			 (unsigned long long)inode->i_size,
+			 (unsigned long long)iinfo->i_lenExtents);
 	}
 	kfree(iinfo->i_ext.i_data);
 	iinfo->i_ext.i_data = NULL;
@@ -1169,16 +1167,15 @@ static void __udf_read_inode(struct inode *inode)
 	 */
 	bh = udf_read_ptagged(inode->i_sb, &iinfo->i_location, 0, &ident);
 	if (!bh) {
-		printk(KERN_ERR "udf: udf_read_inode(ino %ld) failed !bh\n",
-		       inode->i_ino);
+		udf_err(inode->i_sb, "(ino %ld) failed !bh\n", inode->i_ino);
 		make_bad_inode(inode);
 		return;
 	}
 
 	if (ident != TAG_IDENT_FE && ident != TAG_IDENT_EFE &&
 	    ident != TAG_IDENT_USE) {
-		printk(KERN_ERR "udf: udf_read_inode(ino %ld) "
-				"failed ident=%d\n", inode->i_ino, ident);
+		udf_err(inode->i_sb, "(ino %ld) failed ident=%d\n",
+			inode->i_ino, ident);
 		brelse(bh);
 		make_bad_inode(inode);
 		return;
@@ -1218,7 +1215,7 @@ static void __udf_read_inode(struct inode *inode)
 		}
 		brelse(ibh);
 	} else if (fe->icbTag.strategyType != cpu_to_le16(4)) {
-		printk(KERN_ERR "udf: unsupported strategy type: %d\n",
+		pr_err("unsupported strategy type: %d\n",
 		       le16_to_cpu(fe->icbTag.strategyType));
 		brelse(bh);
 		make_bad_inode(inode);
@@ -1413,9 +1410,8 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh)
 		udf_debug("METADATA BITMAP FILE-----\n");
 		break;
 	default:
-		printk(KERN_ERR "udf: udf_fill_inode(ino %ld) failed unknown "
-				"file type=%d\n", inode->i_ino,
-				fe->icbTag.fileType);
+		udf_err(inode->i_sb, "(ino %ld) failed unknown file type=%d\n",
+			inode->i_ino, fe->icbTag.fileType);
 		make_bad_inode(inode);
 		return;
 	}
@@ -1438,8 +1434,8 @@ static int udf_alloc_i_data(struct inode *inode, size_t size)
 	iinfo->i_ext.i_data = kmalloc(size, GFP_KERNEL);
 
 	if (!iinfo->i_ext.i_data) {
-		printk(KERN_ERR "udf:udf_alloc_i_data (ino %ld) "
-				"no free memory\n", inode->i_ino);
+		udf_err(inode->i_sb, "(ino %ld) no free memory\n",
+			inode->i_ino);
 		return -ENOMEM;
 	}
 
@@ -1689,9 +1685,8 @@ out:
 	if (do_sync) {
 		sync_dirty_buffer(bh);
 		if (buffer_write_io_error(bh)) {
-			printk(KERN_WARNING "IO error syncing udf inode "
-				"[%s:%08lx]\n", inode->i_sb->s_id,
-				inode->i_ino);
+			udf_warn(inode->i_sb, "IO error syncing udf inode [%08lx]\n",
+				 inode->i_ino);
 			err = -EIO;
 		}
 	}
diff --git a/fs/udf/super.c b/fs/udf/super.c
index 622331f..ea1b44b 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -547,8 +547,7 @@ static int udf_parse_options(char *options, struct udf_options *uopt,
 			uopt->dmode = option & 0777;
 			break;
 		default:
-			printk(KERN_ERR "udf: bad mount option \"%s\" "
-			       "or missing value\n", p);
+			pr_err("bad mount option \"%s\" or missing value\n", p);
 			return 0;
 		}
 	}
@@ -1106,11 +1105,9 @@ static int udf_load_vat(struct super_block *sb, int p_index, int type1_index)
 	udf_find_vat_block(sb, p_index, type1_index, sbi->s_last_block);
 	if (!sbi->s_vat_inode &&
 	    sbi->s_last_block != blocks - 1) {
-		printk(KERN_NOTICE "UDF-fs: Failed to read VAT inode from the"
-		       " last recorded block (%lu), retrying with the last "
-		       "block of the device (%lu).\n",
-		       (unsigned long)sbi->s_last_block,
-		       (unsigned long)blocks - 1);
+		pr_notice("Failed to read VAT inode from the last recorded block (%lu), retrying with the last block of the device (%lu).\n",
+			  (unsigned long)sbi->s_last_block,
+			  (unsigned long)blocks - 1);
 		udf_find_vat_block(sb, p_index, type1_index, blocks - 1);
 	}
 	if (!sbi->s_vat_inode)
@@ -1208,8 +1205,7 @@ static int udf_load_partdesc(struct super_block *sb, sector_t block)
 	if (map->s_partition_type == UDF_METADATA_MAP25) {
 		ret = udf_load_metadata_files(sb, i);
 		if (ret) {
-			printk(KERN_ERR "UDF-fs: error loading MetaData "
-			"partition map %d\n", i);
+			pr_err("error loading MetaData partition map %d\n", i);
 			goto out_bh;
 		}
 	} else {
@@ -1222,9 +1218,7 @@ static int udf_load_partdesc(struct super_block *sb, sector_t block)
 		 * overwrite blocks instead of relocating them).
 		 */
 		sb->s_flags |= MS_RDONLY;
-		printk(KERN_NOTICE "UDF-fs: Filesystem marked read-only "
-			"because writing to pseudooverwrite partition is "
-			"not implemented.\n");
+		pr_notice("Filesystem marked read-only because writing to pseudooverwrite partition is not implemented\n");
 	}
 out_bh:
 	/* In case loading failed, we handle cleanup in udf_fill_super */
@@ -1466,9 +1460,8 @@ static noinline int udf_process_sequence(struct super_block *sb, long block,
 
 		bh = udf_read_tagged(sb, block, block, &ident);
 		if (!bh) {
-			printk(KERN_ERR "udf: Block %Lu of volume descriptor "
-			       "sequence is corrupted or we could not read "
-			       "it.\n", (unsigned long long)block);
+			pr_err("Block %llu of volume descriptor sequence is corrupted or we could not read it\n",
+			       (unsigned long long)block);
 			return 1;
 		}
 
@@ -1541,7 +1534,7 @@ static noinline int udf_process_sequence(struct super_block *sb, long block,
 	 * in a suitable order
 	 */
 	if (!vds[VDS_POS_PRIMARY_VOL_DESC].block) {
-		printk(KERN_ERR "udf: Primary Volume Descriptor not found!\n");
+		pr_err("Primary Volume Descriptor not found!\n");
 		return 1;
 	}
 	if (udf_load_pvoldesc(sb, vds[VDS_POS_PRIMARY_VOL_DESC].block))
@@ -1728,7 +1721,7 @@ static int udf_load_vrs(struct super_block *sb, struct udf_options *uopt,
 
 	if (!sb_set_blocksize(sb, uopt->blocksize)) {
 		if (!silent)
-			printk(KERN_WARNING "UDF-fs: Bad block size\n");
+			pr_warn("Bad block size\n");
 		return 0;
 	}
 	sbi->s_last_block = uopt->lastblock;
@@ -1737,7 +1730,7 @@ static int udf_load_vrs(struct super_block *sb, struct udf_options *uopt,
 		nsr_off = udf_check_vsd(sb);
 		if (!nsr_off) {
 			if (!silent)
-				printk(KERN_WARNING "UDF-fs: No VRS found\n");
+				pr_warn("No VRS found\n");
 			return 0;
 		}
 		if (nsr_off == -1)
@@ -1753,7 +1746,7 @@ static int udf_load_vrs(struct super_block *sb, struct udf_options *uopt,
 	sbi->s_anchor = uopt->anchor;
 	if (!udf_find_anchor(sb, fileset)) {
 		if (!silent)
-			printk(KERN_WARNING "UDF-fs: No anchor found\n");
+			pr_warn("No anchor found\n");
 		return 0;
 	}
 	return 1;
@@ -1974,15 +1967,14 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
 		ret = udf_load_vrs(sb, &uopt, silent, &fileset);
 		if (!ret && uopt.blocksize != UDF_DEFAULT_BLOCKSIZE) {
 			if (!silent)
-				printk(KERN_NOTICE
-				       "UDF-fs: Rescanning with blocksize "
-				       "%d\n", UDF_DEFAULT_BLOCKSIZE);
+				pr_notice("Rescanning with blocksize %d\n",
+					  UDF_DEFAULT_BLOCKSIZE);
 			uopt.blocksize = UDF_DEFAULT_BLOCKSIZE;
 			ret = udf_load_vrs(sb, &uopt, silent, &fileset);
 		}
 	}
 	if (!ret) {
-		printk(KERN_WARNING "UDF-fs: No partition found (1)\n");
+		pr_warn("No partition found (1)\n");
 		goto error_out;
 	}
 
@@ -1997,8 +1989,7 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
 				le16_to_cpu(lvidiu->maxUDFWriteRev); */
 
 		if (minUDFReadRev > UDF_MAX_READ_VERSION) {
-			printk(KERN_ERR "UDF-fs: minUDFReadRev=%x "
-					"(max is %x)\n",
+			pr_err("minUDFReadRev=%x (max is %x)\n",
 			       le16_to_cpu(lvidiu->minUDFReadRev),
 			       UDF_MAX_READ_VERSION);
 			goto error_out;
@@ -2014,28 +2005,27 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
 	}
 
 	if (!sbi->s_partitions) {
-		printk(KERN_WARNING "UDF-fs: No partition found (2)\n");
+		pr_warn("No partition found (2)\n");
 		goto error_out;
 	}
 
 	if (sbi->s_partmaps[sbi->s_partition].s_partition_flags &
 			UDF_PART_FLAG_READ_ONLY) {
-		printk(KERN_NOTICE "UDF-fs: Partition marked readonly; "
-				   "forcing readonly mount\n");
+		pr_notice("Partition marked readonly; forcing readonly mount\n");
 		sb->s_flags |= MS_RDONLY;
 	}
 
 	if (udf_find_fileset(sb, &fileset, &rootdir)) {
-		printk(KERN_WARNING "UDF-fs: No fileset found\n");
+		pr_warn("No fileset found\n");
 		goto error_out;
 	}
 
 	if (!silent) {
 		struct timestamp ts;
 		udf_time_to_disk_stamp(&ts, sbi->s_record_time);
-		udf_info("UDF: Mounting volume '%s', "
-			 "timestamp %04u/%02u/%02u %02u:%02u (%x)\n",
-			 sbi->s_volume_ident, le16_to_cpu(ts.year), ts.month, ts.day,
+		udf_info("Mounting volume '%s', timestamp %04u/%02u/%02u %02u:%02u (%x)\n",
+			 sbi->s_volume_ident,
+			 le16_to_cpu(ts.year), ts.month, ts.day,
 			 ts.hour, ts.minute, le16_to_cpu(ts.typeAndTimezone));
 	}
 	if (!(sb->s_flags & MS_RDONLY))
@@ -2046,8 +2036,7 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
 	/* perhaps it's not extensible enough, but for now ... */
 	inode = udf_iget(sb, &rootdir);
 	if (!inode) {
-		printk(KERN_ERR "UDF-fs: Error in udf_iget, block=%d, "
-				"partition=%d\n",
+		pr_err("Error in udf_iget, block=%d, partition=%d\n",
 		       rootdir.logicalBlockNum, rootdir.partitionReferenceNum);
 		goto error_out;
 	}
@@ -2055,7 +2044,7 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
 	/* Allocate a dentry for the root inode */
 	sb->s_root = d_alloc_root(inode);
 	if (!sb->s_root) {
-		printk(KERN_ERR "UDF-fs: Couldn't allocate root dentry\n");
+		pr_err("Couldn't allocate root dentry\n");
 		iput(inode);
 		goto error_out;
 	}
@@ -2095,7 +2084,7 @@ void _udf_err(struct super_block *sb, const char *function,
 	va_start(args, fmt);
 	vsnprintf(error_buf, sizeof(error_buf), fmt, args);
 	va_end(args);
-	printk(KERN_CRIT "UDF-fs error (device %s): %s: %s",
+	pr_crit("error (device %s): %s: %s",
 	       sb->s_id, function, error_buf);
 }
 
@@ -2107,7 +2096,7 @@ void _udf_warn(struct super_block *sb, const char *function,
 	va_start(args, fmt);
 	vsnprintf(error_buf, sizeof(error_buf), fmt, args);
 	va_end(args);
-	printk(KERN_WARNING "UDF-fs warning (device %s): %s: %s",
+	pr_warn("warning (device %s): %s: %s",
 	       sb->s_id, function, error_buf);
 }
 
@@ -2200,11 +2189,11 @@ static unsigned int udf_count_free_bitmap(struct super_block *sb,
 	bh = udf_read_ptagged(sb, &loc, 0, &ident);
 
 	if (!bh) {
-		printk(KERN_ERR "udf: udf_count_free failed\n");
+		pr_err("udf_count_free failed\n");
 		goto out;
 	} else if (ident != TAG_IDENT_SBD) {
 		brelse(bh);
-		printk(KERN_ERR "udf: udf_count_free failed\n");
+		pr_err("udf_count_free failed\n");
 		goto out;
 	}
 
diff --git a/fs/udf/truncate.c b/fs/udf/truncate.c
index 8424308..d6225b3 100644
--- a/fs/udf/truncate.c
+++ b/fs/udf/truncate.c
@@ -95,23 +95,20 @@ void udf_truncate_tail_extent(struct inode *inode)
 		lbcount += elen;
 		if (lbcount > inode->i_size) {
 			if (lbcount - inode->i_size >= inode->i_sb->s_blocksize)
-				printk(KERN_WARNING
-				       "udf_truncate_tail_extent(): Too long "
-				       "extent after EOF in inode %u: i_size: "
-				       "%Ld lbcount: %Ld extent %u+%u\n",
-				       (unsigned)inode->i_ino,
-				       (long long)inode->i_size,
-				       (long long)lbcount,
-				       (unsigned)eloc.logicalBlockNum,
-				       (unsigned)elen);
+				pr_warn("%s: Too long extent after EOF in inode %u: i_size: %lld lbcount: %lld extent %u+%u\n",
+					__func__,
+					(unsigned)inode->i_ino,
+					(long long)inode->i_size,
+					(long long)lbcount,
+					(unsigned)eloc.logicalBlockNum,
+					(unsigned)elen);
 			nelen = elen - (lbcount - inode->i_size);
 			epos.offset -= adsize;
 			extent_trunc(inode, &epos, &eloc, etype, elen, nelen);
 			epos.offset += adsize;
 			if (udf_next_aext(inode, &epos, &eloc, &elen, 1) != -1)
-				printk(KERN_ERR "udf_truncate_tail_extent(): "
-				       "Extent after EOF in inode %u.\n",
-				       (unsigned)inode->i_ino);
+				pr_err("%s: Extent after EOF in inode %u\n",
+				       __func__, (unsigned)inode->i_ino);
 			break;
 		}
 	}
diff --git a/fs/udf/udfdecl.h b/fs/udf/udfdecl.h
index 85e15ed..f7273fb 100644
--- a/fs/udf/udfdecl.h
+++ b/fs/udf/udfdecl.h
@@ -1,6 +1,8 @@
 #ifndef __UDF_DECL_H
 #define __UDF_DECL_H
 
+#define pr_fmt(fmt) "UDF-fs: " fmt
+
 #include "ecma_167.h"
 #include "osta_udf.h"
 
@@ -16,18 +18,11 @@
 #define UDF_PREALLOCATE
 #define UDF_DEFAULT_PREALLOC_BLOCKS	8
 
-#undef UDFFS_DEBUG
-
-#ifdef UDFFS_DEBUG
-#define udf_debug(f, a...) \
-do { \
-	printk(KERN_DEBUG "UDF-fs DEBUG %s:%d:%s: ", \
-		__FILE__, __LINE__, __func__); \
-	printk(f, ##a); \
-} while (0)
-#else
-#define udf_debug(f, a...) /**/
-#endif
+__attribute__((format(printf, 3, 4)))
+extern void _udf_err(struct super_block *sb, const char *function,
+		     const char *fmt, ...);
+#define udf_err(sb, fmt, ...)					\
+	_udf_err(sb, __func__, fmt, ##__VA_ARGS__)
 
 __attribute__((format(printf, 3, 4)))
 extern void _udf_warn(struct super_block *sb, const char *function,
@@ -35,14 +30,19 @@ extern void _udf_warn(struct super_block *sb, const char *function,
 #define udf_warn(sb, fmt, ...)					\
 	_udf_warn(sb, __func__, fmt, ##__VA_ARGS__)
 
-__attribute__((format(printf, 3, 4)))
-extern void _udf_err(struct super_block *sb, const char *function,
-		     const char *fmt, ...);
-#define udf_err(sb, fmt, ...)					\
-	_udf_err(sb, __func__, fmt, ##__VA_ARGS__)
+#define udf_info(fmt, ...)					\
+	pr_info("INFO " fmt, ##__VA_ARGS__)
 
-#define udf_info(f, a...) \
-	printk(KERN_INFO "UDF-fs INFO " f, ##a);
+#undef UDFFS_DEBUG
+
+#ifdef UDFFS_DEBUG
+#define udf_debug(fmt, ...)					\
+	printk(KERN_DEBUG pr_fmt("%s:%d:%s: " fmt),		\
+	       __FILE__, __LINE__, __func__, ##__VA_ARGS_)
+#else
+#define udf_debug(fmt, ...)					\
+	no_printk(fmt, ##__VA_ARGS__)
+#endif
 
 #define udf_fixed_to_variable(x) ( ( ( (x) >> 5 ) * 39 ) + ( (x) & 0x0000001F ) )
 #define udf_variable_to_fixed(x) ( ( ( (x) / 39 ) << 5 ) + ( (x) % 39 ) )
diff --git a/fs/udf/udftime.c b/fs/udf/udftime.c
index b8c828c..1f11483 100644
--- a/fs/udf/udftime.c
+++ b/fs/udf/udftime.c
@@ -34,9 +34,10 @@
  * http://www.boulder.nist.gov/timefreq/pubs/bulletin/leapsecond.htm
  */
 
+#include "udfdecl.h"
+
 #include <linux/types.h>
 #include <linux/kernel.h>
-#include "udfdecl.h"
 
 #define EPOCH_YEAR 1970
 
diff --git a/fs/udf/unicode.c b/fs/udf/unicode.c
index d03a90b..44b815e 100644
--- a/fs/udf/unicode.c
+++ b/fs/udf/unicode.c
@@ -114,7 +114,7 @@ int udf_CS0toUTF8(struct ustr *utf_o, const struct ustr *ocu_i)
 	cmp_id = ocu_i->u_cmpID;
 	if (cmp_id != 8 && cmp_id != 16) {
 		memset(utf_o, 0, sizeof(struct ustr));
-		printk(KERN_ERR "udf: unknown compression code (%d) stri=%s\n",
+		pr_err("unknown compression code (%d) stri=%s\n",
 		       cmp_id, ocu_i->u_name);
 		return 0;
 	}
@@ -242,7 +242,7 @@ try_again:
 	if (utf_cnt) {
 error_out:
 		ocu[++u_len] = '?';
-		printk(KERN_DEBUG "udf: bad UTF-8 character\n");
+		printk(KERN_DEBUG pr_fmt("bad UTF-8 character\n"));
 	}
 
 	ocu[length - 1] = (uint8_t)u_len + 1;
@@ -267,7 +267,7 @@ static int udf_CS0toNLS(struct nls_table *nls, struct ustr *utf_o,
 	cmp_id = ocu_i->u_cmpID;
 	if (cmp_id != 8 && cmp_id != 16) {
 		memset(utf_o, 0, sizeof(struct ustr));
-		printk(KERN_ERR "udf: unknown compression code (%d) stri=%s\n",
+		pr_err("unknown compression code (%d) stri=%s\n",
 		       cmp_id, ocu_i->u_name);
 		return 0;
 	}
-- 
1.7.6.405.gc1be0


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH 5/6] udf: Neaten logging output, use vsprintf extension %pV
  2011-10-10  8:08                   ` [PATCH 0/6] udf: Change some KERN_<level>s and logging neatening Joe Perches
                                       ` (3 preceding siblings ...)
  2011-10-10  8:08                     ` [PATCH 4/6] udf: Convert printks to pr_<level> Joe Perches
@ 2011-10-10  8:08                     ` Joe Perches
  2011-10-10 10:22                       ` NamJae Jeon
  2011-10-10 15:04                       ` Jan Kara
  2011-10-10  8:08                     ` [PATCH 6/6] udf: Neaten udf_debug uses Joe Perches
                                       ` (2 subsequent siblings)
  7 siblings, 2 replies; 36+ messages in thread
From: Joe Perches @ 2011-10-10  8:08 UTC (permalink / raw)
  To: Jan Kara; +Cc: NamJae Jeon, linux-kernel

Remove the warning and error prefixes that duplicate KERN_<level>.
Use %pV and remove a static buffer to save some text space.

Signed-off-by: Joe Perches <joe@perches.com>
---
 fs/udf/super.c |   28 +++++++++++++++++-----------
 1 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/fs/udf/super.c b/fs/udf/super.c
index ea1b44b..b72c5ab 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -75,8 +75,6 @@
 
 #define UDF_DEFAULT_BLOCKSIZE 2048
 
-static char error_buf[1024];
-
 /* These are the "meat" - everything else is stuffing */
 static int udf_fill_super(struct super_block *, void *, int);
 static void udf_put_super(struct super_block *);
@@ -2075,29 +2073,37 @@ error_out:
 void _udf_err(struct super_block *sb, const char *function,
 	      const char *fmt, ...)
 {
+	struct va_format vaf;
 	va_list args;
 
-	if (!(sb->s_flags & MS_RDONLY)) {
-		/* mark sb error */
+	/* mark sb error */
+	if (!(sb->s_flags & MS_RDONLY))
 		sb->s_dirt = 1;
-	}
+
 	va_start(args, fmt);
-	vsnprintf(error_buf, sizeof(error_buf), fmt, args);
+
+	vaf.fmt = fmt;
+	vaf.va = &args;
+
+	pr_crit("device %s: %s: %pV", sb->s_id, function, &vaf);
+
 	va_end(args);
-	pr_crit("error (device %s): %s: %s",
-	       sb->s_id, function, error_buf);
 }
 
 void _udf_warn(struct super_block *sb, const char *function,
 	       const char *fmt, ...)
 {
+	struct va_format vaf;
 	va_list args;
 
 	va_start(args, fmt);
-	vsnprintf(error_buf, sizeof(error_buf), fmt, args);
+
+	vaf.fmt = fmt;
+	vaf.va = &args;
+
+	pr_warn("device %s: %s: %pV", sb->s_id, function, &vaf);
+
 	va_end(args);
-	pr_warn("warning (device %s): %s: %s",
-	       sb->s_id, function, error_buf);
 }
 
 static void udf_put_super(struct super_block *sb)
-- 
1.7.6.405.gc1be0


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH 6/6] udf: Neaten udf_debug uses
  2011-10-10  8:08                   ` [PATCH 0/6] udf: Change some KERN_<level>s and logging neatening Joe Perches
                                       ` (4 preceding siblings ...)
  2011-10-10  8:08                     ` [PATCH 5/6] udf: Neaten logging output, use vsprintf extension %pV Joe Perches
@ 2011-10-10  8:08                     ` Joe Perches
  2011-10-10 10:23                       ` NamJae Jeon
  2011-10-10 10:24                     ` [PATCH 0/6] udf: Change some KERN_<level>s and logging neatening NamJae Jeon
  2011-10-10 17:47                     ` Jan Kara
  7 siblings, 1 reply; 36+ messages in thread
From: Joe Perches @ 2011-10-10  8:08 UTC (permalink / raw)
  To: Jan Kara; +Cc: NamJae Jeon, linux-kernel

Just whitespace and argument alignment.
Introduce some checkpatch warnings that deserve to be ignored.

Signed-off-by: Joe Perches <joe@perches.com>
---
 fs/udf/balloc.c    |   14 +++++----
 fs/udf/directory.c |    4 +-
 fs/udf/inode.c     |    3 +-
 fs/udf/lowlevel.c  |    2 +-
 fs/udf/partition.c |    8 ++--
 fs/udf/super.c     |   78 ++++++++++++++++++++++-----------------------------
 6 files changed, 50 insertions(+), 59 deletions(-)

diff --git a/fs/udf/balloc.c b/fs/udf/balloc.c
index 95518a9..987585b 100644
--- a/fs/udf/balloc.c
+++ b/fs/udf/balloc.c
@@ -59,8 +59,8 @@ static int __load_block_bitmap(struct super_block *sb,
 	int nr_groups = bitmap->s_nr_groups;
 
 	if (block_group >= nr_groups) {
-		udf_debug("block_group (%d) > nr_groups (%d)\n", block_group,
-			  nr_groups);
+		udf_debug("block_group (%d) > nr_groups (%d)\n",
+			  block_group, nr_groups);
 	}
 
 	if (bitmap->s_block_bitmap[block_group]) {
@@ -126,8 +126,9 @@ static void udf_bitmap_free_blocks(struct super_block *sb,
 	if (bloc->logicalBlockNum + count < count ||
 	    (bloc->logicalBlockNum + count) > partmap->s_partition_len) {
 		udf_debug("%d < %d || %d + %d > %d\n",
-			  bloc->logicalBlockNum, 0, bloc->logicalBlockNum,
-			  count, partmap->s_partition_len);
+			  bloc->logicalBlockNum, 0,
+			  bloc->logicalBlockNum, count,
+			  partmap->s_partition_len);
 		goto error_return;
 	}
 
@@ -155,7 +156,7 @@ static void udf_bitmap_free_blocks(struct super_block *sb,
 			if (udf_set_bit(bit + i, bh->b_data)) {
 				udf_debug("bit %ld already set\n", bit + i);
 				udf_debug("byte=%2x\n",
-					((char *)bh->b_data)[(bit + i) >> 3]);
+					  ((char *)bh->b_data)[(bit + i) >> 3]);
 			}
 		}
 		udf_add_free_space(sb, sbi->s_partition, count);
@@ -369,7 +370,8 @@ static void udf_table_free_blocks(struct super_block *sb,
 	if (bloc->logicalBlockNum + count < count ||
 	    (bloc->logicalBlockNum + count) > partmap->s_partition_len) {
 		udf_debug("%d < %d || %d + %d > %d\n",
-			  bloc->logicalBlockNum, 0, bloc->logicalBlockNum, count,
+			  bloc->logicalBlockNum, 0,
+			  bloc->logicalBlockNum, count,
 			  partmap->s_partition_len);
 		goto error_return;
 	}
diff --git a/fs/udf/directory.c b/fs/udf/directory.c
index 4e08438..3e44f57 100644
--- a/fs/udf/directory.c
+++ b/fs/udf/directory.c
@@ -162,8 +162,8 @@ struct fileIdentDesc *udf_get_fileident(void *buffer, int bufsize, int *offset)
 	int padlen;
 
 	if ((!buffer) || (!offset)) {
-		udf_debug("invalidparms\n, buffer=%p, offset=%p\n", buffer,
-			  offset);
+		udf_debug("invalidparms, buffer=%p, offset=%p\n",
+			  buffer, offset);
 		return NULL;
 	}
 
diff --git a/fs/udf/inode.c b/fs/udf/inode.c
index 663b04b..ffc7e0c 100644
--- a/fs/udf/inode.c
+++ b/fs/udf/inode.c
@@ -1977,8 +1977,7 @@ int8_t udf_current_aext(struct inode *inode, struct extent_position *epos,
 		*elen = le32_to_cpu(lad->extLength) & UDF_EXTENT_LENGTH_MASK;
 		break;
 	default:
-		udf_debug("alloc_type = %d unsupported\n",
-				iinfo->i_alloc_type);
+		udf_debug("alloc_type = %d unsupported\n", iinfo->i_alloc_type);
 		return -1;
 	}
 
diff --git a/fs/udf/lowlevel.c b/fs/udf/lowlevel.c
index 43e24a3..6583fe9 100644
--- a/fs/udf/lowlevel.c
+++ b/fs/udf/lowlevel.c
@@ -38,7 +38,7 @@ unsigned int udf_get_last_session(struct super_block *sb)
 
 	if (i == 0) {
 		udf_debug("XA disk: %s, vol_desc_start=%d\n",
-			  (ms_info.xa_flag ? "yes" : "no"), ms_info.addr.lba);
+			  ms_info.xa_flag ? "yes" : "no", ms_info.addr.lba);
 		if (ms_info.xa_flag) /* necessary for a valid ms_info.addr */
 			vol_desc_start = ms_info.addr.lba;
 	} else {
diff --git a/fs/udf/partition.c b/fs/udf/partition.c
index c72edb2..f3e472c 100644
--- a/fs/udf/partition.c
+++ b/fs/udf/partition.c
@@ -33,8 +33,8 @@ uint32_t udf_get_pblock(struct super_block *sb, uint32_t block,
 	struct udf_sb_info *sbi = UDF_SB(sb);
 	struct udf_part_map *map;
 	if (partition >= sbi->s_partitions) {
-		udf_debug("block=%d, partition=%d, offset=%d: "
-			  "invalid partition\n", block, partition, offset);
+		udf_debug("block=%d, partition=%d, offset=%d: invalid partition\n",
+			  block, partition, offset);
 		return 0xFFFFFFFF;
 	}
 	map = &sbi->s_partmaps[partition];
@@ -60,8 +60,8 @@ uint32_t udf_get_pblock_virt15(struct super_block *sb, uint32_t block,
 	vdata = &map->s_type_specific.s_virtual;
 
 	if (block > vdata->s_num_entries) {
-		udf_debug("Trying to access block beyond end of VAT "
-			  "(%d max %d)\n", block, vdata->s_num_entries);
+		udf_debug("Trying to access block beyond end of VAT (%d max %d)\n",
+			  block, vdata->s_num_entries);
 		return 0xFFFFFFFF;
 	}
 
diff --git a/fs/udf/super.c b/fs/udf/super.c
index b72c5ab..622330c 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -639,20 +639,16 @@ static loff_t udf_check_vsd(struct super_block *sb)
 				udf_debug("ISO9660 Boot Record found\n");
 				break;
 			case 1:
-				udf_debug("ISO9660 Primary Volume Descriptor "
-					  "found\n");
+				udf_debug("ISO9660 Primary Volume Descriptor found\n");
 				break;
 			case 2:
-				udf_debug("ISO9660 Supplementary Volume "
-					  "Descriptor found\n");
+				udf_debug("ISO9660 Supplementary Volume Descriptor found\n");
 				break;
 			case 3:
-				udf_debug("ISO9660 Volume Partition Descriptor "
-					  "found\n");
+				udf_debug("ISO9660 Volume Partition Descriptor found\n");
 				break;
 			case 255:
-				udf_debug("ISO9660 Volume Descriptor Set "
-					  "Terminator found\n");
+				udf_debug("ISO9660 Volume Descriptor Set Terminator found\n");
 				break;
 			default:
 				udf_debug("ISO9660 VRS (%u) found\n",
@@ -803,8 +799,7 @@ static int udf_load_pvoldesc(struct super_block *sb, sector_t block)
 			      pvoldesc->recordingDateAndTime)) {
 #ifdef UDFFS_DEBUG
 		struct timestamp *ts = &pvoldesc->recordingDateAndTime;
-		udf_debug("recording time %04u/%02u/%02u"
-			  " %02u:%02u (%x)\n",
+		udf_debug("recording time %04u/%02u/%02u %02u:%02u (%x)\n",
 			  le16_to_cpu(ts->year), ts->month, ts->day, ts->hour,
 			  ts->minute, le16_to_cpu(ts->typeAndTimezone));
 #endif
@@ -815,7 +810,7 @@ static int udf_load_pvoldesc(struct super_block *sb, sector_t block)
 			strncpy(UDF_SB(sb)->s_volume_ident, outstr->u_name,
 				outstr->u_len > 31 ? 31 : outstr->u_len);
 			udf_debug("volIdent[] = '%s'\n",
-					UDF_SB(sb)->s_volume_ident);
+				  UDF_SB(sb)->s_volume_ident);
 		}
 
 	if (!udf_build_ustr(instr, pvoldesc->volSetIdent, 128))
@@ -847,7 +842,7 @@ static int udf_load_metadata_files(struct super_block *sb, int partition)
 	addr.partitionReferenceNum = map->s_partition_num;
 
 	udf_debug("Metadata file location: block = %d part = %d\n",
-			  addr.logicalBlockNum, addr.partitionReferenceNum);
+		  addr.logicalBlockNum, addr.partitionReferenceNum);
 
 	mdata->s_metadata_fe = udf_iget(sb, &addr);
 
@@ -867,7 +862,7 @@ static int udf_load_metadata_files(struct super_block *sb, int partition)
 	addr.partitionReferenceNum = map->s_partition_num;
 
 	udf_debug("Mirror metadata file location: block = %d part = %d\n",
-			  addr.logicalBlockNum, addr.partitionReferenceNum);
+		  addr.logicalBlockNum, addr.partitionReferenceNum);
 
 	mdata->s_mirror_fe = udf_iget(sb, &addr);
 
@@ -896,7 +891,7 @@ static int udf_load_metadata_files(struct super_block *sb, int partition)
 		addr.partitionReferenceNum = map->s_partition_num;
 
 		udf_debug("Bitmap file location: block = %d part = %d\n",
-			addr.logicalBlockNum, addr.partitionReferenceNum);
+			  addr.logicalBlockNum, addr.partitionReferenceNum);
 
 		mdata->s_bitmap_fe = udf_iget(sb, &addr);
 
@@ -988,10 +983,9 @@ static int udf_fill_partdesc_info(struct super_block *sb,
 	if (p->accessType == cpu_to_le32(PD_ACCESS_TYPE_OVERWRITABLE))
 		map->s_partition_flags |= UDF_PART_FLAG_OVERWRITABLE;
 
-	udf_debug("Partition (%d type %x) starts at physical %d, "
-		  "block length %d\n", p_index,
-		  map->s_partition_type, map->s_partition_root,
-		  map->s_partition_len);
+	udf_debug("Partition (%d type %x) starts at physical %d, block length %d\n",
+		  p_index, map->s_partition_type,
+		  map->s_partition_root, map->s_partition_len);
 
 	if (strcmp(p->partitionContents.ident, PD_PARTITION_CONTENTS_NSR02) &&
 	    strcmp(p->partitionContents.ident, PD_PARTITION_CONTENTS_NSR03))
@@ -1008,12 +1002,12 @@ static int udf_fill_partdesc_info(struct super_block *sb,
 		map->s_uspace.s_table = udf_iget(sb, &loc);
 		if (!map->s_uspace.s_table) {
 			udf_debug("cannot load unallocSpaceTable (part %d)\n",
-					p_index);
+				  p_index);
 			return 1;
 		}
 		map->s_partition_flags |= UDF_PART_FLAG_UNALLOC_TABLE;
 		udf_debug("unallocSpaceTable (part %d) @ %ld\n",
-				p_index, map->s_uspace.s_table->i_ino);
+			  p_index, map->s_uspace.s_table->i_ino);
 	}
 
 	if (phd->unallocSpaceBitmap.extLength) {
@@ -1026,8 +1020,8 @@ static int udf_fill_partdesc_info(struct super_block *sb,
 		bitmap->s_extPosition = le32_to_cpu(
 				phd->unallocSpaceBitmap.extPosition);
 		map->s_partition_flags |= UDF_PART_FLAG_UNALLOC_BITMAP;
-		udf_debug("unallocSpaceBitmap (part %d) @ %d\n", p_index,
-						bitmap->s_extPosition);
+		udf_debug("unallocSpaceBitmap (part %d) @ %d\n",
+			  p_index, bitmap->s_extPosition);
 	}
 
 	if (phd->partitionIntegrityTable.extLength)
@@ -1043,13 +1037,13 @@ static int udf_fill_partdesc_info(struct super_block *sb,
 		map->s_fspace.s_table = udf_iget(sb, &loc);
 		if (!map->s_fspace.s_table) {
 			udf_debug("cannot load freedSpaceTable (part %d)\n",
-				p_index);
+				  p_index);
 			return 1;
 		}
 
 		map->s_partition_flags |= UDF_PART_FLAG_FREED_TABLE;
 		udf_debug("freedSpaceTable (part %d) @ %ld\n",
-				p_index, map->s_fspace.s_table->i_ino);
+			  p_index, map->s_fspace.s_table->i_ino);
 	}
 
 	if (phd->freedSpaceBitmap.extLength) {
@@ -1062,8 +1056,8 @@ static int udf_fill_partdesc_info(struct super_block *sb,
 		bitmap->s_extPosition = le32_to_cpu(
 				phd->freedSpaceBitmap.extPosition);
 		map->s_partition_flags |= UDF_PART_FLAG_FREED_BITMAP;
-		udf_debug("freedSpaceBitmap (part %d) @ %d\n", p_index,
-					bitmap->s_extPosition);
+		udf_debug("freedSpaceBitmap (part %d) @ %d\n",
+			  p_index, bitmap->s_extPosition);
 	}
 	return 0;
 }
@@ -1324,9 +1318,8 @@ static int udf_load_logicalvol(struct super_block *sb, sector_t block,
 				struct metadataPartitionMap *mdm =
 						(struct metadataPartitionMap *)
 						&(lvd->partitionMaps[offset]);
-				udf_debug("Parsing Logical vol part %d "
-					"type %d  id=%s\n", i, type,
-					UDF_ID_METADATA);
+				udf_debug("Parsing Logical vol part %d type %d  id=%s\n",
+					  i, type, UDF_ID_METADATA);
 
 				map->s_partition_type = UDF_METADATA_MAP25;
 				map->s_partition_func = udf_get_pblock_meta25;
@@ -1345,21 +1338,20 @@ static int udf_load_logicalvol(struct super_block *sb, sector_t block,
 					mdm->flags & 0x01;
 
 				udf_debug("Metadata Ident suffix=0x%x\n",
-					(le16_to_cpu(
-					 ((__le16 *)
-					      mdm->partIdent.identSuffix)[0])));
+					  le16_to_cpu(*(__le16 *)
+						      mdm->partIdent.identSuffix));
 				udf_debug("Metadata part num=%d\n",
-					le16_to_cpu(mdm->partitionNum));
+					  le16_to_cpu(mdm->partitionNum));
 				udf_debug("Metadata part alloc unit size=%d\n",
-					le32_to_cpu(mdm->allocUnitSize));
+					  le32_to_cpu(mdm->allocUnitSize));
 				udf_debug("Metadata file loc=%d\n",
-					le32_to_cpu(mdm->metadataFileLoc));
+					  le32_to_cpu(mdm->metadataFileLoc));
 				udf_debug("Mirror file loc=%d\n",
-				       le32_to_cpu(mdm->metadataMirrorFileLoc));
+					  le32_to_cpu(mdm->metadataMirrorFileLoc));
 				udf_debug("Bitmap file loc=%d\n",
-				       le32_to_cpu(mdm->metadataBitmapFileLoc));
+					  le32_to_cpu(mdm->metadataBitmapFileLoc));
 				udf_debug("Duplicate Flag: %d %d\n",
-					mdata->s_dup_md_flag, mdm->flags);
+					  mdata->s_dup_md_flag, mdm->flags);
 			} else {
 				udf_debug("Unknown ident: %s\n",
 					  upm2->partIdent.ident);
@@ -1369,16 +1361,15 @@ static int udf_load_logicalvol(struct super_block *sb, sector_t block,
 			map->s_partition_num = le16_to_cpu(upm2->partitionNum);
 		}
 		udf_debug("Partition (%d:%d) type %d on volume %d\n",
-			  i, map->s_partition_num, type,
-			  map->s_volumeseqnum);
+			  i, map->s_partition_num, type, map->s_volumeseqnum);
 	}
 
 	if (fileset) {
 		struct long_ad *la = (struct long_ad *)&(lvd->logicalVolContentsUse[0]);
 
 		*fileset = lelb_to_cpu(la->extLocation);
-		udf_debug("FileSet found in LogicalVolDesc at block=%d, "
-			  "partition=%d\n", fileset->logicalBlockNum,
+		udf_debug("FileSet found in LogicalVolDesc at block=%d, partition=%d\n",
+			  fileset->logicalBlockNum,
 			  fileset->partitionReferenceNum);
 	}
 	if (lvd->integritySeqExt.extLength)
@@ -1732,8 +1723,7 @@ static int udf_load_vrs(struct super_block *sb, struct udf_options *uopt,
 			return 0;
 		}
 		if (nsr_off == -1)
-			udf_debug("Failed to read byte 32768. Assuming open "
-				  "disc. Skipping validity check\n");
+			udf_debug("Failed to read byte 32768. Assuming open disc. Skipping validity check\n");
 		if (!sbi->s_last_block)
 			sbi->s_last_block = udf_get_last_block(sb);
 	} else {
-- 
1.7.6.405.gc1be0


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* Re: [PATCH 1/6] udf: Promote some debugging messages to udf_error
  2011-10-10  8:08                     ` [PATCH 1/6] udf: Promote some debugging messages to udf_error Joe Perches
@ 2011-10-10 10:06                       ` NamJae Jeon
  2011-10-10 17:32                       ` Jan Kara
  1 sibling, 0 replies; 36+ messages in thread
From: NamJae Jeon @ 2011-10-10 10:06 UTC (permalink / raw)
  To: Joe Perches; +Cc: Jan Kara, linux-kernel

2011/10/10 Joe Perches <joe@perches.com>:
> If there is a problem with a scratched disc or loader,
> it's valuable to know which error occurred.
>
> Convert some debug messages to udf_error, neaten those messages too.
> Add the calculated tag checksum and the read checksum to error message.
> Make udf_error a public function and move the logging prototypes together.
>
> Original-patch-by: NamJae Jeon <linkinjeon@gmail.com>
> Signed-off-by: Joe Perches <joe@perches.com>
Reviewed-by: NamJae Jeon <linkinjeon@gmail.com>
> ---
>  fs/udf/misc.c    |   21 ++++++++++++++-------
>  fs/udf/super.c   |    6 ++----
>  fs/udf/udfdecl.h |    9 +++++++--
>  3 files changed, 23 insertions(+), 13 deletions(-)
>
> diff --git a/fs/udf/misc.c b/fs/udf/misc.c
> index 9215700..87667f8 100644
> --- a/fs/udf/misc.c
> +++ b/fs/udf/misc.c
> @@ -204,6 +204,7 @@ struct buffer_head *udf_read_tagged(struct super_block *sb, uint32_t block,
>  {
>        struct tag *tag_p;
>        struct buffer_head *bh = NULL;
> +       u8 checksum;
>
>        /* Read the block */
>        if (block == 0xFFFFFFFF)
> @@ -211,7 +212,7 @@ struct buffer_head *udf_read_tagged(struct super_block *sb, uint32_t block,
>
>        bh = udf_tread(sb, block);
>        if (!bh) {
> -               udf_debug("block=%d, location=%d: read failed\n",
> +               udf_error(sb, __func__, "read failed, block=%u, location=%d\n",
>                          block, location);
>                return NULL;
>        }
> @@ -221,21 +222,26 @@ struct buffer_head *udf_read_tagged(struct super_block *sb, uint32_t block,
>        *ident = le16_to_cpu(tag_p->tagIdent);
>
>        if (location != le32_to_cpu(tag_p->tagLocation)) {
> -               udf_debug("location mismatch block %u, tag %u != %u\n",
> +               udf_error(sb, __func__,
> +                         "location mismatch, block %u, tag %u != %u\n",
>                          block, le32_to_cpu(tag_p->tagLocation), location);
>                goto error_out;
>        }
>
>        /* Verify the tag checksum */
> -       if (udf_tag_checksum(tag_p) != tag_p->tagChecksum) {
> -               printk(KERN_ERR "udf: tag checksum failed block %d\n", block);
> +       checksum = udf_tag_checksum(tag_p);
> +       if (checksum != tag_p->tagChecksum) {
> +               udf_error(sb, __func__,
> +                         "tag checksum failed, block %u: 0x%02x != 0x%02x\n",
> +                         block, checksum, tag_p->tagChecksum);
>                goto error_out;
>        }
>
>        /* Verify the tag version */
>        if (tag_p->descVersion != cpu_to_le16(0x0002U) &&
>            tag_p->descVersion != cpu_to_le16(0x0003U)) {
> -               udf_debug("tag version 0x%04x != 0x0002 || 0x0003 block %d\n",
> +               udf_error(sb, __func__,
> +                         "tag version 0x%04x != 0x0002 || 0x0003, block %u\n",
>                          le16_to_cpu(tag_p->descVersion), block);
>                goto error_out;
>        }
> @@ -247,8 +253,9 @@ struct buffer_head *udf_read_tagged(struct super_block *sb, uint32_t block,
>                                        le16_to_cpu(tag_p->descCRCLength)))
>                return bh;
>
> -       udf_debug("Crc failure block %d: crc = %d, crclen = %d\n", block,
> -           le16_to_cpu(tag_p->descCRC), le16_to_cpu(tag_p->descCRCLength));
> +       udf_error(sb, __func__, "crc failure, block %u: crc = %d, crclen = %d\n",
> +                 block, le16_to_cpu(tag_p->descCRC),
> +                 le16_to_cpu(tag_p->descCRCLength));
>
>  error_out:
>        brelse(bh);
> diff --git a/fs/udf/super.c b/fs/udf/super.c
> index 7b27b06..80f47ce 100644
> --- a/fs/udf/super.c
> +++ b/fs/udf/super.c
> @@ -92,8 +92,6 @@ static void udf_close_lvid(struct super_block *);
>  static unsigned int udf_count_free(struct super_block *);
>  static int udf_statfs(struct dentry *, struct kstatfs *);
>  static int udf_show_options(struct seq_file *, struct vfsmount *);
> -static void udf_error(struct super_block *sb, const char *function,
> -                     const char *fmt, ...);
>
>  struct logicalVolIntegrityDescImpUse *udf_sb_lvidiu(struct udf_sb_info *sbi)
>  {
> @@ -2096,8 +2094,8 @@ error_out:
>        return -EINVAL;
>  }
>
> -static void udf_error(struct super_block *sb, const char *function,
> -                     const char *fmt, ...)
> +void udf_error(struct super_block *sb, const char *function,
> +              const char *fmt, ...)
>  {
>        va_list args;
>
> diff --git a/fs/udf/udfdecl.h b/fs/udf/udfdecl.h
> index dbd52d4b..81e66af 100644
> --- a/fs/udf/udfdecl.h
> +++ b/fs/udf/udfdecl.h
> @@ -29,6 +29,13 @@ do { \
>  #define udf_debug(f, a...) /**/
>  #endif
>
> +__attribute__((format(printf, 3, 4)))
> +extern void udf_warning(struct super_block *, const char *, const char *, ...);
> +
> +__attribute__((format(printf, 3, 4)))
> +extern void udf_error(struct super_block *sb, const char *function,
> +                     const char *fmt, ...);
> +
>  #define udf_info(f, a...) \
>        printk(KERN_INFO "UDF-fs INFO " f, ##a);
>
> @@ -112,8 +119,6 @@ struct extent_position {
>
>  /* super.c */
>
> -__attribute__((format(printf, 3, 4)))
> -extern void udf_warning(struct super_block *, const char *, const char *, ...);
>  static inline void udf_updated_lvid(struct super_block *sb)
>  {
>        struct buffer_head *bh = UDF_SB(sb)->s_lvid_bh;
> --
> 1.7.6.405.gc1be0
>
>

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 2/6] udf: Rename udf_error to udf_err
  2011-10-10  8:08                     ` [PATCH 2/6] udf: Rename udf_error to udf_err Joe Perches
@ 2011-10-10 10:18                       ` NamJae Jeon
  0 siblings, 0 replies; 36+ messages in thread
From: NamJae Jeon @ 2011-10-10 10:18 UTC (permalink / raw)
  To: Joe Perches; +Cc: Jan Kara, linux-kernel

2011/10/10 Joe Perches <joe@perches.com>:
> Rename udf_error to udf_err for consistency with normal logging
> uses of pr_err.
>
> Rename function udf_err to _udf_err.
> Remove __func__ from uses and move __func__ to a new udf_err
> macro that calls _udf_err.
> Some of the udf_error uses had \n terminations, some did not so
> standardize \n's to udf_err uses, remove \n from _udf_err function.
> Coalesce udf_err formats.
> One message prefixed with udf_read_super is now prefixed with
> udf_fill_super.
>
> Signed-off-by: Joe Perches <joe@perches.com>
Reviewed-by: NamJae Jeon <linkinjeon@gmail.com>

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 3/6] udf: Rename udf_warn to udf_warn
  2011-10-10  8:08                     ` [PATCH 3/6] udf: Rename udf_warn to udf_warn Joe Perches
@ 2011-10-10 10:18                       ` NamJae Jeon
  2011-10-10 18:25                       ` Paul Bolle
  1 sibling, 0 replies; 36+ messages in thread
From: NamJae Jeon @ 2011-10-10 10:18 UTC (permalink / raw)
  To: Joe Perches; +Cc: Jan Kara, linux-kernel

2011/10/10 Joe Perches <joe@perches.com>:
> Rename udf_warning to udf_warn for consistency with normal logging
> uses of pr_warn.
>
> Rename function udf_warning to _udf_warn.
> Remove __func__ from uses and move __func__ to a new udf_warn
> macro that calls _udf_warn.
> Add \n's to uses of udf_warn, remove \n from _udf_warn.
> Coalesce formats.
>
> Signed-off-by: Joe Perches <joe@perches.com>
Reviewed-by: NamJae Jeon <linkinjeon@gmail.com>
> ---

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 4/6] udf: Convert printks to pr_<level>
  2011-10-10  8:08                     ` [PATCH 4/6] udf: Convert printks to pr_<level> Joe Perches
@ 2011-10-10 10:21                       ` NamJae Jeon
  2011-10-10 14:59                       ` Jan Kara
  1 sibling, 0 replies; 36+ messages in thread
From: NamJae Jeon @ 2011-10-10 10:21 UTC (permalink / raw)
  To: Joe Perches; +Cc: Jan Kara, linux-kernel

2011/10/10 Joe Perches <joe@perches.com>:
> Use the current logging styles.
>
> Convert a few printks that should have been udf_warn and udf_err.
> Coalesce formats.  Add #define pr_fmt.
> Move an #include "udfdecls.h" above other includes in udftime.c
> so pr_fmt works correctly.  Strip prefixes from conversions as appropriate.
> Reorder logging definitions in udfdecl.h
>
> Signed-off-by: Joe Perches <joe@perches.com>
Reviewed-by: NamJae Jeon <linkinjeon@gmail.com>
> ---

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 5/6] udf: Neaten logging output, use vsprintf extension %pV
  2011-10-10  8:08                     ` [PATCH 5/6] udf: Neaten logging output, use vsprintf extension %pV Joe Perches
@ 2011-10-10 10:22                       ` NamJae Jeon
  2011-10-10 15:04                       ` Jan Kara
  1 sibling, 0 replies; 36+ messages in thread
From: NamJae Jeon @ 2011-10-10 10:22 UTC (permalink / raw)
  To: Joe Perches; +Cc: Jan Kara, linux-kernel

2011/10/10 Joe Perches <joe@perches.com>:
> Remove the warning and error prefixes that duplicate KERN_<level>.
> Use %pV and remove a static buffer to save some text space.
>
> Signed-off-by: Joe Perches <joe@perches.com>
Reviewed-by: NamJae Jeon <linkinjeon@gmail.com>
> ---

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 6/6] udf: Neaten udf_debug uses
  2011-10-10  8:08                     ` [PATCH 6/6] udf: Neaten udf_debug uses Joe Perches
@ 2011-10-10 10:23                       ` NamJae Jeon
  0 siblings, 0 replies; 36+ messages in thread
From: NamJae Jeon @ 2011-10-10 10:23 UTC (permalink / raw)
  To: Joe Perches; +Cc: Jan Kara, linux-kernel

2011/10/10 Joe Perches <joe@perches.com>:
> Just whitespace and argument alignment.
> Introduce some checkpatch warnings that deserve to be ignored.
>
> Signed-off-by: Joe Perches <joe@perches.com>
Reviewed-by: NamJae Jeon <linkinjeon@gmail.com>
> ---

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 0/6] udf: Change some KERN_<level>s and logging neatening
  2011-10-10  8:08                   ` [PATCH 0/6] udf: Change some KERN_<level>s and logging neatening Joe Perches
                                       ` (5 preceding siblings ...)
  2011-10-10  8:08                     ` [PATCH 6/6] udf: Neaten udf_debug uses Joe Perches
@ 2011-10-10 10:24                     ` NamJae Jeon
  2011-10-10 17:47                     ` Jan Kara
  7 siblings, 0 replies; 36+ messages in thread
From: NamJae Jeon @ 2011-10-10 10:24 UTC (permalink / raw)
  To: Joe Perches; +Cc: Jan Kara, linux-kernel

2011/10/10 Joe Perches <joe@perches.com>:
> I reviewed your patch and think it's too large
> for others to review because it combines multiple
> things into a single patch.
>
> I think that adding struct super_block * to udb_debug
> isn't necessary or particularly useful.
>
> Here are the changes to your original patch that I made:
>
> Separate a single large patch into reviewable chunks.
> Don't convert every message type to udf_<foo>.
Hi Joe.
Thank you, you are given a nice clean up.
>
> Joe Perches (6):
>  udf: Promote some debugging messages to udf_error
>  udf: Rename udf_error to udf_err
>  udf: Rename udf_warn to udf_warn
>  udf: Convert printks to pr_<level>
>  udf: Neaten logging output, use vsprintf extension %pV
>  udf: Neaten udf_debug uses
>
>  fs/udf/balloc.c    |   14 ++--
>  fs/udf/directory.c |    8 +-
>  fs/udf/inode.c     |   36 ++++-----
>  fs/udf/lowlevel.c  |    2 +-
>  fs/udf/misc.c      |   24 ++++---
>  fs/udf/namei.c     |    5 +-
>  fs/udf/partition.c |   11 +--
>  fs/udf/super.c     |  214 +++++++++++++++++++++++-----------------------------
>  fs/udf/truncate.c  |   21 ++---
>  fs/udf/udfdecl.h   |   35 ++++++---
>  fs/udf/udftime.c   |    3 +-
>  fs/udf/unicode.c   |    6 +-
>  12 files changed, 178 insertions(+), 201 deletions(-)
>
> --
> 1.7.6.405.gc1be0
>
>

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 4/6] udf: Convert printks to pr_<level>
  2011-10-10  8:08                     ` [PATCH 4/6] udf: Convert printks to pr_<level> Joe Perches
  2011-10-10 10:21                       ` NamJae Jeon
@ 2011-10-10 14:59                       ` Jan Kara
  2011-10-10 15:20                         ` Joe Perches
  2011-10-10 15:23                         ` Joe Perches
  1 sibling, 2 replies; 36+ messages in thread
From: Jan Kara @ 2011-10-10 14:59 UTC (permalink / raw)
  To: Joe Perches; +Cc: Jan Kara, NamJae Jeon, linux-kernel

On Mon 10-10-11 01:08:05, Joe Perches wrote:
> Use the current logging styles.
> 
> Convert a few printks that should have been udf_warn and udf_err.
> Coalesce formats.  Add #define pr_fmt.
> Move an #include "udfdecls.h" above other includes in udftime.c
> so pr_fmt works correctly.  Strip prefixes from conversions as appropriate.
> Reorder logging definitions in udfdecl.h
  Any reason why you didn't use udf_err() / udf_warn() in all the places
where sb pointer is available? Also I'd further use udf_err() in
udf_parse_options() - passing sb there is simple and additional information
in the message is useful. Thanks.

									Honza
-- 
Jan Kara <jack@suse.cz>
SUSE Labs, CR

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 5/6] udf: Neaten logging output, use vsprintf extension %pV
  2011-10-10  8:08                     ` [PATCH 5/6] udf: Neaten logging output, use vsprintf extension %pV Joe Perches
  2011-10-10 10:22                       ` NamJae Jeon
@ 2011-10-10 15:04                       ` Jan Kara
  2011-10-10 15:20                         ` Joe Perches
  1 sibling, 1 reply; 36+ messages in thread
From: Jan Kara @ 2011-10-10 15:04 UTC (permalink / raw)
  To: Joe Perches; +Cc: Jan Kara, NamJae Jeon, linux-kernel

On Mon 10-10-11 01:08:06, Joe Perches wrote:
> Remove the warning and error prefixes that duplicate KERN_<level>.
  Please keep that in the prefix. It's easier to read messages when they
are that way ...

> Use %pV and remove a static buffer to save some text space.
  This is actually a bugfix because we could corrupt error message when
several error messages would be reported in parallel... Thanks for finding
this.

								Honza  
> 
> Signed-off-by: Joe Perches <joe@perches.com>
> ---
>  fs/udf/super.c |   28 +++++++++++++++++-----------
>  1 files changed, 17 insertions(+), 11 deletions(-)
> 
> diff --git a/fs/udf/super.c b/fs/udf/super.c
> index ea1b44b..b72c5ab 100644
> --- a/fs/udf/super.c
> +++ b/fs/udf/super.c
> @@ -75,8 +75,6 @@
>  
>  #define UDF_DEFAULT_BLOCKSIZE 2048
>  
> -static char error_buf[1024];
> -
>  /* These are the "meat" - everything else is stuffing */
>  static int udf_fill_super(struct super_block *, void *, int);
>  static void udf_put_super(struct super_block *);
> @@ -2075,29 +2073,37 @@ error_out:
>  void _udf_err(struct super_block *sb, const char *function,
>  	      const char *fmt, ...)
>  {
> +	struct va_format vaf;
>  	va_list args;
>  
> -	if (!(sb->s_flags & MS_RDONLY)) {
> -		/* mark sb error */
> +	/* mark sb error */
> +	if (!(sb->s_flags & MS_RDONLY))
>  		sb->s_dirt = 1;
> -	}
> +
>  	va_start(args, fmt);
> -	vsnprintf(error_buf, sizeof(error_buf), fmt, args);
> +
> +	vaf.fmt = fmt;
> +	vaf.va = &args;
> +
> +	pr_crit("device %s: %s: %pV", sb->s_id, function, &vaf);
> +
>  	va_end(args);
> -	pr_crit("error (device %s): %s: %s",
> -	       sb->s_id, function, error_buf);
>  }
>  
>  void _udf_warn(struct super_block *sb, const char *function,
>  	       const char *fmt, ...)
>  {
> +	struct va_format vaf;
>  	va_list args;
>  
>  	va_start(args, fmt);
> -	vsnprintf(error_buf, sizeof(error_buf), fmt, args);
> +
> +	vaf.fmt = fmt;
> +	vaf.va = &args;
> +
> +	pr_warn("device %s: %s: %pV", sb->s_id, function, &vaf);
> +
>  	va_end(args);
> -	pr_warn("warning (device %s): %s: %s",
> -	       sb->s_id, function, error_buf);
>  }
>  
>  static void udf_put_super(struct super_block *sb)
-- 
Jan Kara <jack@suse.cz>
SUSE Labs, CR

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 4/6] udf: Convert printks to pr_<level>
  2011-10-10 14:59                       ` Jan Kara
@ 2011-10-10 15:20                         ` Joe Perches
  2011-10-10 15:23                         ` Joe Perches
  1 sibling, 0 replies; 36+ messages in thread
From: Joe Perches @ 2011-10-10 15:20 UTC (permalink / raw)
  To: Jan Kara; +Cc: NamJae Jeon, linux-kernel

On Mon, 2011-10-10 at 16:59 +0200, Jan Kara wrote:
> On Mon 10-10-11 01:08:05, Joe Perches wrote:
> > Use the current logging styles.
> > Convert a few printks that should have been udf_warn and udf_err.
> > Coalesce formats.  Add #define pr_fmt.
> > Move an #include "udfdecls.h" above other includes in udftime.c
> > so pr_fmt works correctly.  Strip prefixes from conversions as appropriate.
> > Reorder logging definitions in udfdecl.h
>   Any reason why you didn't use udf_err() / udf_warn() in all the places
> where sb pointer is available?

I did it in the places where sb was otherwise used
in the output message.

> Also I'd further use udf_err() in
> udf_parse_options() - passing sb there is simple and additional information
> in the message is useful. Thanks.

Maybe NamJae can do that in a follow-on patch.

NamJae, I broke up your larger patch so you could
see an example of the preferred form of smaller,
targeted patches.



^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 5/6] udf: Neaten logging output, use vsprintf extension %pV
  2011-10-10 15:04                       ` Jan Kara
@ 2011-10-10 15:20                         ` Joe Perches
  0 siblings, 0 replies; 36+ messages in thread
From: Joe Perches @ 2011-10-10 15:20 UTC (permalink / raw)
  To: Jan Kara; +Cc: NamJae Jeon, linux-kernel

On Mon, 2011-10-10 at 17:04 +0200, Jan Kara wrote:
> On Mon 10-10-11 01:08:06, Joe Perches wrote:
> > Remove the warning and error prefixes that duplicate KERN_<level>.
>   Please keep that in the prefix. It's easier to read messages when they
> are that way ...

I think duplicating kernel standard functionality
is not good and this merely increases logging buffer
size.

It's your code, you're the maintainer, fix it up
as you choose.


^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 4/6] udf: Convert printks to pr_<level>
  2011-10-10 14:59                       ` Jan Kara
  2011-10-10 15:20                         ` Joe Perches
@ 2011-10-10 15:23                         ` Joe Perches
  2011-10-10 16:41                           ` Jan Kara
  1 sibling, 1 reply; 36+ messages in thread
From: Joe Perches @ 2011-10-10 15:23 UTC (permalink / raw)
  To: Jan Kara; +Cc: NamJae Jeon, linux-kernel

On Mon, 2011-10-10 at 16:59 +0200, Jan Kara wrote:
> On Mon 10-10-11 01:08:05, Joe Perches wrote:
> > Use the current logging styles.
> > 
> > Convert a few printks that should have been udf_warn and udf_err.
> > Coalesce formats.  Add #define pr_fmt.
> > Move an #include "udfdecls.h" above other includes in udftime.c
> > so pr_fmt works correctly.  Strip prefixes from conversions as appropriate.
> > Reorder logging definitions in udfdecl.h
>   Any reason why you didn't use udf_err() / udf_warn() in all the places
> where sb pointer is available?

Oh, I forgot to mention that udf_err emits at KERN_CRIT.
I think that's not good.

It's either an error or it's a critical notification
and the pr_crit should be pr_err or the function should
be renamed.


^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 4/6] udf: Convert printks to pr_<level>
  2011-10-10 15:23                         ` Joe Perches
@ 2011-10-10 16:41                           ` Jan Kara
  2011-10-10 17:25                             ` Joe Perches
  0 siblings, 1 reply; 36+ messages in thread
From: Jan Kara @ 2011-10-10 16:41 UTC (permalink / raw)
  To: Joe Perches; +Cc: Jan Kara, NamJae Jeon, linux-kernel

On Mon 10-10-11 08:23:34, Joe Perches wrote:
> On Mon, 2011-10-10 at 16:59 +0200, Jan Kara wrote:
> > On Mon 10-10-11 01:08:05, Joe Perches wrote:
> > > Use the current logging styles.
> > > 
> > > Convert a few printks that should have been udf_warn and udf_err.
> > > Coalesce formats.  Add #define pr_fmt.
> > > Move an #include "udfdecls.h" above other includes in udftime.c
> > > so pr_fmt works correctly.  Strip prefixes from conversions as appropriate.
> > > Reorder logging definitions in udfdecl.h
> >   Any reason why you didn't use udf_err() / udf_warn() in all the places
> > where sb pointer is available?
> 
> Oh, I forgot to mention that udf_err emits at KERN_CRIT.
> I think that's not good.
> 
> It's either an error or it's a critical notification
> and the pr_crit should be pr_err or the function should
> be renamed.
  Yeah, good point. I've changed udf_err() to call pr_err() because
KERN_CRIT is really too much.

								Honza
-- 
Jan Kara <jack@suse.cz>
SUSE Labs, CR

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 4/6] udf: Convert printks to pr_<level>
  2011-10-10 16:41                           ` Jan Kara
@ 2011-10-10 17:25                             ` Joe Perches
  2011-10-10 17:40                               ` Jan Kara
  0 siblings, 1 reply; 36+ messages in thread
From: Joe Perches @ 2011-10-10 17:25 UTC (permalink / raw)
  To: Jan Kara; +Cc: linux-kernel, NamJae Jeon

On Mon, 2011-10-10 at 18:41 +0200, Jan Kara wrote:
> On Mon 10-10-11 08:23:34, Joe Perches wrote:
> > I forgot to mention that udf_err emits at KERN_CRIT.
> > I think that's not good.
> I've changed udf_err() to call pr_err() because
> KERN_CRIT is really too much.

If this means you applied it or applied it with
modifications, I think it'd be good to either
reply to the 0/n message with something like
"applied to my tree", or reply to each message
as appropriate.

That reply lets other people like NamJae proceed
appropriately.  Otherwise, it's left to some
pull request or patch series posted by you
potentially months later to figure out what's
current.

Is there a udf git tree?

The stuff on sourceforge is not current
and the MAINTAINERS W: entry doesn't work.

Maybe:

diff --git a/MAINTAINERS b/MAINTAINERS
index 644894a..58eb5f1 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -6624,7 +6624,7 @@ F:	drivers/net/ethernet/8390/ne-h8300.c
 
 UDF FILESYSTEM
 M:	Jan Kara <jack@suse.cz>
-W:	http://linux-udf.sourceforge.net
+W:	http://sourceforge.net/projects/linux-udf/develop
 S:	Maintained
 F:	Documentation/filesystems/udf.txt
 F:	fs/udf/

cheers, Joe



^ permalink raw reply related	[flat|nested] 36+ messages in thread

* Re: [PATCH 1/6] udf: Promote some debugging messages to udf_error
  2011-10-10  8:08                     ` [PATCH 1/6] udf: Promote some debugging messages to udf_error Joe Perches
  2011-10-10 10:06                       ` NamJae Jeon
@ 2011-10-10 17:32                       ` Jan Kara
  1 sibling, 0 replies; 36+ messages in thread
From: Jan Kara @ 2011-10-10 17:32 UTC (permalink / raw)
  To: Joe Perches; +Cc: Jan Kara, NamJae Jeon, linux-kernel

On Mon 10-10-11 01:08:02, Joe Perches wrote:
> If there is a problem with a scratched disc or loader,
> it's valuable to know which error occurred.
> 
> Convert some debug messages to udf_error, neaten those messages too.
> Add the calculated tag checksum and the read checksum to error message.
> Make udf_error a public function and move the logging prototypes together.
> 
> Original-patch-by: NamJae Jeon <linkinjeon@gmail.com>
> Signed-off-by: Joe Perches <joe@perches.com>
  I have now tested this patch and found out it's not such a good idea as
it seems at the first sight. UDF uses udf_read_tagged() to probe whether
some structure is in some location (because some structures can be placed
at several places in the filesystem and the only way to determine where the
structure is to load blocks from all the places and check block headers).
So as a result of this patch normal UDF mount produces about 20 error
messages... So I've altered this patch to change only some messages in
udf_read_tagged(). The result is below.

								Honza

-- 
Jan Kara <jack@suse.cz>
SUSE Labs, CR
---

>From 7e273e3b41e32716dc122b293b5f15635af495ff Mon Sep 17 00:00:00 2001
From: Joe Perches <joe@perches.com>
Date: Mon, 10 Oct 2011 01:08:02 -0700
Subject: [PATCH] udf: Promote some debugging messages to udf_error

If there is a problem with a scratched disc or loader, it's valuable to know
which error occurred.

Convert some debug messages to udf_error, neaten those messages too.
Add the calculated tag checksum and the read checksum to error message.
Make udf_error a public function and move the logging prototypes together.

Original-patch-by: NamJae Jeon <linkinjeon@gmail.com>
Reviewed-by: NamJae Jeon <linkinjeon@gmail.com>
Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Jan Kara <jack@suse.cz>
---
 fs/udf/misc.c    |   13 +++++++++----
 fs/udf/super.c   |    6 ++----
 fs/udf/udfdecl.h |    9 +++++++--
 3 files changed, 18 insertions(+), 10 deletions(-)

diff --git a/fs/udf/misc.c b/fs/udf/misc.c
index 9215700..a85fa7c 100644
--- a/fs/udf/misc.c
+++ b/fs/udf/misc.c
@@ -204,6 +204,7 @@ struct buffer_head *udf_read_tagged(struct super_block *sb, uint32_t block,
 {
 	struct tag *tag_p;
 	struct buffer_head *bh = NULL;
+	u8 checksum;
 
 	/* Read the block */
 	if (block == 0xFFFFFFFF)
@@ -211,7 +212,7 @@ struct buffer_head *udf_read_tagged(struct super_block *sb, uint32_t block,
 
 	bh = udf_tread(sb, block);
 	if (!bh) {
-		udf_debug("block=%d, location=%d: read failed\n",
+		udf_error(sb, __func__, "read failed, block=%u, location=%d\n",
 			  block, location);
 		return NULL;
 	}
@@ -227,15 +228,19 @@ struct buffer_head *udf_read_tagged(struct super_block *sb, uint32_t block,
 	}
 
 	/* Verify the tag checksum */
-	if (udf_tag_checksum(tag_p) != tag_p->tagChecksum) {
-		printk(KERN_ERR "udf: tag checksum failed block %d\n", block);
+	checksum = udf_tag_checksum(tag_p);
+	if (checksum != tag_p->tagChecksum) {
+		udf_error(sb, __func__,
+			  "tag checksum failed, block %u: 0x%02x != 0x%02x\n",
+			  block, checksum, tag_p->tagChecksum);
 		goto error_out;
 	}
 
 	/* Verify the tag version */
 	if (tag_p->descVersion != cpu_to_le16(0x0002U) &&
 	    tag_p->descVersion != cpu_to_le16(0x0003U)) {
-		udf_debug("tag version 0x%04x != 0x0002 || 0x0003 block %d\n",
+		udf_error(sb, __func__,
+			  "tag version 0x%04x != 0x0002 || 0x0003, block %u\n",
 			  le16_to_cpu(tag_p->descVersion), block);
 		goto error_out;
 	}
diff --git a/fs/udf/super.c b/fs/udf/super.c
index 7b27b06..80f47ce 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -92,8 +92,6 @@ static void udf_close_lvid(struct super_block *);
 static unsigned int udf_count_free(struct super_block *);
 static int udf_statfs(struct dentry *, struct kstatfs *);
 static int udf_show_options(struct seq_file *, struct vfsmount *);
-static void udf_error(struct super_block *sb, const char *function,
-		      const char *fmt, ...);
 
 struct logicalVolIntegrityDescImpUse *udf_sb_lvidiu(struct udf_sb_info *sbi)
 {
@@ -2096,8 +2094,8 @@ error_out:
 	return -EINVAL;
 }
 
-static void udf_error(struct super_block *sb, const char *function,
-		      const char *fmt, ...)
+void udf_error(struct super_block *sb, const char *function,
+	       const char *fmt, ...)
 {
 	va_list args;
 
diff --git a/fs/udf/udfdecl.h b/fs/udf/udfdecl.h
index dbd52d4..81e66af 100644
--- a/fs/udf/udfdecl.h
+++ b/fs/udf/udfdecl.h
@@ -29,6 +29,13 @@ do { \
 #define udf_debug(f, a...) /**/
 #endif
 
+__attribute__((format(printf, 3, 4)))
+extern void udf_warning(struct super_block *, const char *, const char *, ...);
+
+__attribute__((format(printf, 3, 4)))
+extern void udf_error(struct super_block *sb, const char *function,
+		      const char *fmt, ...);
+
 #define udf_info(f, a...) \
 	printk(KERN_INFO "UDF-fs INFO " f, ##a);
 
@@ -112,8 +119,6 @@ struct extent_position {
 
 /* super.c */
 
-__attribute__((format(printf, 3, 4)))
-extern void udf_warning(struct super_block *, const char *, const char *, ...);
 static inline void udf_updated_lvid(struct super_block *sb)
 {
 	struct buffer_head *bh = UDF_SB(sb)->s_lvid_bh;
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* Re: [PATCH 4/6] udf: Convert printks to pr_<level>
  2011-10-10 17:25                             ` Joe Perches
@ 2011-10-10 17:40                               ` Jan Kara
  0 siblings, 0 replies; 36+ messages in thread
From: Jan Kara @ 2011-10-10 17:40 UTC (permalink / raw)
  To: Joe Perches; +Cc: Jan Kara, linux-kernel, NamJae Jeon

On Mon 10-10-11 10:25:10, Joe Perches wrote:
> On Mon, 2011-10-10 at 18:41 +0200, Jan Kara wrote:
> > On Mon 10-10-11 08:23:34, Joe Perches wrote:
> > > I forgot to mention that udf_err emits at KERN_CRIT.
> > > I think that's not good.
> > I've changed udf_err() to call pr_err() because
> > KERN_CRIT is really too much.
> 
> If this means you applied it or applied it with
> modifications, I think it'd be good to either
> reply to the 0/n message with something like
> "applied to my tree", or reply to each message
> as appropriate.
  Sure, that's what I wanted to do but I first wanted to test what I have,
stumbled across an issue with patch 1 which delayed me a bit...

> That reply lets other people like NamJae proceed
> appropriately.  Otherwise, it's left to some
> pull request or patch series posted by you
> potentially months later to figure out what's
> current.
> 
> Is there a udf git tree?
  On kernel.org which is down... I didn't bother to setup some other place
yet.

> The stuff on sourceforge is not current
> and the MAINTAINERS W: entry doesn't work.
  Actually, the link is ancient and I don't use SF for UDF development so
I've added a patch to my tree which removes the link.
  
> 
> Maybe:
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 644894a..58eb5f1 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -6624,7 +6624,7 @@ F:	drivers/net/ethernet/8390/ne-h8300.c
>  
>  UDF FILESYSTEM
>  M:	Jan Kara <jack@suse.cz>
> -W:	http://linux-udf.sourceforge.net
> +W:	http://sourceforge.net/projects/linux-udf/develop
>  S:	Maintained
>  F:	Documentation/filesystems/udf.txt
>  F:	fs/udf/
> 
> cheers, Joe
> 
> 
-- 
Jan Kara <jack@suse.cz>
SUSE Labs, CR

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 0/6] udf: Change some KERN_<level>s and logging neatening
  2011-10-10  8:08                   ` [PATCH 0/6] udf: Change some KERN_<level>s and logging neatening Joe Perches
                                       ` (6 preceding siblings ...)
  2011-10-10 10:24                     ` [PATCH 0/6] udf: Change some KERN_<level>s and logging neatening NamJae Jeon
@ 2011-10-10 17:47                     ` Jan Kara
  7 siblings, 0 replies; 36+ messages in thread
From: Jan Kara @ 2011-10-10 17:47 UTC (permalink / raw)
  To: Joe Perches; +Cc: Jan Kara, NamJae Jeon, linux-kernel

On Mon 10-10-11 01:08:01, Joe Perches wrote:
> I reviewed your patch and think it's too large
> for others to review because it combines multiple
> things into a single patch.
> 
> I think that adding struct super_block * to udb_debug
> isn't necessary or particularly useful.
> 
> Here are the changes to your original patch that I made:
> 
> Separate a single large patch into reviewable chunks.
> Don't convert every message type to udf_<foo>.
> 
> Joe Perches (6):
>   udf: Promote some debugging messages to udf_error
>   udf: Rename udf_error to udf_err
>   udf: Rename udf_warn to udf_warn
>   udf: Convert printks to pr_<level>
>   udf: Neaten logging output, use vsprintf extension %pV
>   udf: Neaten udf_debug uses
  So, I've merged all the patches (patches 1, 4, and 5 with some
modifications). Since kernel.org where I normally have my tree is down
(well, better said I have not reestablished my tree there yet), I'll resend
the whole series in a while so that people see what I carry.

								Honza
-- 
Jan Kara <jack@suse.cz>
SUSE Labs, CR

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 3/6] udf: Rename udf_warn to udf_warn
  2011-10-10  8:08                     ` [PATCH 3/6] udf: Rename udf_warn to udf_warn Joe Perches
  2011-10-10 10:18                       ` NamJae Jeon
@ 2011-10-10 18:25                       ` Paul Bolle
  2011-10-10 18:27                         ` Joe Perches
  1 sibling, 1 reply; 36+ messages in thread
From: Paul Bolle @ 2011-10-10 18:25 UTC (permalink / raw)
  To: Joe Perches; +Cc: Jan Kara, NamJae Jeon, linux-kernel

On Mon, 2011-10-10 at 01:08 -0700, Joe Perches wrote:
> Rename udf_warning to udf_warn for consistency with normal logging
> uses of pr_warn.

So the summary should read:
    udf: Rename udf_warning to udf_warn


Paul Bolle


^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 3/6] udf: Rename udf_warn to udf_warn
  2011-10-10 18:25                       ` Paul Bolle
@ 2011-10-10 18:27                         ` Joe Perches
  0 siblings, 0 replies; 36+ messages in thread
From: Joe Perches @ 2011-10-10 18:27 UTC (permalink / raw)
  To: Paul Bolle; +Cc: Jan Kara, NamJae Jeon, linux-kernel

On Mon, 2011-10-10 at 20:25 +0200, Paul Bolle wrote:
> On Mon, 2011-10-10 at 01:08 -0700, Joe Perches wrote:
> > Rename udf_warning to udf_warn for consistency with normal logging
> > uses of pr_warn.
> 
> So the summary should read:
>     udf: Rename udf_warning to udf_warn

Yeah, I stuffed that subject line up.
Jan/Honza caught it and fixed it though.


^ permalink raw reply	[flat|nested] 36+ messages in thread

end of thread, other threads:[~2011-10-10 18:27 UTC | newest]

Thread overview: 36+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-03 13:53 [PATCH 1/2 v3] udf : enable error print in udf_read_tagged() Namjae Jeon
2011-10-05 22:08 ` Jan Kara
2011-10-05 22:19   ` Joe Perches
2011-10-06 21:41     ` Jan Kara
2011-10-09  3:16       ` NamJae Jeon
2011-10-09  3:29         ` Joe Perches
2011-10-09  4:44           ` NamJae Jeon
2011-10-09  4:56             ` Joe Perches
2011-10-09  6:25               ` NamJae Jeon
2011-10-09 14:07                 ` NamJae Jeon
2011-10-10  8:08                   ` [PATCH 0/6] udf: Change some KERN_<level>s and logging neatening Joe Perches
2011-10-10  8:08                     ` [PATCH 1/6] udf: Promote some debugging messages to udf_error Joe Perches
2011-10-10 10:06                       ` NamJae Jeon
2011-10-10 17:32                       ` Jan Kara
2011-10-10  8:08                     ` [PATCH 2/6] udf: Rename udf_error to udf_err Joe Perches
2011-10-10 10:18                       ` NamJae Jeon
2011-10-10  8:08                     ` [PATCH 3/6] udf: Rename udf_warn to udf_warn Joe Perches
2011-10-10 10:18                       ` NamJae Jeon
2011-10-10 18:25                       ` Paul Bolle
2011-10-10 18:27                         ` Joe Perches
2011-10-10  8:08                     ` [PATCH 4/6] udf: Convert printks to pr_<level> Joe Perches
2011-10-10 10:21                       ` NamJae Jeon
2011-10-10 14:59                       ` Jan Kara
2011-10-10 15:20                         ` Joe Perches
2011-10-10 15:23                         ` Joe Perches
2011-10-10 16:41                           ` Jan Kara
2011-10-10 17:25                             ` Joe Perches
2011-10-10 17:40                               ` Jan Kara
2011-10-10  8:08                     ` [PATCH 5/6] udf: Neaten logging output, use vsprintf extension %pV Joe Perches
2011-10-10 10:22                       ` NamJae Jeon
2011-10-10 15:04                       ` Jan Kara
2011-10-10 15:20                         ` Joe Perches
2011-10-10  8:08                     ` [PATCH 6/6] udf: Neaten udf_debug uses Joe Perches
2011-10-10 10:23                       ` NamJae Jeon
2011-10-10 10:24                     ` [PATCH 0/6] udf: Change some KERN_<level>s and logging neatening NamJae Jeon
2011-10-10 17:47                     ` Jan Kara

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).