Skip to content

Commit

Permalink
scsi: use per-cpu buffer for formatting scsi_print_result()
Browse files Browse the repository at this point in the history
Convert scsi_print_result() to use the per-cpu buffer for decoding the
command result and disposition.

Tested-by: Robert Elliott <[email protected]>
Reviewed-by: Robert Elliott <[email protected]>
Signed-off-by: Hannes Reinecke <[email protected]>
Signed-off-by: Christoph Hellwig <[email protected]>
  • Loading branch information
hreinecke authored and Christoph Hellwig committed Jan 9, 2015
1 parent 2104551 commit 026f8da
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 24 deletions.
22 changes: 0 additions & 22 deletions drivers/scsi/constants.c
Original file line number Diff line number Diff line change
Expand Up @@ -1316,25 +1316,3 @@ const char *scsi_mlreturn_string(int result)
return NULL;
}
EXPORT_SYMBOL(scsi_mlreturn_string);

void scsi_print_result(struct scsi_cmnd *cmd, const char *msg, int disposition)
{
const char *mlret_string = scsi_mlreturn_string(disposition);
const char *hb_string = scsi_hostbyte_string(cmd->result);
const char *db_string = scsi_driverbyte_string(cmd->result);

if (hb_string || db_string)
scmd_printk(KERN_INFO, cmd,
"%s%s Result: hostbyte=%s driverbyte=%s",
msg ? msg : "",
mlret_string ? mlret_string : "UNKNOWN",
hb_string ? hb_string : "invalid",
db_string ? db_string : "invalid");
else
scmd_printk(KERN_INFO, cmd,
"%s%s Result: hostbyte=0x%02x driverbyte=0x%02x",
msg ? msg : "",
mlret_string ? mlret_string : "UNKNOWN",
host_byte(cmd->result), driver_byte(cmd->result));
}
EXPORT_SYMBOL(scsi_print_result);
2 changes: 1 addition & 1 deletion drivers/scsi/scsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ void scsi_log_completion(struct scsi_cmnd *cmd, int disposition)
SCSI_LOG_MLCOMPLETE_BITS);
if (((level > 0) && (cmd->result || disposition != SUCCESS)) ||
(level > 1)) {
scsi_print_result(cmd, "Done: ", disposition);
scsi_print_result(cmd, "Done", disposition);
scsi_print_command(cmd);
if (status_byte(cmd->result) & CHECK_CONDITION)
scsi_print_sense(cmd);
Expand Down
59 changes: 59 additions & 0 deletions drivers/scsi/scsi_logging.c
Original file line number Diff line number Diff line change
Expand Up @@ -428,3 +428,62 @@ void scsi_print_sense(const struct scsi_cmnd *cmd)
cmd->sense_buffer, SCSI_SENSE_BUFFERSIZE);
}
EXPORT_SYMBOL(scsi_print_sense);

void scsi_print_result(const struct scsi_cmnd *cmd, const char *msg,
int disposition)
{
char *logbuf;
size_t off, logbuf_len;
const char *mlret_string = scsi_mlreturn_string(disposition);
const char *hb_string = scsi_hostbyte_string(cmd->result);
const char *db_string = scsi_driverbyte_string(cmd->result);

logbuf = scsi_log_reserve_buffer(&logbuf_len);
if (!logbuf)
return;

off = sdev_format_header(logbuf, logbuf_len,
scmd_name(cmd), cmd->request->tag);

if (off >= logbuf_len)
goto out_printk;

if (msg) {
off += scnprintf(logbuf + off, logbuf_len - off,
"%s: ", msg);
if (WARN_ON(off >= logbuf_len))
goto out_printk;
}
if (mlret_string)
off += scnprintf(logbuf + off, logbuf_len - off,
"%s ", mlret_string);
else
off += scnprintf(logbuf + off, logbuf_len - off,
"UNKNOWN(0x%02x) ", disposition);
if (WARN_ON(off >= logbuf_len))
goto out_printk;

off += scnprintf(logbuf + off, logbuf_len - off, "Result: ");
if (WARN_ON(off >= logbuf_len))
goto out_printk;

if (hb_string)
off += scnprintf(logbuf + off, logbuf_len - off,
"hostbyte=%s ", hb_string);
else
off += scnprintf(logbuf + off, logbuf_len - off,
"hostbyte=0x%02x ", host_byte(cmd->result));
if (WARN_ON(off >= logbuf_len))
goto out_printk;

if (db_string)
off += scnprintf(logbuf + off, logbuf_len - off,
"driverbyte=%s", db_string);
else
off += scnprintf(logbuf + off, logbuf_len - off,
"driverbyte=0x%02x", driver_byte(cmd->result));
out_printk:
dev_printk(KERN_INFO, &cmd->device->sdev_gendev, logbuf);
scsi_log_release_buffer(logbuf);
}
EXPORT_SYMBOL(scsi_print_result);
2 changes: 1 addition & 1 deletion include/scsi/scsi_dbg.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ extern void scsi_print_sense(const struct scsi_cmnd *);
extern void __scsi_print_sense(const struct scsi_device *, const char *name,
const unsigned char *sense_buffer,
int sense_len);
extern void scsi_print_result(struct scsi_cmnd *, const char *, int);
extern void scsi_print_result(const struct scsi_cmnd *, const char *, int);
extern const char *scsi_hostbyte_string(int);
extern const char *scsi_driverbyte_string(int);
extern const char *scsi_mlreturn_string(int);
Expand Down

0 comments on commit 026f8da

Please sign in to comment.