udf: Promote some debugging messages to udf_error
authorJoe Perches <joe@perches.com>
Mon, 10 Oct 2011 08:08:02 +0000 (01:08 -0700)
committerJan Kara <jack@suse.cz>
Mon, 10 Oct 2011 17:26:24 +0000 (19:26 +0200)
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
fs/udf/super.c
fs/udf/udfdecl.h

index 9215700c00a4448eedd1e5306cb2c3410f3f4b45..a85fa7c55b0ac61630f1190f3c3f807f5b4ed906 100644 (file)
@@ -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;
        }
index 7b27b063ff6d673423ecd0902d0076f1c0ea3ccf..80f47ce515bcb540e3d33c825b85cea4c67a4291 100644 (file)
@@ -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;
 
index dbd52d4b5eed9f01382a0be8cddfa2c79f353e0c..81e66afecd42658ba40e3f49067b163299c6b552 100644 (file)
@@ -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;