Re: [PATCH 1/6] udf: Promote some debugging messages to udf_error

From: NamJae Jeon
Date: Mon Oct 10 2011 - 06:06:41 EST


2011/10/10 Joe Perches <joe@xxxxxxxxxxx>:
> 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@xxxxxxxxx>
> Signed-off-by: Joe Perches <joe@xxxxxxxxxxx>
Reviewed-by: NamJae Jeon <linkinjeon@xxxxxxxxx>
> ---
> Â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
>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/