[PATCH] tcm_qla2xxx: Fix tcm_qla2xxx_new_cmd_map failure cases

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Nicholas Bellinger <nab@xxxxxxxxxxxxxxx>

This patch fixes a bug in handling tcm_qla2xxx_new_cmd_map() failure
cases where it was incorrectly returning zero and causing TCM to still
call transport_generic_new_cmd() and eventually hit an BUG() in
transport_map_control_cmd_to_task()

It updates tcm_qla2xxx_new_cmd_map() to follow TCM v4.1 and use -ENOMEM
and -EINVAL return codes from transport_generic_allocate_tasks() to determine
the initial failure, and also converts to use PYX_TRANSPORT_* return codes
instead of direct calls to transport_send_check_condition_and_sense() to
follow what tcm_loop is doing to handle failures during TFO->new_cmd_map().

Reported-by: Roland Dreier <roland@xxxxxxxxxxxxxxx>
Signed-off-by: Nicholas Bellinger <nab@xxxxxxxxxxxxxxx>
---
 drivers/target/tcm_qla2xxx/tcm_qla2xxx_fabric.c |   23 +++++++++--------------
 1 files changed, 9 insertions(+), 14 deletions(-)

diff --git a/drivers/target/tcm_qla2xxx/tcm_qla2xxx_fabric.c b/drivers/target/tcm_qla2xxx/tcm_qla2xxx_fabric.c
index e2f424a..1271d4e 100644
--- a/drivers/target/tcm_qla2xxx/tcm_qla2xxx_fabric.c
+++ b/drivers/target/tcm_qla2xxx/tcm_qla2xxx_fabric.c
@@ -641,26 +641,21 @@ int tcm_qla2xxx_new_cmd_map(struct se_cmd *se_cmd)
 	 * Allocate the necessary tasks to complete the received CDB+data
 	 */
 	ret = transport_generic_allocate_tasks(se_cmd, cdb);
-	if (ret == -1) {
+	if (ret == -ENOMEM) {
 		/* Out of Resources */
-		transport_send_check_condition_and_sense(se_cmd,
-				TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE, 0);
-		return 0;
-	} else if (ret == -2) {
+		return PYX_TRANSPORT_OUT_OF_MEMORY_RESOURCES;
+	} else if (ret == -EINVAL) {
 		/*
 		 * Handle case for SAM_STAT_RESERVATION_CONFLICT
 		 */
-		if (se_cmd->se_cmd_flags & SCF_SCSI_RESERVATION_CONFLICT) {
-			tcm_qla2xxx_queue_status(se_cmd);
-			return 0;
-		}
+		if (se_cmd->se_cmd_flags & SCF_SCSI_RESERVATION_CONFLICT)
+			return PYX_TRANSPORT_RESERVATION_CONFLICT;
 		/*
-		 * Otherwise, return SAM_STAT_CHECK_CONDITION and return
-		 * sense data.
+		 * Otherwise, se_cmd->scsi_sense_reason will be set, so
+		 * return PYX_TRANSPORT_USE_SENSE_REASON to signal
+		 * transport_generic_request_failure()
 		 */
-		transport_send_check_condition_and_sense(se_cmd,
-				se_cmd->scsi_sense_reason, 0);
-		return 0;
+		return PYX_TRANSPORT_USE_SENSE_REASON;
 	}
 	/*
 	 * drivers/target/target_core_transport.c:transport_processing_thread()
-- 
1.7.2.5

--
To unsubscribe from this list: send the line "unsubscribe target-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux SCSI]     [Kernel Newbies]     [Linux SCSI Target Infrastructure]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Device Mapper]

  Powered by Linux