From: Hannes Reinecke <hare@suse.de>
To: James Bottomley <jbottomley@parallels.com>
Cc: Ewan Milne <emilne@redhat.com>,
Christoph Hellwig <hch@infradead.org>,
linux-scsi@vger.kernel.org, Robert Elliot <elliot@hp.com>,
Yoshihiro Yunomae <yoshihiro.ynomae.ez@hitachi.com>,
Hannes Reinecke <hare@suse.de>
Subject: [PATCH 08/22] scsi: dump sense buffer only for debugging
Date: Thu, 28 Aug 2014 19:33:22 +0200 [thread overview]
Message-ID: <1409247216-76074-9-git-send-email-hare@suse.de> (raw)
In-Reply-To: <1409247216-76074-1-git-send-email-hare@suse.de>
Dumping the entire sense buffer might overwhelm the logging functions,
so suppress it per default.
Signed-off-by: Hannes Reinecke <hare@suse.de.
---
drivers/scsi/53c700.c | 1 -
drivers/scsi/constants.c | 32 ++++++++++++++++++++++----------
drivers/scsi/scsi.c | 6 ++++--
drivers/scsi/sg.c | 9 ++++++---
drivers/scsi/st.c | 11 ++++++++---
include/scsi/scsi_dbg.h | 10 ++++++----
6 files changed, 46 insertions(+), 23 deletions(-)
diff --git a/drivers/scsi/53c700.c b/drivers/scsi/53c700.c
index 68bf423..8752481 100644
--- a/drivers/scsi/53c700.c
+++ b/drivers/scsi/53c700.c
@@ -603,7 +603,6 @@ NCR_700_scsi_done(struct NCR_700_Host_Parameters *hostdata,
printk(" ORIGINAL CMD %p RETURNED %d, new return is %d sense is\n",
SCp, SCp->cmnd[7], result);
scsi_print_sense(SCp);
-
#endif
dma_unmap_single(hostdata->dev, slot->dma_handle,
SCSI_SENSE_BUFFERSIZE, DMA_FROM_DEVICE);
diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c
index f0a6595..ecce5b3 100644
--- a/drivers/scsi/constants.c
+++ b/drivers/scsi/constants.c
@@ -1428,9 +1428,9 @@ scsi_print_sense_hdr(struct scsi_device *sdev, const char *name,
}
EXPORT_SYMBOL(scsi_print_sense_hdr);
-static void
-scsi_dump_sense_buffer(struct scsi_device *sdev, const char *name,
- const unsigned char *sense_buffer, int sense_len)
+void
+__scsi_dump_sense(struct scsi_device *sdev, const char *name,
+ const unsigned char *sense_buffer, int sense_len)
{
char linebuf[128];
int i, linelen, remaining;
@@ -1446,9 +1446,21 @@ scsi_dump_sense_buffer(struct scsi_device *sdev, const char *name,
"Sense: %s\n", linebuf);
}
}
+EXPORT_SYMBOL(__scsi_dump_sense);
+
+void
+scsi_dump_sense(struct scsi_cmnd *cmd)
+{
+ struct gendisk *disk = cmd->request->rq_disk;
+ const char *disk_name = disk ? disk->disk_name : NULL;
+
+ __scsi_dump_sense(cmd->device, disk_name, cmd->sense_buffer,
+ SCSI_SENSE_BUFFERSIZE);
+}
+EXPORT_SYMBOL(scsi_dump_sense);
/* Normalize and print sense buffer with name prefix */
-void __scsi_print_sense(struct scsi_device *sdev, const char *name,
+int __scsi_print_sense(struct scsi_device *sdev, const char *name,
const unsigned char *sense_buffer, int sense_len)
{
struct scsi_sense_hdr sshdr;
@@ -1456,23 +1468,23 @@ void __scsi_print_sense(struct scsi_device *sdev, const char *name,
res = scsi_normalize_sense(sense_buffer, sense_len, &sshdr);
if (res == 0) {
- scsi_dump_sense_buffer(sdev, name, sense_buffer, sense_len);
- return;
+ __scsi_dump_sense(sdev, name, sense_buffer, sense_len);
+ return 0;
}
scsi_show_sense_hdr(sdev, name, &sshdr);
scsi_show_extd_sense(sdev, name, sshdr.asc, sshdr.ascq);
- scsi_dump_sense_buffer(sdev, name, sense_buffer, sense_len);
+ return res;
}
EXPORT_SYMBOL(__scsi_print_sense);
/* Normalize and print sense buffer in SCSI command */
-void scsi_print_sense(struct scsi_cmnd *cmd)
+int scsi_print_sense(struct scsi_cmnd *cmd)
{
struct gendisk *disk = cmd->request->rq_disk;
const char *disk_name = disk ? disk->disk_name : NULL;
- __scsi_print_sense(cmd->device, disk_name, cmd->sense_buffer,
- SCSI_SENSE_BUFFERSIZE);
+ return __scsi_print_sense(cmd->device, disk_name, cmd->sense_buffer,
+ SCSI_SENSE_BUFFERSIZE);
}
EXPORT_SYMBOL(scsi_print_sense);
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index 8954036..283f053 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -597,8 +597,10 @@ void scsi_log_completion(struct scsi_cmnd *cmd, int disposition)
}
scsi_print_result(cmd);
scsi_print_command(cmd);
- if (status_byte(cmd->result) & CHECK_CONDITION)
- scsi_print_sense(cmd);
+ if (status_byte(cmd->result) & CHECK_CONDITION) {
+ if (scsi_print_sense(cmd))
+ scsi_dump_sense(cmd);
+ }
if (level > 3)
scmd_printk(KERN_INFO, cmd,
"scsi host busy %d failed %d\n",
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index 16f826e..6bed135 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -1359,9 +1359,12 @@ sg_rq_end_io(struct request *rq, int uptodate)
srp->header.driver_status = driver_byte(result);
if ((sdp->sgdebug > 0) &&
((CHECK_CONDITION == srp->header.masked_status) ||
- (COMMAND_TERMINATED == srp->header.masked_status)))
- __scsi_print_sense(sdp->device, __func__, sense,
- SCSI_SENSE_BUFFERSIZE);
+ (COMMAND_TERMINATED == srp->header.masked_status))) {
+ if (__scsi_print_sense(sdp->device, __func__, sense,
+ SCSI_SENSE_BUFFERSIZE))
+ __scsi_dump_sense(sdp->device, __func__,
+ sense, SCSI_SENSE_BUFFERSIZE);
+ }
/* Following if statement is a patch supplied by Eric Youngdale */
if (driver_byte(result) != 0
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
index c0cc4ca..8107e03 100644
--- a/drivers/scsi/st.c
+++ b/drivers/scsi/st.c
@@ -373,9 +373,14 @@ static int st_chk_result(struct scsi_tape *STp, struct st_request * SRpnt)
"Error: %x, cmd: %x %x %x %x %x %x\n", result,
SRpnt->cmd[0], SRpnt->cmd[1], SRpnt->cmd[2],
SRpnt->cmd[3], SRpnt->cmd[4], SRpnt->cmd[5]);
- if (cmdstatp->have_sense)
- __scsi_print_sense(STp->device, name,
- SRpnt->sense, SCSI_SENSE_BUFFERSIZE);
+ if (cmdstatp->have_sense) {
+ if (__scsi_print_sense(STp->device, name,
+ SRpnt->sense,
+ SCSI_SENSE_BUFFERSIZE))
+ __scsi_dump_sense(STp->device, name,
+ SRpnt->sense,
+ SCSI_SENSE_BUFFERSIZE);
+ }
} ) /* end DEB */
if (!debugging) { /* Abnormal conditions for tape */
if (!cmdstatp->have_sense)
diff --git a/include/scsi/scsi_dbg.h b/include/scsi/scsi_dbg.h
index cd0c873..0bbf118 100644
--- a/include/scsi/scsi_dbg.h
+++ b/include/scsi/scsi_dbg.h
@@ -13,10 +13,12 @@ extern void scsi_show_sense_hdr(struct scsi_device *, const char *,
struct scsi_sense_hdr *);
extern void scsi_print_sense_hdr(struct scsi_device *, const char *,
struct scsi_sense_hdr *);
-extern void scsi_print_sense(struct scsi_cmnd *);
-extern void __scsi_print_sense(struct scsi_device *, const char *name,
- const unsigned char *sense_buffer,
- int sense_len);
+extern int scsi_print_sense(struct scsi_cmnd *);
+extern int __scsi_print_sense(struct scsi_device *, const char *,
+ const unsigned char *, int);
+extern void scsi_dump_sense(struct scsi_cmnd *);
+extern void __scsi_dump_sense(struct scsi_device *, const char *,
+ const unsigned char *, int);
extern void scsi_show_result(int);
extern void scsi_print_result(struct scsi_cmnd *);
extern void scsi_print_status(unsigned char);
--
1.8.5.2
next prev parent reply other threads:[~2014-08-28 17:33 UTC|newest]
Thread overview: 63+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-28 17:33 [PATCH 00/22] scsi logging update Hannes Reinecke
2014-08-28 17:33 ` [PATCH 01/22] Remove scsi_cmd_print_sense_hdr() Hannes Reinecke
2014-08-31 21:39 ` Christoph Hellwig
2014-08-28 17:33 ` [PATCH 02/22] aha152x: Remove #ifdef 0 section Hannes Reinecke
2014-08-31 21:40 ` Christoph Hellwig
2014-08-28 17:33 ` [PATCH 03/22] sd: Remove scsi_print_sense() in sd_done() Hannes Reinecke
2014-08-31 21:40 ` Christoph Hellwig
2014-08-28 17:33 ` [PATCH 04/22] scsi: introduce sdev_prefix_printk() Hannes Reinecke
2014-08-31 21:43 ` Christoph Hellwig
2014-09-01 7:54 ` Hannes Reinecke
2014-08-28 17:33 ` [PATCH 05/22] scsi: Use sdev as argument for sense code printing Hannes Reinecke
2014-08-31 21:55 ` Christoph Hellwig
2014-09-01 8:00 ` Hannes Reinecke
2014-08-28 17:33 ` [PATCH 06/22] scsi: stop decoding if scsi_normalize_sense() fails Hannes Reinecke
2014-08-31 22:00 ` Christoph Hellwig
2014-09-01 8:06 ` Hannes Reinecke
2014-08-28 17:33 ` [PATCH 07/22] scsi: do not decode sense extras Hannes Reinecke
2014-08-31 22:06 ` Christoph Hellwig
2014-09-01 8:10 ` Hannes Reinecke
2014-08-28 17:33 ` Hannes Reinecke [this message]
2014-08-31 22:09 ` [PATCH 08/22] scsi: dump sense buffer only for debugging Christoph Hellwig
2014-09-01 8:26 ` Hannes Reinecke
2014-08-28 17:33 ` [PATCH 09/22] Use sdev as argument for scsi_print_result Hannes Reinecke
2014-08-31 22:11 ` Christoph Hellwig
2014-09-01 8:43 ` Hannes Reinecke
2014-08-28 17:33 ` [PATCH 10/22] scsi: consolidate scsi_print_status() Hannes Reinecke
2014-08-31 22:14 ` Christoph Hellwig
2014-09-01 8:46 ` Hannes Reinecke
2014-08-28 17:33 ` [PATCH 11/22] Implement scsi_opcode_sa_name Hannes Reinecke
2014-08-28 23:50 ` Douglas Gilbert
2014-08-31 22:16 ` Christoph Hellwig
2014-08-28 17:33 ` [PATCH 12/22] scsi: remove obsolete __scsi_print_command() usages Hannes Reinecke
2014-08-31 22:18 ` Christoph Hellwig
2014-09-01 6:56 ` Hannes Reinecke
2014-08-28 17:33 ` [PATCH 13/22] scsi: use local buffer for printing the opcode Hannes Reinecke
2014-08-31 22:19 ` Christoph Hellwig
2014-09-01 8:57 ` Hannes Reinecke
2014-09-01 14:42 ` Hannes Reinecke
2014-08-28 17:33 ` [PATCH 14/22] scsi: pass in string buffer to __scsi_print_command() Hannes Reinecke
2014-08-28 17:33 ` [PATCH 15/22] scsi: use dev_printk() variants in scsi_print_command() Hannes Reinecke
2014-08-28 17:33 ` [PATCH 16/22] libata: use __scsi_print_command() Hannes Reinecke
2014-08-28 17:33 ` [PATCH 17/22] scsi: print disposition in scsi_print_result() Hannes Reinecke
2014-08-31 22:23 ` Christoph Hellwig
2014-08-28 17:33 ` [PATCH 18/22] scsi_error: format abort error message Hannes Reinecke
2014-08-31 22:25 ` Christoph Hellwig
2014-08-28 17:33 ` [PATCH 19/22] scsi: use local buffer for scsi_log_(send|completion) Hannes Reinecke
2014-08-28 17:33 ` [PATCH 20/22] scsi: align logging messages Hannes Reinecke
2014-08-31 22:25 ` Christoph Hellwig
2014-09-01 1:00 ` Elliott, Robert (Server Storage)
2014-09-06 0:34 ` Christoph Hellwig
2014-09-18 23:58 ` Elliott, Robert (Server Storage)
2014-09-19 6:26 ` Hannes Reinecke
2014-09-19 11:35 ` Christoph Hellwig
2014-09-19 11:56 ` Hannes Reinecke
2014-08-28 17:33 ` [PATCH 21/22] scsi: reduce messages for command failure Hannes Reinecke
2014-08-31 22:28 ` Christoph Hellwig
2014-09-01 1:14 ` Elliott, Robert (Server Storage)
2014-09-06 0:35 ` Christoph Hellwig
2014-08-28 17:33 ` [PATCH 22/22] sd: Reduce logging output Hannes Reinecke
2014-08-31 22:29 ` Christoph Hellwig
2014-09-03 7:58 ` Hannes Reinecke
2014-08-28 19:24 ` [PATCH 00/22] scsi logging update Douglas Gilbert
2014-08-29 9:48 ` Hannes Reinecke
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1409247216-76074-9-git-send-email-hare@suse.de \
--to=hare@suse.de \
--cc=elliot@hp.com \
--cc=emilne@redhat.com \
--cc=hch@infradead.org \
--cc=jbottomley@parallels.com \
--cc=linux-scsi@vger.kernel.org \
--cc=yoshihiro.ynomae.ez@hitachi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox