[Devel] [PATCH RHEL7 COMMIT] ms/qla2xxx/target: Add TFO->abort_task for aborted task resources release

Konstantin Khorenko khorenko at virtuozzo.com
Fri Oct 20 14:57:31 MSK 2017


The commit is pushed to "branch-rh7-3.10.0-693.1.1.vz7.37.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-693.1.1.vz7.37.17
------>
commit f39515cc246f1576f51e3e7a5072232ac880a7b2
Author: Kirill Tkhai <ktkhai at virtuozzo.com>
Date:   Fri Oct 20 14:56:24 2017 +0300

    ms/qla2xxx/target: Add TFO->abort_task for aborted task resources release
    
    The patch is based on ms commits:
    b79fafa ("target: make queue_tm_rsp() return void")
    e70beee ("target: Pass in transport supported PI at session initialization")
    
    131e6ab ("target: Add TFO->abort_task for aborted task resources release")
    
        Now that TASK_ABORTED status is not generated for all cases by
        TMR ABORT_TASK + LUN_RESET, a new TFO->abort_task() caller is
        necessary in order to give fabric drivers a chance to unmap
        hardware / software resources before the se_cmd descriptor is
        released via the normal TFO->release_cmd() codepath.
    
        This patch adds TFO->aborted_task() in core_tmr_abort_task()
        in place of the original transport_send_task_abort(), and
        also updates all fabric drivers to implement this caller.
    
        The fabric drivers that include changes to perform cleanup
        via ->aborted_task() are:
    
          - iscsi-target
          - iser-target
          - srpt
          - tcm_qla2xxx
    
        The fabric drivers that currently set ->aborted_task() to
        NOPs are:
    
          - loopback
          - tcm_fc
          - usb-gadget
          - sbp-target
          - vhost-scsi
    
        For the latter five, there appears to be no additional cleanup
        required before invoking TFO->release_cmd() to release the
        se_cmd descriptor.
    
        v2 changes:
          - Move ->aborted_task() call into transport_cmd_finish_abort (Alex)
    
        Cc: Alex Leung <amleung21 at yahoo.com>
        Cc: Mark Rustad <mark.d.rustad at intel.com>
        Cc: Roland Dreier <roland at kernel.org>
        Cc: Vu Pham <vu at mellanox.com>
        Cc: Chris Boot <bootc at bootc.net>
        Cc: Sebastian Andrzej Siewior <bigeasy at linutronix.de>
        Cc: Michael S. Tsirkin <mst at redhat.com>
        Cc: Giridhar Malavali <giridhar.malavali at qlogic.com>
        Cc: Saurav Kashyap <saurav.kashyap at qlogic.com>
        Cc: Quinn Tran <quinn.tran at qlogic.com>
        Cc: Sagi Grimberg <sagig at mellanox.com>
        Cc: Or Gerlitz <ogerlitz at mellanox.com>
        Signed-off-by: Nicholas Bellinger <nab at linux-iscsi.org>
    
    https://jira.sw.ru/browse/PSBM-73161
    
    Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 drivers/scsi/qla2xxx/tcm_qla2xxx.c | 22 +++++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.c b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
index 3186a79..d69020f 100644
--- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c
+++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
@@ -53,6 +53,8 @@
 #include "qla_target.h"
 #include "tcm_qla2xxx.h"
 
+#define TF_CIT_TMPL(tf) (&(tf)->tf_cit_tmpl)
+
 struct workqueue_struct *tcm_qla2xxx_free_wq;
 struct workqueue_struct *tcm_qla2xxx_cmd_wq;
 
@@ -709,7 +711,7 @@ static int tcm_qla2xxx_queue_status(struct se_cmd *se_cmd)
 	return qlt_xmit_response(cmd, xmit_type, se_cmd->scsi_status);
 }
 
-static int tcm_qla2xxx_queue_tm_rsp(struct se_cmd *se_cmd)
+static void tcm_qla2xxx_queue_tm_rsp(struct se_cmd *se_cmd)
 {
 	struct se_tmr_req *se_tmr = se_cmd->se_tmr_req;
 	struct qla_tgt_mgmt_cmd *mcmd = container_of(se_cmd,
@@ -741,8 +743,20 @@ static int tcm_qla2xxx_queue_tm_rsp(struct se_cmd *se_cmd)
 	 * CTIO response packet.
 	 */
 	qlt_xmit_tm_rsp(mcmd);
+}
 
-	return 0;
+static void tcm_qla2xxx_aborted_task(struct se_cmd *se_cmd)
+{
+	struct qla_tgt_cmd *cmd = container_of(se_cmd,
+				struct qla_tgt_cmd, se_cmd);
+	struct scsi_qla_host *vha = cmd->vha;
+	struct qla_hw_data *ha = vha->hw;
+
+	if (!cmd->sg_mapped)
+		return;
+
+	pci_unmap_sg(ha->pdev, cmd->sg, cmd->sg_cnt, cmd->dma_data_direction);
+	cmd->sg_mapped = 0;
 }
 
 /* Local pointer to allocated TCM configfs fabric module */
@@ -1424,7 +1438,7 @@ static int tcm_qla2xxx_check_initiator_node_acl(
 	}
 	se_tpg = &tpg->se_tpg;
 
-	se_sess = transport_init_session();
+	se_sess = transport_init_session(TARGET_PROT_NORMAL);
 	if (IS_ERR(se_sess)) {
 		pr_err("Unable to initialize struct se_session\n");
 		return PTR_ERR(se_sess);
@@ -1761,6 +1775,7 @@ static struct target_core_fabric_ops tcm_qla2xxx_ops = {
 	.queue_data_in			= tcm_qla2xxx_queue_data_in,
 	.queue_status			= tcm_qla2xxx_queue_status,
 	.queue_tm_rsp			= tcm_qla2xxx_queue_tm_rsp,
+	.aborted_task			= tcm_qla2xxx_aborted_task,
 	/*
 	 * Setup function pointers for generic logic in
 	 * target_core_fabric_configfs.c
@@ -1808,6 +1823,7 @@ static struct target_core_fabric_ops tcm_qla2xxx_npiv_ops = {
 	.queue_data_in			= tcm_qla2xxx_queue_data_in,
 	.queue_status			= tcm_qla2xxx_queue_status,
 	.queue_tm_rsp			= tcm_qla2xxx_queue_tm_rsp,
+	.aborted_task			= tcm_qla2xxx_aborted_task,
 	/*
 	 * Setup function pointers for generic logic in
 	 * target_core_fabric_configfs.c


More information about the Devel mailing list