]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.11.2/target-fix-compare_and_write_callback-handling-for-non-good-status.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.11.2 / target-fix-compare_and_write_callback-handling-for-non-good-status.patch
CommitLineData
b0c1a8bd
GKH
1From a71a5dc7f833943998e97ca8fa6a4c708a0ed1a9 Mon Sep 17 00:00:00 2001
2From: Nicholas Bellinger <nab@linux-iscsi.org>
3Date: Tue, 11 Apr 2017 16:24:16 -0700
4Subject: target: Fix compare_and_write_callback handling for non GOOD status
5
6From: Nicholas Bellinger <nab@linux-iscsi.org>
7
8commit a71a5dc7f833943998e97ca8fa6a4c708a0ed1a9 upstream.
9
10Following the bugfix for handling non SAM_STAT_GOOD COMPARE_AND_WRITE
11status during COMMIT phase in commit 9b2792c3da1, the same bug exists
12for the READ phase as well.
13
14This would manifest first as a lost SCSI response, and eventual
15hung task during fabric driver logout or re-login, as existing
16shutdown logic waited for the COMPARE_AND_WRITE se_cmd->cmd_kref
17to reach zero.
18
19To address this bug, compare_and_write_callback() has been changed
20to set post_ret = 1 and return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE
21as necessary to signal failure status.
22
23Reported-by: Bill Borsari <wgb@datera.io>
24Cc: Bill Borsari <wgb@datera.io>
25Tested-by: Gary Guo <ghg@datera.io>
26Cc: Gary Guo <ghg@datera.io>
27Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
28Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
29
30---
31 drivers/target/target_core_sbc.c | 5 ++++-
32 1 file changed, 4 insertions(+), 1 deletion(-)
33
34--- a/drivers/target/target_core_sbc.c
35+++ b/drivers/target/target_core_sbc.c
36@@ -507,8 +507,11 @@ static sense_reason_t compare_and_write_
37 * been failed with a non-zero SCSI status.
38 */
39 if (cmd->scsi_status) {
40- pr_err("compare_and_write_callback: non zero scsi_status:"
41+ pr_debug("compare_and_write_callback: non zero scsi_status:"
42 " 0x%02x\n", cmd->scsi_status);
43+ *post_ret = 1;
44+ if (cmd->scsi_status == SAM_STAT_CHECK_CONDITION)
45+ ret = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
46 goto out;
47 }
48