From 6e31fd830613a21d2cd7b4d05464c121d4fa6e12 Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Thu, 4 Jul 2013 02:46:49 +0000 Subject: [PATCH] Relax and cleanup HARDWARE ERROR sense usage HARDWARE ERROR sense is very strong considered be "internal failure", so might lead to serios initiator side issues up to disconnect from device. In many cases WRITE or READ ERROR sense can be used instead. All remaining usages must be logged. git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@4911 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- qla2x00t/qla2x00-target/qla2x00t.c | 16 +++++++++++----- scst/include/scst.h | 2 +- scst/src/dev_handlers/scst_vdisk.c | 4 ++-- scst/src/scst_pres.c | 16 ++++++++-------- scst/src/scst_targ.c | 7 +++++-- srpt/src/ib_srpt.c | 4 +++- 6 files changed, 30 insertions(+), 19 deletions(-) diff --git a/qla2x00t/qla2x00-target/qla2x00t.c b/qla2x00t/qla2x00-target/qla2x00t.c index 7660508b6..09d3e0042 100644 --- a/qla2x00t/qla2x00-target/qla2x00t.c +++ b/qla2x00t/qla2x00-target/qla2x00t.c @@ -3539,9 +3539,11 @@ static void q2t_do_ctio_completion(scsi_qla_host_t *ha, uint32_t handle, cmd->state = Q2T_STATE_DATA_IN; - if (unlikely(status != CTIO_SUCCESS)) - rx_status = SCST_RX_STATUS_ERROR; - else + if (unlikely(status != CTIO_SUCCESS)) { + scst_set_cmd_error(&cmd->scst_cmd, + SCST_LOAD_SENSE(scst_sense_write_error)); + rx_status = SCST_RX_STATUS_ERROR_SENSE_SET; + } else cmd->write_data_transferred = 1; TRACE_DBG("Data received, context %x, rx_status %d", @@ -4375,7 +4377,9 @@ out_reject: NOTIFY_ACK_SRR_FLAGS_REJECT_EXPL_NO_EXPL); if (cmd->state == Q2T_STATE_NEED_DATA) { cmd->state = Q2T_STATE_DATA_IN; - scst_rx_data(&cmd->scst_cmd, SCST_RX_STATUS_ERROR, + scst_set_cmd_error(&cmd->scst_cmd, + SCST_LOAD_SENSE(scst_sense_write_error)); + scst_rx_data(&cmd->scst_cmd, SCST_RX_STATUS_ERROR_SENSE_SET, SCST_CONTEXT_THREAD); } else q24_send_term_exchange(ha, cmd, &cmd->atio.atio7, 1); @@ -4464,7 +4468,9 @@ out_reject: NOTIFY_ACK_SRR_FLAGS_REJECT_EXPL_NO_EXPL); if (cmd->state == Q2T_STATE_NEED_DATA) { cmd->state = Q2T_STATE_DATA_IN; - scst_rx_data(&cmd->scst_cmd, SCST_RX_STATUS_ERROR, + scst_set_cmd_error(&cmd->scst_cmd, + SCST_LOAD_SENSE(scst_sense_write_error)); + scst_rx_data(&cmd->scst_cmd, SCST_RX_STATUS_ERROR_SENSE_SET, SCST_CONTEXT_THREAD); } else q2x_send_term_exchange(ha, cmd, &cmd->atio.atio2x, 1); diff --git a/scst/include/scst.h b/scst/include/scst.h index e723f66fb..70e787f5b 100644 --- a/scst/include/scst.h +++ b/scst/include/scst.h @@ -448,7 +448,7 @@ enum scst_exec_context { /* * Fatal error, if returned by xmit_response() the cmd will * be destroyed, if by any other function, xmit_response() - * will be called with HARDWARE ERROR sense data + * will be called with READ or WRITE FAILED sense data */ #define SCST_TGT_RES_FATAL_ERROR -3 diff --git a/scst/src/dev_handlers/scst_vdisk.c b/scst/src/dev_handlers/scst_vdisk.c index 0bc294631..c66f7791f 100644 --- a/scst/src/dev_handlers/scst_vdisk.c +++ b/scst/src/dev_handlers/scst_vdisk.c @@ -4084,7 +4084,7 @@ static enum compl_status_e fileio_exec_verify(struct vdisk_cmd_params *p) (long long unsigned int)err, (long long unsigned int)loff); scst_set_cmd_error(cmd, - SCST_LOAD_SENSE(scst_sense_hardw_error)); + SCST_LOAD_SENSE(scst_sense_read_error)); goto out_set_fs; } } @@ -4093,7 +4093,7 @@ static enum compl_status_e fileio_exec_verify(struct vdisk_cmd_params *p) if (mem_verify == NULL) { PRINT_ERROR("Unable to allocate memory %d for verify", LEN_MEM); - scst_set_cmd_error(cmd, SCST_LOAD_SENSE(scst_sense_hardw_error)); + scst_set_busy(cmd); goto out_set_fs; } diff --git a/scst/src/scst_pres.c b/scst/src/scst_pres.c index 37de5a318..8c5c09a58 100644 --- a/scst/src/scst_pres.c +++ b/scst/src/scst_pres.c @@ -935,14 +935,14 @@ out: "(target %s, initiator %s, device %s)", tgt_dev->sess->tgt->tgt_name, tgt_dev->sess->initiator_name, dev->virt_name); -#if 0 /* - * Looks like it's safer to return SUCCESS and expect operator's - * intervention to be able to save the PR's state next time, than - * to return HARDWARE ERROR and screw up all the interaction with - * the affected initiator. - */ - if (cmd != NULL) - scst_set_cmd_error(cmd, SCST_LOAD_SENSE(scst_sense_hardw_error)); +#if 0 /* + * Looks like it's safer to return SUCCESS and expect operator's + * intervention to be able to save the PR's state next time, than + * to return HARDWARE ERROR and screw up all the interaction with + * the affected initiator. + */ + if (cmd != NULL) + scst_set_cmd_error(cmd, SCST_LOAD_SENSE(scst_sense_hardw_error)); #endif } diff --git a/scst/src/scst_targ.c b/scst/src/scst_targ.c index 2ac8fff51..7627c2579 100644 --- a/scst/src/scst_targ.c +++ b/scst/src/scst_targ.c @@ -1171,7 +1171,10 @@ out_no_space: goto out; out_error: - scst_set_cmd_error(cmd, SCST_LOAD_SENSE(scst_sense_hardw_error)); + if (cmd->data_direction & SCST_DATA_WRITE) + scst_set_cmd_error(cmd, SCST_LOAD_SENSE(scst_sense_write_error)); + else + scst_set_cmd_error(cmd, SCST_LOAD_SENSE(scst_sense_read_error)); scst_set_cmd_abnormal_done_state(cmd); res = SCST_CMD_STATE_RES_CONT_SAME; goto out; @@ -1400,7 +1403,7 @@ out_error_rc: PRINT_ERROR("Target driver %s rdy_to_xfer() returned invalid " "value %d", tgtt->name, rc); } - scst_set_cmd_error(cmd, SCST_LOAD_SENSE(scst_sense_hardw_error)); + scst_set_cmd_error(cmd, SCST_LOAD_SENSE(scst_sense_write_error)); out_dev_done: scst_set_cmd_abnormal_done_state(cmd); diff --git a/srpt/src/ib_srpt.c b/srpt/src/ib_srpt.c index 451825f46..f04f04f5a 100644 --- a/srpt/src/ib_srpt.c +++ b/srpt/src/ib_srpt.c @@ -1401,7 +1401,9 @@ static void srpt_abort_cmd(struct srpt_send_ioctx *ioctx, break; case SRPT_STATE_NEED_DATA: /* SCST_DATA_WRITE - RDMA read error or RDMA read timeout. */ - scst_rx_data(scmnd, SCST_RX_STATUS_ERROR, context); + scst_set_cmd_error(scmnd, + SCST_LOAD_SENSE(scst_sense_write_error)); + scst_rx_data(scmnd, SCST_RX_STATUS_ERROR_SENSE_SET, context); break; case SRPT_STATE_CMD_RSP_SENT: /*