diff --git a/scst/include/scst.h b/scst/include/scst.h index b1c273bad..655e155e8 100644 --- a/scst/include/scst.h +++ b/scst/include/scst.h @@ -2028,6 +2028,9 @@ struct scst_cmd { /* Set if cmd was pre-alloced by target driver */ unsigned int pre_alloced:1; + /* Set if scst_cmd_set_write_not_received_data_len() was called */ + unsigned int write_not_received_set:1; + /**************************************************************/ /* cmd's async flags */ diff --git a/scst/src/scst_lib.c b/scst/src/scst_lib.c index e27a5d9ce..ffd41a7a4 100644 --- a/scst/src/scst_lib.c +++ b/scst/src/scst_lib.c @@ -2943,6 +2943,8 @@ void scst_cmd_set_write_not_received_data_len(struct scst_cmd *cmd, { TRACE_ENTRY(); + cmd->write_not_received_set = 1; + if (!cmd->expected_values_set) { /* * No expected values set, so no residuals processing. diff --git a/scst/src/scst_targ.c b/scst/src/scst_targ.c index f321a099a..d4d123954 100644 --- a/scst/src/scst_targ.c +++ b/scst/src/scst_targ.c @@ -1520,6 +1520,9 @@ void scst_rx_data(struct scst_cmd *cmd, int status, break; case SCST_RX_STATUS_ERROR_SENSE_SET: + if (!cmd->write_not_received_set) + scst_cmd_set_write_not_received_data_len(cmd, + cmd->expected_transfer_len); scst_set_cmd_abnormal_done_state(cmd); pref_context = SCST_CONTEXT_THREAD; break; @@ -1528,6 +1531,9 @@ void scst_rx_data(struct scst_cmd *cmd, int status, set_bit(SCST_CMD_NO_RESP, &cmd->cmd_flags); /* go through */ case SCST_RX_STATUS_ERROR: + if (!cmd->write_not_received_set) + scst_cmd_set_write_not_received_data_len(cmd, + cmd->expected_transfer_len); scst_set_cmd_error(cmd, SCST_LOAD_SENSE(scst_sense_hardw_error)); scst_set_cmd_abnormal_done_state(cmd); @@ -1537,6 +1543,9 @@ void scst_rx_data(struct scst_cmd *cmd, int status, default: PRINT_ERROR("scst_rx_data() received unknown status %x", status); + if (!cmd->write_not_received_set) + scst_cmd_set_write_not_received_data_len(cmd, + cmd->expected_transfer_len); scst_set_cmd_abnormal_done_state(cmd); pref_context = SCST_CONTEXT_THREAD; break;