From: Bart Van Assche <bvanassche@acm.org>
To: "Martin K . Petersen" <martin.petersen@oracle.com>,
"James E . J . Bottomley" <jejb@linux.vnet.ibm.com>
Cc: linux-scsi@vger.kernel.org, Christoph Hellwig <hch@lst.de>,
Bart Van Assche <bvanassche@acm.org>,
Hannes Reinecke <hare@suse.de>
Subject: [PATCH 013/117] core: Convert to the scsi_status union
Date: Mon, 19 Apr 2021 17:07:01 -0700 [thread overview]
Message-ID: <20210420000845.25873-14-bvanassche@acm.org> (raw)
In-Reply-To: <20210420000845.25873-1-bvanassche@acm.org>
An explanation of the purpose of this patch is available in the patch
"scsi: Introduce the scsi_status union".
Cc: Hannes Reinecke <hare@suse.de>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
drivers/scsi/device_handler/scsi_dh_alua.c | 20 ++++----
drivers/scsi/hosts.c | 2 +-
drivers/scsi/scsi.c | 8 +--
drivers/scsi/scsi_debugfs.c | 2 +-
drivers/scsi/scsi_error.c | 44 ++++++++--------
drivers/scsi/scsi_ioctl.c | 12 ++---
drivers/scsi/scsi_lib.c | 59 ++++++++++++----------
drivers/scsi/scsi_logging.c | 8 +--
drivers/scsi/scsi_scan.c | 15 +++---
drivers/scsi/scsi_transport_spi.c | 8 +--
include/trace/events/scsi.h | 2 +-
11 files changed, 96 insertions(+), 84 deletions(-)
diff --git a/drivers/scsi/device_handler/scsi_dh_alua.c b/drivers/scsi/device_handler/scsi_dh_alua.c
index efa8c0381476..d8269cdec399 100644
--- a/drivers/scsi/device_handler/scsi_dh_alua.c
+++ b/drivers/scsi/device_handler/scsi_dh_alua.c
@@ -517,7 +517,8 @@ static int alua_rtpg(struct scsi_device *sdev, struct alua_port_group *pg)
int len, k, off, bufflen = ALUA_RTPG_SIZE;
int group_id_old, state_old, pref_old, valid_states_old;
unsigned char *desc, *buff;
- unsigned err, retval;
+ unsigned err;
+ union scsi_status retval;
unsigned int tpg_desc_tbl_off;
unsigned char orig_transition_tmo;
unsigned long flags;
@@ -543,9 +544,10 @@ static int alua_rtpg(struct scsi_device *sdev, struct alua_port_group *pg)
retry:
err = 0;
- retval = submit_rtpg(sdev, buff, bufflen, &sense_hdr, pg->flags);
+ retval.combined = submit_rtpg(sdev, buff, bufflen, &sense_hdr,
+ pg->flags);
- if (retval) {
+ if (retval.combined) {
/*
* Some (broken) implementations have a habit of returning
* an error during things like firmware update etc.
@@ -558,14 +560,14 @@ static int alua_rtpg(struct scsi_device *sdev, struct alua_port_group *pg)
if ((pg->valid_states & ~TPGS_SUPPORT_OPTIMIZED) == 0) {
sdev_printk(KERN_INFO, sdev,
"%s: ignoring rtpg result %d\n",
- ALUA_DH_NAME, retval);
+ ALUA_DH_NAME, retval.combined);
kfree(buff);
return SCSI_DH_OK;
}
if (!scsi_sense_valid(&sense_hdr)) {
sdev_printk(KERN_INFO, sdev,
"%s: rtpg failed, result %d\n",
- ALUA_DH_NAME, retval);
+ ALUA_DH_NAME, retval.combined);
kfree(buff);
if (driver_byte(retval) == DRIVER_ERROR)
return SCSI_DH_DEV_TEMP_BUSY;
@@ -759,7 +761,7 @@ static int alua_rtpg(struct scsi_device *sdev, struct alua_port_group *pg)
*/
static unsigned alua_stpg(struct scsi_device *sdev, struct alua_port_group *pg)
{
- int retval;
+ union scsi_status retval;
struct scsi_sense_hdr sense_hdr;
if (!(pg->tpgs & TPGS_MODE_EXPLICIT)) {
@@ -788,13 +790,13 @@ static unsigned alua_stpg(struct scsi_device *sdev, struct alua_port_group *pg)
ALUA_DH_NAME, pg->state);
return SCSI_DH_NOSYS;
}
- retval = submit_stpg(sdev, pg->group_id, &sense_hdr);
+ retval.combined = submit_stpg(sdev, pg->group_id, &sense_hdr);
- if (retval) {
+ if (retval.combined) {
if (!scsi_sense_valid(&sense_hdr)) {
sdev_printk(KERN_INFO, sdev,
"%s: stpg failed, result %d",
- ALUA_DH_NAME, retval);
+ ALUA_DH_NAME, retval.combined);
if (driver_byte(retval) == DRIVER_ERROR)
return SCSI_DH_DEV_TEMP_BUSY;
} else {
diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
index b551e0ee2271..4c1e80a4a7c3 100644
--- a/drivers/scsi/hosts.c
+++ b/drivers/scsi/hosts.c
@@ -660,7 +660,7 @@ static bool complete_all_cmds_iter(struct request *rq, void *data, bool rsvd)
enum host_status status = *(enum host_status *)data;
scsi_dma_unmap(scmd);
- scmd->result = 0;
+ scmd->status.combined = 0;
set_host_byte(scmd, status);
scmd->scsi_done(scmd);
return true;
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index 4f71f2005be4..c6f3bbec8982 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -140,11 +140,11 @@ void scsi_log_completion(struct scsi_cmnd *cmd, int disposition)
if (unlikely(scsi_logging_level)) {
level = SCSI_LOG_LEVEL(SCSI_LOG_MLCOMPLETE_SHIFT,
SCSI_LOG_MLCOMPLETE_BITS);
- if (((level > 0) && (cmd->result || disposition != SUCCESS)) ||
+ if (((level > 0) && (cmd->status.combined || disposition != SUCCESS)) ||
(level > 1)) {
scsi_print_result(cmd, "Done", disposition);
scsi_print_command(cmd);
- if (status_byte(cmd->result) == CHECK_CONDITION)
+ if (status_byte(cmd->status) == CHECK_CONDITION)
scsi_print_sense(cmd);
if (level > 3)
scmd_printk(KERN_INFO, cmd,
@@ -190,11 +190,11 @@ void scsi_finish_command(struct scsi_cmnd *cmd)
* must have taken place. Make a note of this.
*/
if (SCSI_SENSE_VALID(cmd))
- cmd->result |= (DRIVER_SENSE << 24);
+ cmd->status.combined |= (DRIVER_SENSE << 24);
SCSI_LOG_MLCOMPLETE(4, sdev_printk(KERN_INFO, sdev,
"Notifying upper driver of completion "
- "(result %x)\n", cmd->result));
+ "(result %x)\n", cmd->status.combined));
good_bytes = scsi_bufflen(cmd);
if (!blk_rq_is_passthrough(cmd->request)) {
diff --git a/drivers/scsi/scsi_debugfs.c b/drivers/scsi/scsi_debugfs.c
index c19ea7ab54cb..09679072b070 100644
--- a/drivers/scsi/scsi_debugfs.c
+++ b/drivers/scsi/scsi_debugfs.c
@@ -42,7 +42,7 @@ void scsi_show_rq(struct seq_file *m, struct request *rq)
if (cdb)
__scsi_format_command(buf, sizeof(buf), cdb, cmd->cmd_len);
seq_printf(m, ", .cmd=%s, .retries=%d, .result = %#x, .flags=", buf,
- cmd->retries, cmd->result);
+ cmd->retries, cmd->status.combined);
scsi_flags_show(m, cmd->flags, scsi_cmd_flags,
ARRAY_SIZE(scsi_cmd_flags));
seq_printf(m, ", .timeout=%d.%03d, allocated %d.%03d s ago",
diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index 54213c37806b..e54fbdc9206c 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -732,7 +732,7 @@ static enum scsi_disposition scsi_eh_completed_normally(struct scsi_cmnd *scmd)
* first check the host byte, to see if there is anything in there
* that would indicate what we need to do.
*/
- if (host_byte(scmd->result) == DID_RESET) {
+ if (host_byte(scmd->status) == DID_RESET) {
/*
* rats. we are already in the error handler, so we now
* get to try and figure out what to do next. if the sense
@@ -741,20 +741,20 @@ static enum scsi_disposition scsi_eh_completed_normally(struct scsi_cmnd *scmd)
*/
return scsi_check_sense(scmd);
}
- if (host_byte(scmd->result) != DID_OK)
+ if (host_byte(scmd->status) != DID_OK)
return FAILED;
/*
* next, check the message byte.
*/
- if (msg_byte(scmd->result) != COMMAND_COMPLETE)
+ if (msg_byte(scmd->status) != COMMAND_COMPLETE)
return FAILED;
/*
* now, check the status byte to see if this indicates
* anything special.
*/
- switch (status_byte(scmd->result)) {
+ switch (status_byte(scmd->status)) {
case GOOD:
scsi_handle_queue_ramp_up(scmd->device);
fallthrough;
@@ -796,7 +796,7 @@ static void scsi_eh_done(struct scsi_cmnd *scmd)
struct completion *eh_action;
SCSI_LOG_ERROR_RECOVERY(3, scmd_printk(KERN_INFO, scmd,
- "%s result: %x\n", __func__, scmd->result));
+ "%s result: %x\n", __func__, scmd->status.combined));
eh_action = scmd->device->host->eh_action;
if (eh_action)
@@ -989,7 +989,7 @@ void scsi_eh_prep_cmnd(struct scsi_cmnd *scmd, struct scsi_eh_save *ses,
ses->cmnd = scmd->cmnd;
ses->data_direction = scmd->sc_data_direction;
ses->sdb = scmd->sdb;
- ses->result = scmd->result;
+ ses->status = scmd->status;
ses->resid_len = scmd->req.resid_len;
ses->underflow = scmd->underflow;
ses->prot_op = scmd->prot_op;
@@ -1000,7 +1000,7 @@ void scsi_eh_prep_cmnd(struct scsi_cmnd *scmd, struct scsi_eh_save *ses,
scmd->cmnd = ses->eh_cmnd;
memset(scmd->cmnd, 0, BLK_MAX_CDB);
memset(&scmd->sdb, 0, sizeof(scmd->sdb));
- scmd->result = 0;
+ scmd->status.combined = 0;
scmd->req.resid_len = 0;
if (sense_bytes) {
@@ -1053,7 +1053,7 @@ void scsi_eh_restore_cmnd(struct scsi_cmnd* scmd, struct scsi_eh_save *ses)
scmd->cmnd = ses->cmnd;
scmd->sc_data_direction = ses->data_direction;
scmd->sdb = ses->sdb;
- scmd->result = ses->result;
+ scmd->status = ses->status;
scmd->req.resid_len = ses->resid_len;
scmd->underflow = ses->underflow;
scmd->prot_op = ses->prot_op;
@@ -1261,7 +1261,7 @@ int scsi_eh_get_sense(struct list_head *work_q,
current->comm));
break;
}
- if (status_byte(scmd->result) != CHECK_CONDITION)
+ if (status_byte(scmd->status) != CHECK_CONDITION)
/*
* don't request sense if there's no check condition
* status because the error we're processing isn't one
@@ -1278,7 +1278,7 @@ int scsi_eh_get_sense(struct list_head *work_q,
continue;
SCSI_LOG_ERROR_RECOVERY(3, scmd_printk(KERN_INFO, scmd,
- "sense requested, result %x\n", scmd->result));
+ "sense requested, result %x\n", scmd->status.combined));
SCSI_LOG_ERROR_RECOVERY(3, scsi_print_sense(scmd));
rtn = scsi_decide_disposition(scmd);
@@ -1759,7 +1759,7 @@ static void scsi_eh_offline_sdevs(struct list_head *work_q,
*/
int scsi_noretry_cmd(struct scsi_cmnd *scmd)
{
- switch (host_byte(scmd->result)) {
+ switch (host_byte(scmd->status)) {
case DID_OK:
break;
case DID_TIME_OUT:
@@ -1769,8 +1769,8 @@ int scsi_noretry_cmd(struct scsi_cmnd *scmd)
case DID_PARITY:
return (scmd->request->cmd_flags & REQ_FAILFAST_DEV);
case DID_ERROR:
- if (msg_byte(scmd->result) == COMMAND_COMPLETE &&
- status_byte(scmd->result) == RESERVATION_CONFLICT)
+ if (msg_byte(scmd->status) == COMMAND_COMPLETE &&
+ status_byte(scmd->status) == RESERVATION_CONFLICT)
return 0;
fallthrough;
case DID_SOFT_ERROR:
@@ -1779,7 +1779,7 @@ int scsi_noretry_cmd(struct scsi_cmnd *scmd)
break;
}
- if (status_byte(scmd->result) != CHECK_CONDITION)
+ if (status_byte(scmd->status) != CHECK_CONDITION)
return 0;
check_type:
@@ -1826,14 +1826,14 @@ enum scsi_disposition scsi_decide_disposition(struct scsi_cmnd *scmd)
* first check the host byte, to see if there is anything in there
* that would indicate what we need to do.
*/
- switch (host_byte(scmd->result)) {
+ switch (host_byte(scmd->status)) {
case DID_PASSTHROUGH:
/*
* no matter what, pass this through to the upper layer.
* nuke this special code so that it looks like we are saying
* did_ok.
*/
- scmd->result &= 0xff00ffff;
+ set_host_byte(scmd, DID_OK);
return SUCCESS;
case DID_OK:
/*
@@ -1888,8 +1888,8 @@ enum scsi_disposition scsi_decide_disposition(struct scsi_cmnd *scmd)
*/
return SUCCESS;
case DID_ERROR:
- if (msg_byte(scmd->result) == COMMAND_COMPLETE &&
- status_byte(scmd->result) == RESERVATION_CONFLICT)
+ if (msg_byte(scmd->status) == COMMAND_COMPLETE &&
+ status_byte(scmd->status) == RESERVATION_CONFLICT)
/*
* execute reservation conflict processing code
* lower down
@@ -1920,13 +1920,13 @@ enum scsi_disposition scsi_decide_disposition(struct scsi_cmnd *scmd)
/*
* next, check the message byte.
*/
- if (msg_byte(scmd->result) != COMMAND_COMPLETE)
+ if (msg_byte(scmd->status) != COMMAND_COMPLETE)
return FAILED;
/*
* check the status byte to see if this indicates anything special.
*/
- switch (status_byte(scmd->result)) {
+ switch (status_byte(scmd->status)) {
case QUEUE_FULL:
scsi_handle_queue_full(scmd->device);
/*
@@ -2144,8 +2144,8 @@ void scsi_eh_flush_done_q(struct list_head *done_q)
* scsi_eh_get_sense), scmd->result is already
* set, do not set DRIVER_TIMEOUT.
*/
- if (!scmd->result)
- scmd->result |= (DRIVER_TIMEOUT << 24);
+ if (!scmd->status.combined)
+ scmd->status.combined |= (DRIVER_TIMEOUT << 24);
SCSI_LOG_ERROR_RECOVERY(3,
scmd_printk(KERN_INFO, scmd,
"%s: flush finish cmd\n",
diff --git a/drivers/scsi/scsi_ioctl.c b/drivers/scsi/scsi_ioctl.c
index 14872c9dc78c..fee0e72917b3 100644
--- a/drivers/scsi/scsi_ioctl.c
+++ b/drivers/scsi/scsi_ioctl.c
@@ -89,17 +89,17 @@ static int ioctl_probe(struct Scsi_Host *host, void __user *buffer)
static int ioctl_internal_command(struct scsi_device *sdev, char *cmd,
int timeout, int retries)
{
- int result;
+ union scsi_status result;
struct scsi_sense_hdr sshdr;
SCSI_LOG_IOCTL(1, sdev_printk(KERN_INFO, sdev,
"Trying ioctl with scsi command %d\n", *cmd));
- result = scsi_execute_req(sdev, cmd, DMA_NONE, NULL, 0,
+ result.combined = scsi_execute_req(sdev, cmd, DMA_NONE, NULL, 0,
&sshdr, timeout, retries, NULL);
SCSI_LOG_IOCTL(2, sdev_printk(KERN_INFO, sdev,
- "Ioctl returned 0x%x\n", result));
+ "Ioctl returned 0x%x\n", result.combined));
if (driver_byte(result) == DRIVER_SENSE &&
scsi_sense_valid(&sshdr)) {
@@ -121,14 +121,14 @@ static int ioctl_internal_command(struct scsi_device *sdev, char *cmd,
case UNIT_ATTENTION:
if (sdev->removable) {
sdev->changed = 1;
- result = 0; /* This is no longer considered an error */
+ result.combined = 0; /* This is no longer considered an error */
break;
}
fallthrough; /* for non-removable media */
default:
sdev_printk(KERN_INFO, sdev,
"ioctl_internal_command return code = %x\n",
- result);
+ result.combined);
scsi_print_sense_hdr(sdev, NULL, &sshdr);
break;
}
@@ -136,7 +136,7 @@ static int ioctl_internal_command(struct scsi_device *sdev, char *cmd,
SCSI_LOG_IOCTL(2, sdev_printk(KERN_INFO, sdev,
"IOCTL Releasing command\n"));
- return result;
+ return result.combined;
}
int scsi_set_medium_removal(struct scsi_device *sdev, char state)
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index a979a9457dff..882e04c8be69 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -196,7 +196,7 @@ static void __scsi_queue_insert(struct scsi_cmnd *cmd, int reason, bool unbusy)
* lock such that the kblockd_schedule_work() call happens
* before blk_cleanup_queue() finishes.
*/
- cmd->result = 0;
+ cmd->status.combined = 0;
blk_mq_requeue_request(cmd->request, true);
}
@@ -286,7 +286,7 @@ int __scsi_execute(struct scsi_device *sdev, const unsigned char *cmd,
memcpy(sense, rq->sense, SCSI_SENSE_BUFFERSIZE);
if (sshdr)
scsi_normalize_sense(rq->sense, rq->sense_len, sshdr);
- ret = rq->result;
+ ret = rq->status.combined;
out:
blk_put_request(req);
@@ -616,9 +616,10 @@ static bool scsi_end_request(struct request *req, blk_status_t error,
* @result: scsi error code
*
* Translate a SCSI result code into a blk_status_t value. May reset the host
- * byte of @cmd->result.
+ * byte of @cmd->status.
*/
-static blk_status_t scsi_result_to_blk_status(struct scsi_cmnd *cmd, int result)
+static blk_status_t scsi_result_to_blk_status(struct scsi_cmnd *cmd,
+ union scsi_status result)
{
switch (host_byte(result)) {
case DID_OK:
@@ -627,7 +628,8 @@ static blk_status_t scsi_result_to_blk_status(struct scsi_cmnd *cmd, int result)
* to handle the case when a SCSI LLD sets result to
* DRIVER_SENSE << 24 without setting SAM_STAT_CHECK_CONDITION.
*/
- if (scsi_status_is_good(result) && (result & ~0xff) == 0)
+ if (scsi_status_is_good(result) &&
+ (result.combined & ~0xff) == 0)
return BLK_STS_OK;
return BLK_STS_IOERR;
case DID_TRANSPORT_FAILFAST:
@@ -676,7 +678,8 @@ static bool scsi_cmd_runtime_exceeced(struct scsi_cmnd *cmd)
}
/* Helper for scsi_io_completion() when special action required. */
-static void scsi_io_completion_action(struct scsi_cmnd *cmd, int result)
+static void scsi_io_completion_action(struct scsi_cmnd *cmd,
+ union scsi_status result)
{
struct request_queue *q = cmd->device->request_queue;
struct request *req = cmd->request;
@@ -844,12 +847,12 @@ static void scsi_io_completion_action(struct scsi_cmnd *cmd, int result)
}
/*
- * Helper for scsi_io_completion() when cmd->result is non-zero. Returns a
+ * Helper for scsi_io_completion() when cmd->status is non-zero. Returns a
* new result that may suppress further error checking. Also modifies
* *blk_statp in some cases.
*/
-static int scsi_io_completion_nz_result(struct scsi_cmnd *cmd, int result,
- blk_status_t *blk_statp)
+static union scsi_status scsi_io_completion_nz_result(struct scsi_cmnd *cmd,
+ union scsi_status result, blk_status_t *blk_statp)
{
bool sense_valid;
bool sense_current = true; /* false implies "deferred sense" */
@@ -882,7 +885,7 @@ static int scsi_io_completion_nz_result(struct scsi_cmnd *cmd, int result,
/*
* Recovered errors need reporting, but they're always treated as
* success, so fiddle the result code here. For passthrough requests
- * we already took a copy of the original into sreq->result which
+ * we already took a copy of the original into sreq->status which
* is what gets returned to the user
*/
if (sense_valid && (sshdr.sense_key == RECOVERED_ERROR)) {
@@ -898,7 +901,7 @@ static int scsi_io_completion_nz_result(struct scsi_cmnd *cmd, int result,
do_print = false;
if (do_print)
scsi_print_sense(cmd);
- result = 0;
+ result.combined = 0;
/* for passthrough, *blk_statp may be set */
*blk_statp = BLK_STS_OK;
}
@@ -910,7 +913,7 @@ static int scsi_io_completion_nz_result(struct scsi_cmnd *cmd, int result,
* intermediate statuses (both obsolete in SAM-4) as good.
*/
if (status_byte(result) && scsi_status_is_good(result)) {
- result = 0;
+ result.combined = 0;
*blk_statp = BLK_STS_OK;
}
return result;
@@ -940,19 +943,20 @@ static int scsi_io_completion_nz_result(struct scsi_cmnd *cmd, int result,
*/
void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
{
- int result = cmd->result;
+ union scsi_status result = cmd->status;
struct request_queue *q = cmd->device->request_queue;
struct request *req = cmd->request;
blk_status_t blk_stat = BLK_STS_OK;
- if (unlikely(result)) /* a nz result may or may not be an error */
+ /* a non-zero result may or may not be an error */
+ if (unlikely(result.combined))
result = scsi_io_completion_nz_result(cmd, result, &blk_stat);
if (unlikely(blk_rq_is_passthrough(req))) {
/*
* scsi_result_to_blk_status may have reset the host_byte
*/
- scsi_req(req)->result = cmd->result;
+ scsi_req(req)->status = cmd->status;
}
/*
@@ -984,7 +988,7 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
* If there had been no error, but we have leftover bytes in the
* requeues just queue the command up again.
*/
- if (likely(result == 0))
+ if (likely(result.combined == 0))
scsi_io_completion_reprep(cmd, q);
else
scsi_io_completion_action(cmd, result);
@@ -1446,7 +1450,7 @@ static void scsi_complete(struct request *rq)
INIT_LIST_HEAD(&cmd->eh_entry);
atomic_inc(&cmd->device->iodone_cnt);
- if (cmd->result)
+ if (cmd->status.combined)
atomic_inc(&cmd->device->ioerr_cnt);
disposition = scsi_decide_disposition(cmd);
@@ -1490,7 +1494,7 @@ static int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
/* in SDEV_DEL we error all commands. DID_NO_CONNECT
* returns an immediate error upwards, and signals
* that the device is no longer present */
- cmd->result = DID_NO_CONNECT << 16;
+ cmd->status.combined = DID_NO_CONNECT << 16;
goto done;
}
@@ -1524,12 +1528,12 @@ static int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
"queuecommand : command too long. "
"cdb_size=%d host->max_cmd_len=%d\n",
cmd->cmd_len, cmd->device->host->max_cmd_len));
- cmd->result = (DID_ABORT << 16);
+ cmd->status.combined = (DID_ABORT << 16);
goto done;
}
if (unlikely(host->shost_state == SHOST_DEL)) {
- cmd->result = (DID_NO_CONNECT << 16);
+ cmd->status.combined = (DID_NO_CONNECT << 16);
goto done;
}
@@ -1742,15 +1746,15 @@ static blk_status_t scsi_queue_rq(struct blk_mq_hw_ctx *hctx,
ret = BLK_STS_DEV_RESOURCE;
break;
case BLK_STS_AGAIN:
- scsi_req(req)->result = DID_BUS_BUSY << 16;
+ scsi_req(req)->status.combined = DID_BUS_BUSY << 16;
if (req->rq_flags & RQF_DONTPREP)
scsi_mq_uninit_cmd(cmd);
break;
default:
if (unlikely(!scsi_device_online(sdev)))
- scsi_req(req)->result = DID_NO_CONNECT << 16;
+ scsi_req(req)->status.combined = DID_NO_CONNECT << 16;
else
- scsi_req(req)->result = DID_ERROR << 16;
+ scsi_req(req)->status.combined = DID_ERROR << 16;
/*
* Make sure to release all allocated resources when
* we hit an error, as we will never see this command
@@ -2147,7 +2151,8 @@ scsi_mode_sense(struct scsi_device *sdev, int dbd, int modepage,
unsigned char cmd[12];
int use_10_for_ms;
int header_length;
- int result, retry_count = retries;
+ union scsi_status result;
+ int retry_count = retries;
struct scsi_sense_hdr my_sshdr;
memset(data, 0, sizeof(*data));
@@ -2182,8 +2187,8 @@ scsi_mode_sense(struct scsi_device *sdev, int dbd, int modepage,
memset(buffer, 0, len);
- result = scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE, buffer, len,
- sshdr, timeout, retries, NULL);
+ result.combined = scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE, buffer,
+ len, sshdr, timeout, retries, NULL);
/* This code looks awful: what it's doing is making sure an
* ILLEGAL REQUEST sense return identifies the actual command
@@ -2235,7 +2240,7 @@ scsi_mode_sense(struct scsi_device *sdev, int dbd, int modepage,
goto retry;
}
- return result;
+ return result.combined;
}
EXPORT_SYMBOL(scsi_mode_sense);
diff --git a/drivers/scsi/scsi_logging.c b/drivers/scsi/scsi_logging.c
index 8ea44c6595ef..5c994ba1fad8 100644
--- a/drivers/scsi/scsi_logging.c
+++ b/drivers/scsi/scsi_logging.c
@@ -384,8 +384,8 @@ void scsi_print_result(const struct scsi_cmnd *cmd, const char *msg,
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);
+ const char *hb_string = scsi_hostbyte_string(cmd->status.combined);
+ const char *db_string = scsi_driverbyte_string(cmd->status.combined);
unsigned long cmd_age = (jiffies - cmd->jiffies_at_alloc) / HZ;
logbuf = scsi_log_reserve_buffer(&logbuf_len);
@@ -422,7 +422,7 @@ void scsi_print_result(const struct scsi_cmnd *cmd, const char *msg,
"hostbyte=%s ", hb_string);
else
off += scnprintf(logbuf + off, logbuf_len - off,
- "hostbyte=0x%02x ", host_byte(cmd->result));
+ "hostbyte=0x%02x ", host_byte(cmd->status));
if (WARN_ON(off >= logbuf_len))
goto out_printk;
@@ -432,7 +432,7 @@ void scsi_print_result(const struct scsi_cmnd *cmd, const char *msg,
else
off += scnprintf(logbuf + off, logbuf_len - off,
"driverbyte=0x%02x ",
- driver_byte(cmd->result));
+ driver_byte(cmd->status));
off += scnprintf(logbuf + off, logbuf_len - off,
"cmd_age=%lus", cmd_age);
diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index 9f1b7f3c650a..43346f7dedd1 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -580,7 +580,8 @@ static int scsi_probe_lun(struct scsi_device *sdev, unsigned char *inq_result,
unsigned char scsi_cmd[MAX_COMMAND_SIZE];
int first_inquiry_len, try_inquiry_len, next_inquiry_len;
int response_len = 0;
- int pass, count, result;
+ int pass, count;
+ union scsi_status result;
struct scsi_sense_hdr sshdr;
*bflags = 0;
@@ -607,16 +608,18 @@ static int scsi_probe_lun(struct scsi_device *sdev, unsigned char *inq_result,
memset(inq_result, 0, try_inquiry_len);
- result = scsi_execute_req(sdev, scsi_cmd, DMA_FROM_DEVICE,
+ result.combined =
+ scsi_execute_req(sdev, scsi_cmd, DMA_FROM_DEVICE,
inq_result, try_inquiry_len, &sshdr,
HZ / 2 + HZ * scsi_inq_timeout, 3,
&resid);
SCSI_LOG_SCAN_BUS(3, sdev_printk(KERN_INFO, sdev,
"scsi scan: INQUIRY %s with code 0x%x\n",
- result ? "failed" : "successful", result));
+ result.combined ? "failed" : "successful",
+ result.combined));
- if (result) {
+ if (result.combined) {
/*
* not-ready to ready transition [asc/ascq=0x28/0x0]
* or power-on, reset [asc/ascq=0x29/0x0], continue.
@@ -643,7 +646,7 @@ static int scsi_probe_lun(struct scsi_device *sdev, unsigned char *inq_result,
break;
}
- if (result == 0) {
+ if (result.combined == 0) {
scsi_sanitize_inquiry_string(&inq_result[8], 8);
scsi_sanitize_inquiry_string(&inq_result[16], 16);
scsi_sanitize_inquiry_string(&inq_result[32], 4);
@@ -695,7 +698,7 @@ static int scsi_probe_lun(struct scsi_device *sdev, unsigned char *inq_result,
/* If the last transfer attempt got an error, assume the
* peripheral doesn't exist or is dead. */
- if (result)
+ if (result.combined)
return -EIO;
/* Don't report any more data than the device says is valid */
diff --git a/drivers/scsi/scsi_transport_spi.c b/drivers/scsi/scsi_transport_spi.c
index c37dd15d16d2..8788066275df 100644
--- a/drivers/scsi/scsi_transport_spi.c
+++ b/drivers/scsi/scsi_transport_spi.c
@@ -109,7 +109,8 @@ static int spi_execute(struct scsi_device *sdev, const void *cmd,
void *buffer, unsigned bufflen,
struct scsi_sense_hdr *sshdr)
{
- int i, result;
+ int i;
+ union scsi_status result;
unsigned char sense[SCSI_SENSE_BUFFERSIZE];
struct scsi_sense_hdr sshdr_tmp;
@@ -121,7 +122,8 @@ static int spi_execute(struct scsi_device *sdev, const void *cmd,
* The purpose of the RQF_PM flag below is to bypass the
* SDEV_QUIESCE state.
*/
- result = scsi_execute(sdev, cmd, dir, buffer, bufflen, sense,
+ result.combined =
+ scsi_execute(sdev, cmd, dir, buffer, bufflen, sense,
sshdr, DV_TIMEOUT, /* retries */ 1,
REQ_FAILFAST_DEV |
REQ_FAILFAST_TRANSPORT |
@@ -131,7 +133,7 @@ static int spi_execute(struct scsi_device *sdev, const void *cmd,
sshdr->sense_key != UNIT_ATTENTION)
break;
}
- return result;
+ return result.combined;
}
static struct {
diff --git a/include/trace/events/scsi.h b/include/trace/events/scsi.h
index f624969a4f14..13da567f5b72 100644
--- a/include/trace/events/scsi.h
+++ b/include/trace/events/scsi.h
@@ -309,7 +309,7 @@ DECLARE_EVENT_CLASS(scsi_cmd_done_timeout_template,
__entry->channel = cmd->device->channel;
__entry->id = cmd->device->id;
__entry->lun = cmd->device->lun;
- __entry->result = cmd->result;
+ __entry->result = cmd->status.combined;
__entry->opcode = cmd->cmnd[0];
__entry->cmd_len = cmd->cmd_len;
__entry->data_sglen = scsi_sg_count(cmd);
next prev parent reply other threads:[~2021-04-20 0:09 UTC|newest]
Thread overview: 158+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-20 0:06 [PATCH 000/117] Make better use of static type checking Bart Van Assche
2021-04-20 0:06 ` [PATCH 001/117] libsas: Introduce more SAM status code aliases in enum exec_status Bart Van Assche
2021-04-20 0:06 ` [PATCH 002/117] Introduce enums for the SAM, message, host and driver status codes Bart Van Assche
2021-04-20 9:23 ` Steffen Maier
2021-04-20 14:59 ` Bart Van Assche
2021-04-20 0:06 ` [PATCH 003/117] Change the type of the second argument of scsi_host_complete_all_commands() Bart Van Assche
2021-04-20 0:06 ` [PATCH 004/117] libiscsi: Use the host_status enum Bart Van Assche
2021-05-06 16:51 ` Lee Duncan
2021-04-20 0:06 ` [PATCH 005/117] libsas: Use the host_status and sam_status enums Bart Van Assche
2021-04-20 0:06 ` [PATCH 006/117] target: Use enum sam_status instead of u8 Bart Van Assche
2021-04-20 0:06 ` [PATCH 007/117] lpfc: Reformat four comparisons Bart Van Assche
2021-04-21 20:22 ` James Smart
2021-04-20 0:06 ` [PATCH 008/117] fc: Add a compile-time structure size check Bart Van Assche
2021-04-20 0:06 ` [PATCH 009/117] iscsi: " Bart Van Assche
2021-05-06 16:52 ` Lee Duncan
2021-04-20 0:06 ` [PATCH 010/117] ufs: " Bart Van Assche
2021-05-06 23:56 ` Can Guo
2021-04-20 0:06 ` [PATCH 011/117] Introduce the scsi_status union Bart Van Assche
2021-05-06 17:04 ` Lee Duncan
2021-05-07 0:04 ` Can Guo
2021-04-20 0:07 ` [PATCH 012/117] block: Convert SCSI and bsg code to " Bart Van Assche
2021-04-20 0:07 ` Bart Van Assche [this message]
2021-04-20 0:07 ` [PATCH 014/117] ch: Pass union scsi_status to driver_byte() Bart Van Assche
2021-04-20 0:07 ` [PATCH 015/117] sd: Convert to the scsi_status union Bart Van Assche
2021-04-20 0:07 ` [PATCH 016/117] sr: " Bart Van Assche
2021-04-20 0:07 ` [PATCH 017/117] st: " Bart Van Assche
2021-04-20 0:07 ` [PATCH 018/117] sg: " Bart Van Assche
2021-04-20 0:07 ` [PATCH 019/117] 3w*: " Bart Van Assche
2021-04-20 0:07 ` [PATCH 020/117] 53c700: " Bart Van Assche
2021-04-20 0:07 ` [PATCH 021/117] BusLogic: " Bart Van Assche
2021-04-20 0:07 ` [PATCH 022/117] NCR5380: " Bart Van Assche
2021-04-20 0:07 ` [PATCH 023/117] a100u2w: " Bart Van Assche
2021-04-20 0:07 ` [PATCH 024/117] aacraid: " Bart Van Assche
2021-04-20 0:07 ` [PATCH 025/117] acornscsi: Annotate fallthrough Bart Van Assche
2021-04-20 0:07 ` [PATCH 026/117] acornscsi: Convert to the scsi_status union Bart Van Assche
2021-04-20 0:07 ` [PATCH 027/117] advansys: " Bart Van Assche
2021-04-20 1:49 ` Matthew Wilcox
2021-04-20 2:27 ` Douglas Gilbert
2021-04-20 3:20 ` Bart Van Assche
2021-04-20 3:17 ` Bart Van Assche
2021-04-20 3:23 ` Matthew Wilcox
2021-04-20 15:01 ` Bart Van Assche
2021-04-20 0:07 ` [PATCH 028/117] aha*: " Bart Van Assche
2021-04-20 0:07 ` [PATCH 029/117] aic*: " Bart Van Assche
2021-04-20 0:07 ` [PATCH 030/117] arcmsr: " Bart Van Assche
2021-04-20 0:07 ` [PATCH 031/117] ata: " Bart Van Assche
2021-04-20 0:07 ` [PATCH 032/117] atp870u: " Bart Van Assche
2021-04-20 0:07 ` [PATCH 033/117] be2iscsi: " Bart Van Assche
2021-04-20 0:07 ` [PATCH 034/117] bfa: Use type int32_t to represent a signed integer Bart Van Assche
2021-04-20 0:07 ` [PATCH 035/117] bfa: Convert to the scsi_status union Bart Van Assche
2021-04-20 0:07 ` [PATCH 036/117] bnx2fc: " Bart Van Assche
2021-04-20 0:07 ` [PATCH 037/117] cdrom: " Bart Van Assche
2021-04-20 0:07 ` [PATCH 038/117] csiostor: " Bart Van Assche
2021-04-20 0:07 ` [PATCH 039/117] cxlflash: " Bart Van Assche
2021-04-20 0:07 ` [PATCH 040/117] dc395x: Use the set_{host,msg,status}_byte() functions Bart Van Assche
2021-04-20 0:07 ` [PATCH 041/117] dc395x: Convert to the scsi_status union Bart Van Assche
2021-04-20 0:07 ` [PATCH 042/117] dpt_i2o: " Bart Van Assche
2021-04-20 0:07 ` [PATCH 043/117] esas2r: " Bart Van Assche
2021-04-20 0:07 ` [PATCH 044/117] esp_scsi: " Bart Van Assche
2021-04-20 0:07 ` [PATCH 045/117] fas216: Fix two source code comments Bart Van Assche
2021-04-20 0:07 ` [PATCH 046/117] fas216: Convert to the scsi_status union Bart Van Assche
2021-04-20 0:07 ` [PATCH 047/117] fc: " Bart Van Assche
2021-04-20 0:07 ` [PATCH 048/117] fdomain: " Bart Van Assche
2021-04-20 0:07 ` [PATCH 049/117] firewire: sbp2: " Bart Van Assche
2021-04-20 0:07 ` [PATCH 050/117] fnic: " Bart Van Assche
2021-04-20 0:07 ` [PATCH 051/117] hpsa: " Bart Van Assche
2021-04-20 0:07 ` [PATCH 052/117] hptiop: " Bart Van Assche
2021-04-20 0:07 ` [PATCH 053/117] ib_srp: " Bart Van Assche
2021-04-20 0:07 ` [PATCH 054/117] ibmvfc: Fix the documentation of the return value of ibmvfc_host_chkready() Bart Van Assche
2021-04-20 0:07 ` [PATCH 055/117] ibmvfc: Convert to the scsi_status union Bart Van Assche
2021-04-20 0:07 ` [PATCH 056/117] ibmvscsi: " Bart Van Assche
2021-04-20 0:07 ` [PATCH 057/117] ide: " Bart Van Assche
2021-04-20 0:07 ` [PATCH 058/117] imm: " Bart Van Assche
2021-04-20 0:07 ` [PATCH 059/117] initio: " Bart Van Assche
2021-04-20 0:07 ` [PATCH 060/117] ipr: " Bart Van Assche
2021-04-20 0:07 ` [PATCH 061/117] ips: " Bart Van Assche
2021-04-20 0:07 ` [PATCH 062/117] iscsi: " Bart Van Assche
2021-05-06 18:54 ` Lee Duncan
2021-04-20 0:07 ` [PATCH 063/117] libfc: " Bart Van Assche
2021-04-20 0:07 ` [PATCH 064/117] sas: " Bart Van Assche
2021-04-20 0:07 ` [PATCH 065/117] lpfc: " Bart Van Assche
2021-04-21 20:26 ` James Smart
2021-04-20 0:07 ` [PATCH 066/117] mac53c94: " Bart Van Assche
2021-04-20 0:07 ` [PATCH 067/117] megaraid: " Bart Van Assche
2021-04-20 0:07 ` [PATCH 068/117] mesh: " Bart Van Assche
2021-04-20 0:07 ` [PATCH 069/117] message: fusion: " Bart Van Assche
2021-04-20 0:07 ` [PATCH 070/117] mpt3sas: " Bart Van Assche
2021-04-20 0:07 ` [PATCH 071/117] mvumi: " Bart Van Assche
2021-04-20 0:08 ` [PATCH 072/117] myrb: " Bart Van Assche
2021-04-20 0:08 ` [PATCH 073/117] myrs: " Bart Van Assche
2021-04-20 0:08 ` [PATCH 074/117] ncr53c8xx: " Bart Van Assche
2021-04-20 0:08 ` [PATCH 075/117] nfsd: " Bart Van Assche
2021-04-20 14:36 ` Chuck Lever III
2021-04-20 16:44 ` Bart Van Assche
2021-04-21 14:22 ` Chuck Lever III
2021-04-21 16:12 ` Bart Van Assche
2021-04-21 16:27 ` Chuck Lever III
2021-04-20 0:08 ` [PATCH 076/117] nsp32: " Bart Van Assche
2021-04-20 0:08 ` [PATCH 077/117] pcmcia: " Bart Van Assche
2021-04-20 0:08 ` [PATCH 078/117] pktcdvd: " Bart Van Assche
2021-04-20 0:08 ` [PATCH 079/117] pmcraid: " Bart Van Assche
2021-04-20 0:08 ` [PATCH 080/117] ppa: " Bart Van Assche
2021-04-20 0:08 ` [PATCH 081/117] ps3rom: " Bart Van Assche
2021-04-20 0:08 ` [PATCH 082/117] qedf: " Bart Van Assche
2021-04-20 0:08 ` [PATCH 083/117] qedi: " Bart Van Assche
2021-04-20 0:08 ` [PATCH 084/117] qla1280: " Bart Van Assche
2021-04-20 0:08 ` [PATCH 085/117] qla2xxx: " Bart Van Assche
2021-04-20 0:08 ` [PATCH 086/117] qla4xxx: " Bart Van Assche
2021-04-20 0:08 ` [PATCH 087/117] qlogicfas408: " Bart Van Assche
2021-04-20 0:08 ` [PATCH 088/117] qlogicpti: " Bart Van Assche
2021-04-20 0:08 ` [PATCH 089/117] s390/zfcp: " Bart Van Assche
2021-04-20 0:08 ` [PATCH 090/117] scsi_debug: " Bart Van Assche
2021-04-20 2:13 ` [PATCH 091/117] smartpqi: " Bart Van Assche
2021-04-20 2:13 ` [PATCH 092/117] snic: " Bart Van Assche
2021-04-20 2:13 ` [PATCH 093/117] staging: " Bart Van Assche
2021-04-20 7:47 ` Greg Kroah-Hartman
2021-04-20 15:02 ` Bart Van Assche
2021-04-20 15:06 ` Greg Kroah-Hartman
2021-04-20 2:13 ` [PATCH 094/117] stex: " Bart Van Assche
2021-04-20 2:13 ` [PATCH 095/117] storvsc: " Bart Van Assche
2021-04-20 19:39 ` Wei Liu
2021-04-20 2:13 ` [PATCH 096/117] sym53c8xx_2: " Bart Van Assche
2021-04-20 2:13 ` [PATCH 097/117] target: " Bart Van Assche
2021-04-20 2:13 ` [PATCH 098/117] ufs: Remove an unused structure member Bart Van Assche
2021-05-06 23:57 ` Can Guo
2021-04-20 2:13 ` [PATCH 099/117] ufs: Remove a local variable Bart Van Assche
2021-05-06 23:56 ` Can Guo
2021-04-20 2:13 ` [PATCH 100/117] ufs: Use enum sam_status where appropriate Bart Van Assche
2021-05-07 0:01 ` Can Guo
2021-05-07 0:01 ` Can Guo
2021-04-20 2:13 ` [PATCH 101/117] ufs: Remove an assignment from ufshcd_transfer_rsp_status() Bart Van Assche
2021-05-07 0:03 ` Can Guo
2021-04-20 2:13 ` [PATCH 102/117] ufs: Convert to the scsi_status union Bart Van Assche
2021-05-07 0:09 ` Can Guo
2021-05-07 3:35 ` Bart Van Assche
2021-05-07 4:48 ` Can Guo
2021-04-20 2:13 ` [PATCH 103/117] usb: " Bart Van Assche
2021-04-20 2:13 ` [PATCH 104/117] virtio-scsi: " Bart Van Assche
2021-04-20 2:13 ` [PATCH 105/117] vmw_pvscsi: " Bart Van Assche
2021-04-20 2:13 ` [PATCH 106/117] wd33c93: " Bart Van Assche
2021-04-20 2:13 ` [PATCH 107/117] wd719x: " Bart Van Assche
2021-04-20 2:13 ` [PATCH 108/117] xen-scsiback: Pass union status to the {status,msg,host,driver}_byte() macros Bart Van Assche
2021-04-20 2:13 ` [PATCH 109/117] xen-scsifront: Convert to the scsi_status union Bart Van Assche
2021-04-20 2:13 ` [PATCH 110/117] Finalize the switch from 'int' to 'union scsi_status' Bart Van Assche
2021-05-06 18:55 ` Lee Duncan
2021-05-07 0:24 ` Can Guo
2021-04-20 2:13 ` [PATCH 111/117] Use the scsi_status union more widely Bart Van Assche
2021-04-20 2:13 ` [PATCH 112/117] Change the return type of scsi_execute() into union scsi_status Bart Van Assche
2021-04-20 2:13 ` [PATCH 113/117] Change the return type of scsi_execute_req() " Bart Van Assche
2021-04-20 2:13 ` [PATCH 114/117] Change the return type of scsi_test_unit_ready() " Bart Van Assche
2021-04-20 2:14 ` [PATCH 115/117] Change the return types of scsi_mode_sense() and sd_do_mode_sense() Bart Van Assche
2021-04-20 2:14 ` [PATCH 116/117] Change the return type of scsi_mode_select() into union scsi_status Bart Van Assche
2021-04-20 2:14 ` [PATCH 117/117] Change the return type of ioctl_internal_command() " Bart Van Assche
2021-04-20 6:04 ` [PATCH 000/117] Make better use of static type checking Hannes Reinecke
2021-04-20 16:12 ` Bart Van Assche
2021-04-20 17:11 ` Hannes Reinecke
2021-04-20 21:10 ` Bart Van Assche
2021-04-20 17:19 ` Douglas Gilbert
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=20210420000845.25873-14-bvanassche@acm.org \
--to=bvanassche@acm.org \
--cc=hare@suse.de \
--cc=hch@lst.de \
--cc=jejb@linux.vnet.ibm.com \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.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