diff --git a/scst/include/scst.h b/scst/include/scst.h index ce6abf9d9..a3286d5a9 100644 --- a/scst/include/scst.h +++ b/scst/include/scst.h @@ -1203,6 +1203,10 @@ struct scst_cmd { */ int resp_data_len; + /* + * The status fields in case of errors must be set using + * scst_set_cmd_error_status()! + */ uint8_t status; /* status byte from target device */ uint8_t msg_status; /* return status from host adapter itself */ uint8_t host_status; /* set by low-level driver to indicate status */ diff --git a/scst/src/scst_lib.c b/scst/src/scst_lib.c index 908fa0611..523f574ba 100644 --- a/scst/src/scst_lib.c +++ b/scst/src/scst_lib.c @@ -1375,8 +1375,9 @@ struct scst_cmd *scst_alloc_cmd(gfp_t gfp_mask) cmd->data_len = -1; cmd->is_send_status = 1; cmd->resp_data_len = -1; - cmd->dbl_ua_orig_resp_data_len = -1; + cmd->dbl_ua_orig_data_direction = SCST_DATA_UNKNOWN; + cmd->dbl_ua_orig_resp_data_len = -1; out: TRACE_EXIT(); diff --git a/scst/src/scst_targ.c b/scst/src/scst_targ.c index 72f34e1bc..6e375680d 100644 --- a/scst/src/scst_targ.c +++ b/scst/src/scst_targ.c @@ -1104,9 +1104,14 @@ static void scst_do_cmd_done(struct scst_cmd *cmd, int result, scst_set_resp_data_len(cmd, cmd->resp_data_len - resid); } - if (cmd->status == SAM_STAT_CHECK_CONDITION) + if (unlikely(cmd->status == SAM_STAT_CHECK_CONDITION)) { + /* We might have double reset UA here */ + cmd->dbl_ua_orig_resp_data_len = cmd->resp_data_len; + cmd->dbl_ua_orig_data_direction = cmd->data_direction; + scst_alloc_set_sense(cmd, scst_is_context_gfp_atomic(), rq_sense, rq_sense_len); + } TRACE(TRACE_SCSI, "result=%x, cmd->status=%x, resid=%d, " "cmd->msg_status=%x, cmd->host_status=%x, "