diff --git a/scst/src/scst_lib.c b/scst/src/scst_lib.c index ffd41a7a4..14c7558ab 100644 --- a/scst/src/scst_lib.c +++ b/scst/src/scst_lib.c @@ -2985,6 +2985,27 @@ out: } EXPORT_SYMBOL(scst_cmd_set_write_not_received_data_len); +void scst_cmd_set_write_no_data_received(struct scst_cmd *cmd) +{ + int w; + + TRACE_ENTRY(); + + EXTRACHECKS_BUG_ON(cmd->expected_values_set && + ((cmd->expected_data_direction & SCST_DATA_WRITE) == 0)); + + if ((cmd->expected_data_direction & SCST_DATA_READ) && + (cmd->expected_data_direction & SCST_DATA_WRITE)) + w = cmd->expected_out_transfer_len; + else + w = cmd->expected_transfer_len; + + scst_cmd_set_write_not_received_data_len(cmd, w); + + TRACE_EXIT(); + return; +} + /** * __scst_get_resid() - returns residuals for cmd * diff --git a/scst/src/scst_priv.h b/scst/src/scst_priv.h index dcac6301d..358492276 100644 --- a/scst/src/scst_priv.h +++ b/scst/src/scst_priv.h @@ -305,6 +305,8 @@ int scst_init_thread(void *arg); int scst_tm_thread(void *arg); int scst_global_mgmt_thread(void *arg); +void scst_cmd_set_write_no_data_received(struct scst_cmd *cmd); + void scst_zero_write_rest(struct scst_cmd *cmd); void scst_limit_sg_write_len(struct scst_cmd *cmd); void scst_adjust_resp_data_len(struct scst_cmd *cmd); diff --git a/scst/src/scst_targ.c b/scst/src/scst_targ.c index d4d123954..7a2c2fcb7 100644 --- a/scst/src/scst_targ.c +++ b/scst/src/scst_targ.c @@ -1521,8 +1521,7 @@ void scst_rx_data(struct scst_cmd *cmd, int status, 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_cmd_set_write_no_data_received(cmd); scst_set_cmd_abnormal_done_state(cmd); pref_context = SCST_CONTEXT_THREAD; break; @@ -1532,8 +1531,7 @@ void scst_rx_data(struct scst_cmd *cmd, int status, /* 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_cmd_set_write_no_data_received(cmd); scst_set_cmd_error(cmd, SCST_LOAD_SENSE(scst_sense_hardw_error)); scst_set_cmd_abnormal_done_state(cmd); @@ -1544,8 +1542,7 @@ void scst_rx_data(struct scst_cmd *cmd, int status, 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_cmd_set_write_no_data_received(cmd); scst_set_cmd_abnormal_done_state(cmd); pref_context = SCST_CONTEXT_THREAD; break;