Re: Re: [RFC PATCH 08/10] scsi/trace: Use scsi_print_sense trace point instead of printk
(2014/08/27 23:15), Hannes Reinecke wrote: On 08/08/2014 01:50 PM, Yoshihiro YUNOMAE wrote: Previous sense messages can be mixed into other sense messages, because continuous printk (KERN_CONT) was used. To avoid the problem, patch d87f3a6f51 introduced a local buffer in Hannes's baranch (*1). But using local buffers can induce stack overflow, so we want to solve the problem without local buffer if possible. trace_seq_printf can add log messages without local buffer, so we use it. (*1) http://git.kernel.org/cgit/linux/kernel/git/hare/scsi-devel.git/log/?h=logging - Result examples (printk) sd 2:0:0:0: [sda] Sense Key : Medium Error [current] (ftrace) scsi_print_sense: host_no=2 channel=0 id=0 lun=0 [sda] Sense Key (Medium Error [current]) Signed-off-by: Yoshihiro YUNOMAE Cc: Hannes Reinecke Cc: Doug Gilbert Cc: Martin K. Petersen Cc: Christoph Hellwig Cc: "James E.J. Bottomley" Cc: Hidehiro Kawai Cc: Masami Hiramatsu --- drivers/scsi/constants.c| 145 ++- drivers/scsi/scsi_trace.c | 140 -- include/scsi/scsi_eh.h |7 ++ include/trace/events/scsi.h | 48 ++ 4 files changed, 195 insertions(+), 145 deletions(-) diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c index f7b7f32..85b75c8 100644 --- a/drivers/scsi/constants.c +++ b/drivers/scsi/constants.c @@ -19,7 +19,7 @@ #include #include - +#include /* Commands with service actions that change the command name */ #define SERVICE_ACTION_IN_12 0xab @@ -1267,58 +1267,8 @@ static const struct error_info2 additional2[] = {0x70, 0x00, 0xff, "Decompression exception short algorithm id of %x"}, {0, 0, 0, NULL} }; - -/* description of the sense key values */ -static const char * const snstext[] = { -"No Sense",/* 0: There is no sense information */ -"Recovered Error", /* 1: The last command completed successfully - but used error correction */ -"Not Ready",/* 2: The addressed target is not ready */ -"Medium Error",/* 3: Data error detected on the medium */ -"Hardware Error", /* 4: Controller or device failure */ -"Illegal Request", /* 5: Error in request */ -"Unit Attention", /* 6: Removable medium was changed, or - the target has been reset, or ... */ -"Data Protect",/* 7: Access to the data is blocked */ -"Blank Check",/* 8: Reached unexpected written or unwritten - region of the medium */ -"Vendor Specific(9)", -"Copy Aborted",/* A: COPY or COMPARE was aborted */ -"Aborted Command", /* B: The target aborted the command */ -"Equal",/* C: A SEARCH DATA command found data equal, - reserved in SPC-4 rev 36 */ -"Volume Overflow", /* D: Medium full with still data to be written */ -"Miscompare",/* E: Source data and data on the medium - do not agree */ -"Completed",/* F: command completed sense data reported, - may occur for successful command */ -}; -#else -static const char * const snstext[] = { -"0x0", "0x1", "0x2", "0x3", "0x4", "0x5", "0x6", "0x7", -"0x8", "0x9", "0xa", "0xb", "0xc", "0xd", "0xe", "0xf", -}; #endif -/* Get sense key string or NULL if not available */ -const char * -scsi_sense_key_string(unsigned char key) { -return snstext[key & 0xf]; -} -EXPORT_SYMBOL(scsi_sense_key_string); - -const char * -scsi_sense_type_string(struct scsi_sense_hdr *sshdr) -{ -return scsi_sense_is_deferred(sshdr) ? "[deferred]" : "[current]"; -} - -const char * -scsi_sense_format_string(struct scsi_sense_hdr *sshdr) -{ -return sshdr->response_code >= 0x72 ? "[descriptor]" : ""; -} - /* * Get additional sense code string or NULL if not available. * This string may contain a "%x" and should be printed with ascq as arg. @@ -1375,105 +1325,22 @@ void scsi_print_sense_hdr(struct scsi_device *sdev, const char *name, struct scsi_sense_hdr *sshdr) { -sdev_printk(KERN_INFO, sdev, "[%s] Sense Key : %s %s%s\n", name, -scsi_sense_key_string(sshdr->sense_key), -scsi_sense_type_string(sshdr), -scsi_sense_format_string(sshdr)); +trace_scsi_print_sense(sdev, name, sshdr, NULL, 0, 0); scsi_show_extd_sense(sdev, name, sshdr->asc, sshdr->ascq); } EXPORT_SYMBOL(scsi_print_sense_hdr); -static void -scsi_dump_sense_buffer(struct scsi_device *sdev, const char *prefix, - const unsigned char *sense_buffer, int sense_len) -{ -char linebuf[128]; -int i, linelen, remaining; - -if (sense_len < 32) -sense_len = 32; - -remaining = sense_len; -for (i = 0; i < sense_len; i += 16) { -linelen = min(remaining, 16); -remaining -= 16; - -hex_dump_to_buffer(sense_buffer + i, linelen, 16, 1, - linebuf,
Re: [RFC PATCH 08/10] scsi/trace: Use scsi_print_sense trace point instead of printk
On 08/08/2014 01:50 PM, Yoshihiro YUNOMAE wrote: Previous sense messages can be mixed into other sense messages, because continuous printk (KERN_CONT) was used. To avoid the problem, patch d87f3a6f51 introduced a local buffer in Hannes's baranch (*1). But using local buffers can induce stack overflow, so we want to solve the problem without local buffer if possible. trace_seq_printf can add log messages without local buffer, so we use it. (*1) http://git.kernel.org/cgit/linux/kernel/git/hare/scsi-devel.git/log/?h=logging - Result examples (printk) sd 2:0:0:0: [sda] Sense Key : Medium Error [current] (ftrace) scsi_print_sense: host_no=2 channel=0 id=0 lun=0 [sda] Sense Key (Medium Error [current]) Signed-off-by: Yoshihiro YUNOMAE Cc: Hannes Reinecke Cc: Doug Gilbert Cc: Martin K. Petersen Cc: Christoph Hellwig Cc: "James E.J. Bottomley" Cc: Hidehiro Kawai Cc: Masami Hiramatsu --- drivers/scsi/constants.c| 145 ++- drivers/scsi/scsi_trace.c | 140 -- include/scsi/scsi_eh.h |7 ++ include/trace/events/scsi.h | 48 ++ 4 files changed, 195 insertions(+), 145 deletions(-) diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c index f7b7f32..85b75c8 100644 --- a/drivers/scsi/constants.c +++ b/drivers/scsi/constants.c @@ -19,7 +19,7 @@ #include #include - +#include /* Commands with service actions that change the command name */ #define SERVICE_ACTION_IN_12 0xab @@ -1267,58 +1267,8 @@ static const struct error_info2 additional2[] = {0x70, 0x00, 0xff, "Decompression exception short algorithm id of %x"}, {0, 0, 0, NULL} }; - -/* description of the sense key values */ -static const char * const snstext[] = { - "No Sense", /* 0: There is no sense information */ - "Recovered Error", /* 1: The last command completed successfully - but used error correction */ - "Not Ready", /* 2: The addressed target is not ready */ - "Medium Error", /* 3: Data error detected on the medium */ - "Hardware Error", /* 4: Controller or device failure */ - "Illegal Request", /* 5: Error in request */ - "Unit Attention", /* 6: Removable medium was changed, or - the target has been reset, or ... */ - "Data Protect", /* 7: Access to the data is blocked */ - "Blank Check",/* 8: Reached unexpected written or unwritten - region of the medium */ - "Vendor Specific(9)", - "Copy Aborted", /* A: COPY or COMPARE was aborted */ - "Aborted Command", /* B: The target aborted the command */ - "Equal", /* C: A SEARCH DATA command found data equal, - reserved in SPC-4 rev 36 */ - "Volume Overflow", /* D: Medium full with still data to be written */ - "Miscompare", /* E: Source data and data on the medium - do not agree */ - "Completed", /* F: command completed sense data reported, - may occur for successful command */ -}; -#else -static const char * const snstext[] = { - "0x0", "0x1", "0x2", "0x3", "0x4", "0x5", "0x6", "0x7", - "0x8", "0x9", "0xa", "0xb", "0xc", "0xd", "0xe", "0xf", -}; #endif -/* Get sense key string or NULL if not available */ -const char * -scsi_sense_key_string(unsigned char key) { - return snstext[key & 0xf]; -} -EXPORT_SYMBOL(scsi_sense_key_string); - -const char * -scsi_sense_type_string(struct scsi_sense_hdr *sshdr) -{ - return scsi_sense_is_deferred(sshdr) ? "[deferred]" : "[current]"; -} - -const char * -scsi_sense_format_string(struct scsi_sense_hdr *sshdr) -{ - return sshdr->response_code >= 0x72 ? "[descriptor]" : ""; -} - /* * Get additional sense code string or NULL if not available. * This string may contain a "%x" and should be printed with ascq as arg. @@ -1375,105 +1325,22 @@ void scsi_print_sense_hdr(struct scsi_device *sdev, const char *name, struct scsi_sense_hdr *sshdr) { - sdev_printk(KERN_INFO, sdev, "[%s] Sense Key : %s %s%s\n", name, - scsi_sense_key_string(sshdr->sense_key), - scsi_sense_type_string(sshdr), - scsi_sense_format_string(sshdr)); + trace_scsi_print_sense(sdev, name, sshdr, NULL, 0, 0); scsi_show_extd_sense(sdev, name, sshdr->asc, sshdr->ascq); } EXPORT_SYMBOL(scsi_print_sense_hdr); -static void -scsi_dump_sense_buffer(struct scsi_device *sdev, const char *prefix, - const unsigned char *sense_buffer, int sense_len) -{ - char linebuf[128]; - int i, linelen, remaining; - - if (sense_len < 32) - sense_len = 32; - - remaining = sense_len; - for (i = 0; i <
Re: [RFC PATCH 08/10] scsi/trace: Use scsi_print_sense trace point instead of printk
On 08/08/2014 01:50 PM, Yoshihiro YUNOMAE wrote: Previous sense messages can be mixed into other sense messages, because continuous printk (KERN_CONT) was used. To avoid the problem, patch d87f3a6f51 introduced a local buffer in Hannes's baranch (*1). But using local buffers can induce stack overflow, so we want to solve the problem without local buffer if possible. trace_seq_printf can add log messages without local buffer, so we use it. (*1) http://git.kernel.org/cgit/linux/kernel/git/hare/scsi-devel.git/log/?h=logging - Result examples Before (printk) sd 2:0:0:0: [sda] Sense Key : Medium Error [current] After (ftrace) scsi_print_sense: host_no=2 channel=0 id=0 lun=0 [sda] Sense Key (Medium Error [current]) Signed-off-by: Yoshihiro YUNOMAE yoshihiro.yunomae...@hitachi.com Cc: Hannes Reinecke h...@suse.de Cc: Doug Gilbert dgilb...@interlog.com Cc: Martin K. Petersen martin.peter...@oracle.com Cc: Christoph Hellwig h...@lst.de Cc: James E.J. Bottomley jbottom...@parallels.com Cc: Hidehiro Kawai hidehiro.kawai...@hitachi.com Cc: Masami Hiramatsu masami.hiramatsu...@hitachi.com --- drivers/scsi/constants.c| 145 ++- drivers/scsi/scsi_trace.c | 140 -- include/scsi/scsi_eh.h |7 ++ include/trace/events/scsi.h | 48 ++ 4 files changed, 195 insertions(+), 145 deletions(-) diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c index f7b7f32..85b75c8 100644 --- a/drivers/scsi/constants.c +++ b/drivers/scsi/constants.c @@ -19,7 +19,7 @@ #include scsi/scsi_eh.h #include scsi/scsi_dbg.h - +#include trace/events/scsi.h /* Commands with service actions that change the command name */ #define SERVICE_ACTION_IN_12 0xab @@ -1267,58 +1267,8 @@ static const struct error_info2 additional2[] = {0x70, 0x00, 0xff, Decompression exception short algorithm id of %x}, {0, 0, 0, NULL} }; - -/* description of the sense key values */ -static const char * const snstext[] = { - No Sense, /* 0: There is no sense information */ - Recovered Error, /* 1: The last command completed successfully - but used error correction */ - Not Ready, /* 2: The addressed target is not ready */ - Medium Error, /* 3: Data error detected on the medium */ - Hardware Error, /* 4: Controller or device failure */ - Illegal Request, /* 5: Error in request */ - Unit Attention, /* 6: Removable medium was changed, or - the target has been reset, or ... */ - Data Protect, /* 7: Access to the data is blocked */ - Blank Check,/* 8: Reached unexpected written or unwritten - region of the medium */ - Vendor Specific(9), - Copy Aborted, /* A: COPY or COMPARE was aborted */ - Aborted Command, /* B: The target aborted the command */ - Equal, /* C: A SEARCH DATA command found data equal, - reserved in SPC-4 rev 36 */ - Volume Overflow, /* D: Medium full with still data to be written */ - Miscompare, /* E: Source data and data on the medium - do not agree */ - Completed, /* F: command completed sense data reported, - may occur for successful command */ -}; -#else -static const char * const snstext[] = { - 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, - 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, -}; #endif -/* Get sense key string or NULL if not available */ -const char * -scsi_sense_key_string(unsigned char key) { - return snstext[key 0xf]; -} -EXPORT_SYMBOL(scsi_sense_key_string); - -const char * -scsi_sense_type_string(struct scsi_sense_hdr *sshdr) -{ - return scsi_sense_is_deferred(sshdr) ? [deferred] : [current]; -} - -const char * -scsi_sense_format_string(struct scsi_sense_hdr *sshdr) -{ - return sshdr-response_code = 0x72 ? [descriptor] : ; -} - /* * Get additional sense code string or NULL if not available. * This string may contain a %x and should be printed with ascq as arg. @@ -1375,105 +1325,22 @@ void scsi_print_sense_hdr(struct scsi_device *sdev, const char *name, struct scsi_sense_hdr *sshdr) { - sdev_printk(KERN_INFO, sdev, [%s] Sense Key : %s %s%s\n, name, - scsi_sense_key_string(sshdr-sense_key), - scsi_sense_type_string(sshdr), - scsi_sense_format_string(sshdr)); + trace_scsi_print_sense(sdev, name, sshdr, NULL, 0, 0); scsi_show_extd_sense(sdev, name, sshdr-asc, sshdr-ascq); } EXPORT_SYMBOL(scsi_print_sense_hdr); -static void -scsi_dump_sense_buffer(struct scsi_device *sdev, const char *prefix, - const unsigned char *sense_buffer, int sense_len) -{ - char linebuf[128]; -
Re: Re: [RFC PATCH 08/10] scsi/trace: Use scsi_print_sense trace point instead of printk
(2014/08/27 23:15), Hannes Reinecke wrote: On 08/08/2014 01:50 PM, Yoshihiro YUNOMAE wrote: Previous sense messages can be mixed into other sense messages, because continuous printk (KERN_CONT) was used. To avoid the problem, patch d87f3a6f51 introduced a local buffer in Hannes's baranch (*1). But using local buffers can induce stack overflow, so we want to solve the problem without local buffer if possible. trace_seq_printf can add log messages without local buffer, so we use it. (*1) http://git.kernel.org/cgit/linux/kernel/git/hare/scsi-devel.git/log/?h=logging - Result examples Before (printk) sd 2:0:0:0: [sda] Sense Key : Medium Error [current] After (ftrace) scsi_print_sense: host_no=2 channel=0 id=0 lun=0 [sda] Sense Key (Medium Error [current]) Signed-off-by: Yoshihiro YUNOMAE yoshihiro.yunomae...@hitachi.com Cc: Hannes Reinecke h...@suse.de Cc: Doug Gilbert dgilb...@interlog.com Cc: Martin K. Petersen martin.peter...@oracle.com Cc: Christoph Hellwig h...@lst.de Cc: James E.J. Bottomley jbottom...@parallels.com Cc: Hidehiro Kawai hidehiro.kawai...@hitachi.com Cc: Masami Hiramatsu masami.hiramatsu...@hitachi.com --- drivers/scsi/constants.c| 145 ++- drivers/scsi/scsi_trace.c | 140 -- include/scsi/scsi_eh.h |7 ++ include/trace/events/scsi.h | 48 ++ 4 files changed, 195 insertions(+), 145 deletions(-) diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c index f7b7f32..85b75c8 100644 --- a/drivers/scsi/constants.c +++ b/drivers/scsi/constants.c @@ -19,7 +19,7 @@ #include scsi/scsi_eh.h #include scsi/scsi_dbg.h - +#include trace/events/scsi.h /* Commands with service actions that change the command name */ #define SERVICE_ACTION_IN_12 0xab @@ -1267,58 +1267,8 @@ static const struct error_info2 additional2[] = {0x70, 0x00, 0xff, Decompression exception short algorithm id of %x}, {0, 0, 0, NULL} }; - -/* description of the sense key values */ -static const char * const snstext[] = { -No Sense,/* 0: There is no sense information */ -Recovered Error, /* 1: The last command completed successfully - but used error correction */ -Not Ready,/* 2: The addressed target is not ready */ -Medium Error,/* 3: Data error detected on the medium */ -Hardware Error, /* 4: Controller or device failure */ -Illegal Request, /* 5: Error in request */ -Unit Attention, /* 6: Removable medium was changed, or - the target has been reset, or ... */ -Data Protect,/* 7: Access to the data is blocked */ -Blank Check,/* 8: Reached unexpected written or unwritten - region of the medium */ -Vendor Specific(9), -Copy Aborted,/* A: COPY or COMPARE was aborted */ -Aborted Command, /* B: The target aborted the command */ -Equal,/* C: A SEARCH DATA command found data equal, - reserved in SPC-4 rev 36 */ -Volume Overflow, /* D: Medium full with still data to be written */ -Miscompare,/* E: Source data and data on the medium - do not agree */ -Completed,/* F: command completed sense data reported, - may occur for successful command */ -}; -#else -static const char * const snstext[] = { -0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, -0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, -}; #endif -/* Get sense key string or NULL if not available */ -const char * -scsi_sense_key_string(unsigned char key) { -return snstext[key 0xf]; -} -EXPORT_SYMBOL(scsi_sense_key_string); - -const char * -scsi_sense_type_string(struct scsi_sense_hdr *sshdr) -{ -return scsi_sense_is_deferred(sshdr) ? [deferred] : [current]; -} - -const char * -scsi_sense_format_string(struct scsi_sense_hdr *sshdr) -{ -return sshdr-response_code = 0x72 ? [descriptor] : ; -} - /* * Get additional sense code string or NULL if not available. * This string may contain a %x and should be printed with ascq as arg. @@ -1375,105 +1325,22 @@ void scsi_print_sense_hdr(struct scsi_device *sdev, const char *name, struct scsi_sense_hdr *sshdr) { -sdev_printk(KERN_INFO, sdev, [%s] Sense Key : %s %s%s\n, name, -scsi_sense_key_string(sshdr-sense_key), -scsi_sense_type_string(sshdr), -scsi_sense_format_string(sshdr)); +trace_scsi_print_sense(sdev, name, sshdr, NULL, 0, 0); scsi_show_extd_sense(sdev, name, sshdr-asc, sshdr-ascq); } EXPORT_SYMBOL(scsi_print_sense_hdr); -static void -scsi_dump_sense_buffer(struct scsi_device *sdev, const char *prefix, - const unsigned char *sense_buffer, int sense_len) -{ -char linebuf[128]; -int i, linelen, remaining; - -if (sense_len 32) -sense_len = 32; - -remaining = sense_len; -for (i = 0; i sense_len; i += 16) { -
[RFC PATCH 08/10] scsi/trace: Use scsi_print_sense trace point instead of printk
Previous sense messages can be mixed into other sense messages, because continuous printk (KERN_CONT) was used. To avoid the problem, patch d87f3a6f51 introduced a local buffer in Hannes's baranch (*1). But using local buffers can induce stack overflow, so we want to solve the problem without local buffer if possible. trace_seq_printf can add log messages without local buffer, so we use it. (*1) http://git.kernel.org/cgit/linux/kernel/git/hare/scsi-devel.git/log/?h=logging - Result examples (printk) sd 2:0:0:0: [sda] Sense Key : Medium Error [current] (ftrace) scsi_print_sense: host_no=2 channel=0 id=0 lun=0 [sda] Sense Key (Medium Error [current]) Signed-off-by: Yoshihiro YUNOMAE Cc: Hannes Reinecke Cc: Doug Gilbert Cc: Martin K. Petersen Cc: Christoph Hellwig Cc: "James E.J. Bottomley" Cc: Hidehiro Kawai Cc: Masami Hiramatsu --- drivers/scsi/constants.c| 145 ++- drivers/scsi/scsi_trace.c | 140 -- include/scsi/scsi_eh.h |7 ++ include/trace/events/scsi.h | 48 ++ 4 files changed, 195 insertions(+), 145 deletions(-) diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c index f7b7f32..85b75c8 100644 --- a/drivers/scsi/constants.c +++ b/drivers/scsi/constants.c @@ -19,7 +19,7 @@ #include #include - +#include /* Commands with service actions that change the command name */ #define SERVICE_ACTION_IN_12 0xab @@ -1267,58 +1267,8 @@ static const struct error_info2 additional2[] = {0x70, 0x00, 0xff, "Decompression exception short algorithm id of %x"}, {0, 0, 0, NULL} }; - -/* description of the sense key values */ -static const char * const snstext[] = { - "No Sense", /* 0: There is no sense information */ - "Recovered Error", /* 1: The last command completed successfully - but used error correction */ - "Not Ready",/* 2: The addressed target is not ready */ - "Medium Error", /* 3: Data error detected on the medium */ - "Hardware Error", /* 4: Controller or device failure */ - "Illegal Request", /* 5: Error in request */ - "Unit Attention", /* 6: Removable medium was changed, or - the target has been reset, or ... */ - "Data Protect", /* 7: Access to the data is blocked */ - "Blank Check", /* 8: Reached unexpected written or unwritten - region of the medium */ - "Vendor Specific(9)", - "Copy Aborted", /* A: COPY or COMPARE was aborted */ - "Aborted Command", /* B: The target aborted the command */ - "Equal",/* C: A SEARCH DATA command found data equal, - reserved in SPC-4 rev 36 */ - "Volume Overflow", /* D: Medium full with still data to be written */ - "Miscompare", /* E: Source data and data on the medium - do not agree */ - "Completed",/* F: command completed sense data reported, - may occur for successful command */ -}; -#else -static const char * const snstext[] = { - "0x0", "0x1", "0x2", "0x3", "0x4", "0x5", "0x6", "0x7", - "0x8", "0x9", "0xa", "0xb", "0xc", "0xd", "0xe", "0xf", -}; #endif -/* Get sense key string or NULL if not available */ -const char * -scsi_sense_key_string(unsigned char key) { - return snstext[key & 0xf]; -} -EXPORT_SYMBOL(scsi_sense_key_string); - -const char * -scsi_sense_type_string(struct scsi_sense_hdr *sshdr) -{ - return scsi_sense_is_deferred(sshdr) ? "[deferred]" : "[current]"; -} - -const char * -scsi_sense_format_string(struct scsi_sense_hdr *sshdr) -{ - return sshdr->response_code >= 0x72 ? "[descriptor]" : ""; -} - /* * Get additional sense code string or NULL if not available. * This string may contain a "%x" and should be printed with ascq as arg. @@ -1375,105 +1325,22 @@ void scsi_print_sense_hdr(struct scsi_device *sdev, const char *name, struct scsi_sense_hdr *sshdr) { - sdev_printk(KERN_INFO, sdev, "[%s] Sense Key : %s %s%s\n", name, - scsi_sense_key_string(sshdr->sense_key), - scsi_sense_type_string(sshdr), - scsi_sense_format_string(sshdr)); + trace_scsi_print_sense(sdev, name, sshdr, NULL, 0, 0); scsi_show_extd_sense(sdev, name, sshdr->asc, sshdr->ascq); } EXPORT_SYMBOL(scsi_print_sense_hdr); -static void -scsi_dump_sense_buffer(struct scsi_device *sdev, const char *prefix, - const unsigned char *sense_buffer, int sense_len) -{ - char linebuf[128]; - int i, linelen, remaining; - - if (sense_len < 32) - sense_len = 32; - - remaining = sense_len; - for (i = 0; i < sense_len; i += 16) { - linelen = min(remaining, 16); -
[RFC PATCH 08/10] scsi/trace: Use scsi_print_sense trace point instead of printk
Previous sense messages can be mixed into other sense messages, because continuous printk (KERN_CONT) was used. To avoid the problem, patch d87f3a6f51 introduced a local buffer in Hannes's baranch (*1). But using local buffers can induce stack overflow, so we want to solve the problem without local buffer if possible. trace_seq_printf can add log messages without local buffer, so we use it. (*1) http://git.kernel.org/cgit/linux/kernel/git/hare/scsi-devel.git/log/?h=logging - Result examples Before (printk) sd 2:0:0:0: [sda] Sense Key : Medium Error [current] After (ftrace) scsi_print_sense: host_no=2 channel=0 id=0 lun=0 [sda] Sense Key (Medium Error [current]) Signed-off-by: Yoshihiro YUNOMAE yoshihiro.yunomae...@hitachi.com Cc: Hannes Reinecke h...@suse.de Cc: Doug Gilbert dgilb...@interlog.com Cc: Martin K. Petersen martin.peter...@oracle.com Cc: Christoph Hellwig h...@lst.de Cc: James E.J. Bottomley jbottom...@parallels.com Cc: Hidehiro Kawai hidehiro.kawai...@hitachi.com Cc: Masami Hiramatsu masami.hiramatsu...@hitachi.com --- drivers/scsi/constants.c| 145 ++- drivers/scsi/scsi_trace.c | 140 -- include/scsi/scsi_eh.h |7 ++ include/trace/events/scsi.h | 48 ++ 4 files changed, 195 insertions(+), 145 deletions(-) diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c index f7b7f32..85b75c8 100644 --- a/drivers/scsi/constants.c +++ b/drivers/scsi/constants.c @@ -19,7 +19,7 @@ #include scsi/scsi_eh.h #include scsi/scsi_dbg.h - +#include trace/events/scsi.h /* Commands with service actions that change the command name */ #define SERVICE_ACTION_IN_12 0xab @@ -1267,58 +1267,8 @@ static const struct error_info2 additional2[] = {0x70, 0x00, 0xff, Decompression exception short algorithm id of %x}, {0, 0, 0, NULL} }; - -/* description of the sense key values */ -static const char * const snstext[] = { - No Sense, /* 0: There is no sense information */ - Recovered Error, /* 1: The last command completed successfully - but used error correction */ - Not Ready,/* 2: The addressed target is not ready */ - Medium Error, /* 3: Data error detected on the medium */ - Hardware Error, /* 4: Controller or device failure */ - Illegal Request, /* 5: Error in request */ - Unit Attention, /* 6: Removable medium was changed, or - the target has been reset, or ... */ - Data Protect, /* 7: Access to the data is blocked */ - Blank Check, /* 8: Reached unexpected written or unwritten - region of the medium */ - Vendor Specific(9), - Copy Aborted, /* A: COPY or COMPARE was aborted */ - Aborted Command, /* B: The target aborted the command */ - Equal,/* C: A SEARCH DATA command found data equal, - reserved in SPC-4 rev 36 */ - Volume Overflow, /* D: Medium full with still data to be written */ - Miscompare, /* E: Source data and data on the medium - do not agree */ - Completed,/* F: command completed sense data reported, - may occur for successful command */ -}; -#else -static const char * const snstext[] = { - 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, - 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, -}; #endif -/* Get sense key string or NULL if not available */ -const char * -scsi_sense_key_string(unsigned char key) { - return snstext[key 0xf]; -} -EXPORT_SYMBOL(scsi_sense_key_string); - -const char * -scsi_sense_type_string(struct scsi_sense_hdr *sshdr) -{ - return scsi_sense_is_deferred(sshdr) ? [deferred] : [current]; -} - -const char * -scsi_sense_format_string(struct scsi_sense_hdr *sshdr) -{ - return sshdr-response_code = 0x72 ? [descriptor] : ; -} - /* * Get additional sense code string or NULL if not available. * This string may contain a %x and should be printed with ascq as arg. @@ -1375,105 +1325,22 @@ void scsi_print_sense_hdr(struct scsi_device *sdev, const char *name, struct scsi_sense_hdr *sshdr) { - sdev_printk(KERN_INFO, sdev, [%s] Sense Key : %s %s%s\n, name, - scsi_sense_key_string(sshdr-sense_key), - scsi_sense_type_string(sshdr), - scsi_sense_format_string(sshdr)); + trace_scsi_print_sense(sdev, name, sshdr, NULL, 0, 0); scsi_show_extd_sense(sdev, name, sshdr-asc, sshdr-ascq); } EXPORT_SYMBOL(scsi_print_sense_hdr); -static void -scsi_dump_sense_buffer(struct scsi_device *sdev, const char *prefix, - const unsigned char *sense_buffer, int sense_len) -{ - char linebuf[128]; - int i, linelen, remaining; - - if (sense_len 32) -