summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicholas Bellinger <nab@linux-iscsi.org>2017-04-11 16:24:16 -0700
committerSasha Levin <alexander.levin@verizon.com>2017-05-17 15:08:25 -0400
commit3aa99b61c0995761281afb192e36cab9be549b62 (patch)
tree3b6ca2d498071e4b58881c13c3fbd72465139bae
parent0c5623052d48eae8e1308bb882adcc1115b4cee7 (diff)
downloadlinux-stable-3aa99b61c0995761281afb192e36cab9be549b62.tar.gz
linux-stable-3aa99b61c0995761281afb192e36cab9be549b62.tar.bz2
linux-stable-3aa99b61c0995761281afb192e36cab9be549b62.zip
target: Fix compare_and_write_callback handling for non GOOD status
[ Upstream commit a71a5dc7f833943998e97ca8fa6a4c708a0ed1a9 ] Following the bugfix for handling non SAM_STAT_GOOD COMPARE_AND_WRITE status during COMMIT phase in commit 9b2792c3da1, the same bug exists for the READ phase as well. This would manifest first as a lost SCSI response, and eventual hung task during fabric driver logout or re-login, as existing shutdown logic waited for the COMPARE_AND_WRITE se_cmd->cmd_kref to reach zero. To address this bug, compare_and_write_callback() has been changed to set post_ret = 1 and return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE as necessary to signal failure status. Reported-by: Bill Borsari <wgb@datera.io> Cc: Bill Borsari <wgb@datera.io> Tested-by: Gary Guo <ghg@datera.io> Cc: Gary Guo <ghg@datera.io> Cc: <stable@vger.kernel.org> # v4.1+ Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org> Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
-rw-r--r--drivers/target/target_core_sbc.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/target/target_core_sbc.c b/drivers/target/target_core_sbc.c
index 8e90bcf02a9d..8bf7a06c25a9 100644
--- a/drivers/target/target_core_sbc.c
+++ b/drivers/target/target_core_sbc.c
@@ -446,8 +446,11 @@ static sense_reason_t compare_and_write_callback(struct se_cmd *cmd, bool succes
* been failed with a non-zero SCSI status.
*/
if (cmd->scsi_status) {
- pr_err("compare_and_write_callback: non zero scsi_status:"
+ pr_debug("compare_and_write_callback: non zero scsi_status:"
" 0x%02x\n", cmd->scsi_status);
+ *post_ret = 1;
+ if (cmd->scsi_status == SAM_STAT_CHECK_CONDITION)
+ ret = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
goto out;
}