From 26b9e5eaada43bf09129533df4d78270ae669403 Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Thu, 5 Dec 2013 04:05:49 +0000 Subject: [PATCH] Fix write resuduals handling on data receive error By default data receive error it should be assumed that no data received, not that all data received as it is currently git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@5138 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/include/scst.h | 3 +++ scst/src/scst_lib.c | 2 ++ scst/src/scst_targ.c | 9 +++++++++ 3 files changed, 14 insertions(+) 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;