Commit 8ee132b3 authored by Milan P. Gandhi's avatar Milan P. Gandhi Committed by Martin K. Petersen

scsi: core: Log SCSI command age with errors

Couple of users had requested to print the SCSI command age along with
command failure errors. This is a small change, but allows users to get
more important information about the command that was failed, it would help
the users in debugging the command failures:

Link: https://lore.kernel.org/r/20190926052501.GA8352@machine1Signed-off-by: default avatarMilan P. Gandhi <mgandhi@redhat.com>
Reviewed-by: default avatarBart Van Assche <bvanassche@acm.org>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent c3dde2f3
...@@ -390,6 +390,7 @@ void scsi_print_result(const struct scsi_cmnd *cmd, const char *msg, ...@@ -390,6 +390,7 @@ void scsi_print_result(const struct scsi_cmnd *cmd, const char *msg,
const char *mlret_string = scsi_mlreturn_string(disposition); const char *mlret_string = scsi_mlreturn_string(disposition);
const char *hb_string = scsi_hostbyte_string(cmd->result); const char *hb_string = scsi_hostbyte_string(cmd->result);
const char *db_string = scsi_driverbyte_string(cmd->result); const char *db_string = scsi_driverbyte_string(cmd->result);
unsigned long cmd_age = (jiffies - cmd->jiffies_at_alloc) / HZ;
logbuf = scsi_log_reserve_buffer(&logbuf_len); logbuf = scsi_log_reserve_buffer(&logbuf_len);
if (!logbuf) if (!logbuf)
...@@ -431,10 +432,15 @@ void scsi_print_result(const struct scsi_cmnd *cmd, const char *msg, ...@@ -431,10 +432,15 @@ void scsi_print_result(const struct scsi_cmnd *cmd, const char *msg,
if (db_string) if (db_string)
off += scnprintf(logbuf + off, logbuf_len - off, off += scnprintf(logbuf + off, logbuf_len - off,
"driverbyte=%s", db_string); "driverbyte=%s ", db_string);
else else
off += scnprintf(logbuf + off, logbuf_len - off, off += scnprintf(logbuf + off, logbuf_len - off,
"driverbyte=0x%02x", driver_byte(cmd->result)); "driverbyte=0x%02x ",
driver_byte(cmd->result));
off += scnprintf(logbuf + off, logbuf_len - off,
"cmd_age=%lus", cmd_age);
out_printk: out_printk:
dev_printk(KERN_INFO, &cmd->device->sdev_gendev, "%s", logbuf); dev_printk(KERN_INFO, &cmd->device->sdev_gendev, "%s", logbuf);
scsi_log_release_buffer(logbuf); scsi_log_release_buffer(logbuf);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment