mirror of
https://github.com/torvalds/linux.git
synced 2024-11-13 07:31:45 +00:00
scsi: use per-cpu buffer for formatting scsi_print_result()
Convert scsi_print_result() to use the per-cpu buffer for decoding the command result and disposition. Tested-by: Robert Elliott <elliott@hp.com> Reviewed-by: Robert Elliott <elliott@hp.com> Signed-off-by: Hannes Reinecke <hare@suse.de> Signed-off-by: Christoph Hellwig <hch@lst.de>
This commit is contained in:
parent
2104551969
commit
026f8da8da
@ -1316,25 +1316,3 @@ const char *scsi_mlreturn_string(int result)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(scsi_mlreturn_string);
|
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);
|
|
||||||
|
@ -572,7 +572,7 @@ void scsi_log_completion(struct scsi_cmnd *cmd, int disposition)
|
|||||||
SCSI_LOG_MLCOMPLETE_BITS);
|
SCSI_LOG_MLCOMPLETE_BITS);
|
||||||
if (((level > 0) && (cmd->result || disposition != SUCCESS)) ||
|
if (((level > 0) && (cmd->result || disposition != SUCCESS)) ||
|
||||||
(level > 1)) {
|
(level > 1)) {
|
||||||
scsi_print_result(cmd, "Done: ", disposition);
|
scsi_print_result(cmd, "Done", disposition);
|
||||||
scsi_print_command(cmd);
|
scsi_print_command(cmd);
|
||||||
if (status_byte(cmd->result) & CHECK_CONDITION)
|
if (status_byte(cmd->result) & CHECK_CONDITION)
|
||||||
scsi_print_sense(cmd);
|
scsi_print_sense(cmd);
|
||||||
|
@ -428,3 +428,62 @@ void scsi_print_sense(const struct scsi_cmnd *cmd)
|
|||||||
cmd->sense_buffer, SCSI_SENSE_BUFFERSIZE);
|
cmd->sense_buffer, SCSI_SENSE_BUFFERSIZE);
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(scsi_print_sense);
|
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);
|
||||||
|
@ -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,
|
extern void __scsi_print_sense(const struct scsi_device *, const char *name,
|
||||||
const unsigned char *sense_buffer,
|
const unsigned char *sense_buffer,
|
||||||
int sense_len);
|
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_hostbyte_string(int);
|
||||||
extern const char *scsi_driverbyte_string(int);
|
extern const char *scsi_driverbyte_string(int);
|
||||||
extern const char *scsi_mlreturn_string(int);
|
extern const char *scsi_mlreturn_string(int);
|
||||||
|
Loading…
Reference in New Issue
Block a user