From patchwork Fri Feb 10 01:28:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 9565767 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DB8AB60572 for ; Fri, 10 Feb 2017 01:29:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CCFEF28532 for ; Fri, 10 Feb 2017 01:29:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C1EFE28548; Fri, 10 Feb 2017 01:29:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 35BF72853B for ; Fri, 10 Feb 2017 01:29:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751371AbdBJB3J (ORCPT ); Thu, 9 Feb 2017 20:29:09 -0500 Received: from esa1.hgst.iphmx.com ([68.232.141.245]:36294 "EHLO esa1.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751208AbdBJB3I (ORCPT ); Thu, 9 Feb 2017 20:29:08 -0500 X-IronPort-AV: E=Sophos;i="5.33,348,1477929600"; d="scan'208";a="82349459" Received: from unknown (HELO milsmgep15.sandisk.com) ([63.163.107.21]) by ob1.hgst.iphmx.com with ESMTP; 10 Feb 2017 09:28:59 +0800 Received: from MILHUBIP04.sdcorp.global.sandisk.com (Unknown_Domain [10.201.67.162]) (using TLS with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by (Symantec Messaging Gateway) with SMTP id 3E.87.57638.A571D985; Thu, 9 Feb 2017 17:28:59 -0800 (PST) Received: from milsmgip11.sandisk.com (10.177.9.6) by MILHUBIP04.sdcorp.global.sandisk.com (10.177.9.97) with Microsoft SMTP Server id 14.3.319.2; Thu, 9 Feb 2017 17:28:55 -0800 X-AuditID: 0ac94369-26dee9800001e126-f8-589d175aeca9 Received: from exp-402881.sdcorp.global.sandisk.com ( [10.177.9.6]) by (Symantec Messaging Gateway) with SMTP id C1.9F.11415.7571D985; Thu, 9 Feb 2017 17:28:55 -0800 (PST) From: Bart Van Assche To: "Nicholas A . Bellinger" CC: , Bart Van Assche , Himanshu Madhani , Giridhar Malavali Subject: [PATCH v5 02/22] tcm_qla2xxx: Let the target core look up the LUN of the aborted cmd Date: Thu, 9 Feb 2017 17:28:32 -0800 Message-ID: <20170210012852.15735-3-bart.vanassche@sandisk.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170210012852.15735-1-bart.vanassche@sandisk.com> References: <20170210012852.15735-1-bart.vanassche@sandisk.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrELMWRmVeSWpSXmKPExsXCddJ5kW60+NwIg4vvmSz2PDjHZnFhTzej RdvqM4wWrUvfMjmweMz4vYjF4/72I0wenzfJBTBHcdmkpOZklqUW6dslcGWsuDWNuWCLfsXn /8tYGxhnqXcxcnJICJhILJn3mrGLkYtDSGApk8TjC6tZIJytjBLz/j5mg6lqb37IBpHYyCgx e888ZpAEm4CRxLf3M1lAbBEge3XPMiaQImaBbYwSD3YdBusWFoiVOP2nlRXEZhFQkVh++xo7 iM0rYC8x4fEcFogN8hK72i6C1XAKOEi8mn0dyOYA2mYvsWOXAchMCYF/LBIPTs2B6hWUODnz CVgvs4CExMEXL8AOEhJQlzi5ZD7TBEahWUjKZiEpW8DItIpRLDczpzg3PbXA0FSvODEvJbM4 Wy85P3cTIySkM3cw3n3ifYhRgINRiYf3Rc2cCCHWxLLiytxDjBIczEoivPf55kYI8aYkVlal FuXHF5XmpBYfYpTmYFES5z0nMzVCSCA9sSQ1OzW1ILUIJsvEwSnVwCii8PU9/+xuhmknpz4T 9r4Q0/U1NPbuprXBHzYWCp9oNJ6n7rZHaCqry5J3UrXHLKZIJZjvN9l93trspvAcxr+chmkS n64unPjXtulu0WapT437IiJfSwqxOuzieuv8XPTn7si0Ix6TtXbuvN2vn1K5nee0xrOa9OP5 /6Zs6xP5enzeHAbJuBwlluKMREMt5qLiRAArG5RuZQIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprPJMWRmVeSWpSXmKPExsXCtZGTTTdcfG6EQdtxLouDP9sYLfY8OMdm cWFPN6NF2+ozjBatS98yObB6zPi9iMXj/vYjTB7T1pxn8vi8SS6AJYrLJiU1J7MstUjfLoEr Y8WtacwFW/QrPv9fxtrAOEu9i5GTQ0LARKK9+SFbFyMXh5DAekaJGYuesIEk2ASMJL69n8kC YosA2at7ljGB2MwC2xglbjyxArGFBWIlTv9pZe1i5OBgEVCV+NijBRLmFbCXaH/9nRlivrzE rraLrCA2p4CDxKvZ18HKhYBqduwymMDIvYCRYRWjWG5mTnFuemaBoaFecWJeSmZxtl5yfu4m RkgQRO5gfDrR/BAjEwenVAPj+didCwo9J6fzJJq9VrldXiS4sdL3teGZM+UGRV87f9zderP7 vbBVi83+hvb72qZrHSeuCsnc6DBXeX3aRGtO303L9i44vHmfyKybRRIcK/necb3iu7zEi8Np yp+E8MSNXmZnFAS36Nala578NENctbyj1dNdX2T7XJ+yekPxOg6TN193yU1UYinOSDTUYi4q TgQA3W9mObIBAAA= MIME-Version: 1.0 Sender: target-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: target-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Use the new flag TARGET_SCF_IGNORE_TMR_LUN instead of letting the qla2xxx target driver look up the LUN of the command that has to be aborted. Signed-off-by: Bart Van Assche Reviewed-by: Hannes Reinecke Reviewed-by: Christoph Hellwig Cc: Himanshu Madhani Cc: Giridhar Malavali --- drivers/scsi/qla2xxx/qla_target.c | 66 +++++++++++++------------------------- drivers/scsi/qla2xxx/qla_target.h | 2 +- drivers/scsi/qla2xxx/tcm_qla2xxx.c | 8 +++-- 3 files changed, 30 insertions(+), 46 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_target.c b/drivers/scsi/qla2xxx/qla_target.c index 45f5077684f0..0a32a3786c4e 100644 --- a/drivers/scsi/qla2xxx/qla_target.c +++ b/drivers/scsi/qla2xxx/qla_target.c @@ -1818,39 +1818,8 @@ static int __qlt_24xx_handle_abts(struct scsi_qla_host *vha, struct abts_recv_from_24xx *abts, struct fc_port *sess) { struct qla_hw_data *ha = vha->hw; - struct se_session *se_sess = sess->se_sess; struct qla_tgt_mgmt_cmd *mcmd; - struct se_cmd *se_cmd; - u32 lun = 0; int rc; - bool found_lun = false; - unsigned long flags; - - spin_lock_irqsave(&se_sess->sess_cmd_lock, flags); - list_for_each_entry(se_cmd, &se_sess->sess_cmd_list, se_cmd_list) { - struct qla_tgt_cmd *cmd = - container_of(se_cmd, struct qla_tgt_cmd, se_cmd); - if (se_cmd->tag == abts->exchange_addr_to_abort) { - lun = cmd->unpacked_lun; - found_lun = true; - break; - } - } - spin_unlock_irqrestore(&se_sess->sess_cmd_lock, flags); - - /* cmd not in LIO lists, look in qla list */ - if (!found_lun) { - if (abort_cmd_for_tag(vha, abts->exchange_addr_to_abort)) { - /* send TASK_ABORT response immediately */ - qlt_24xx_send_abts_resp(vha, abts, FCP_TMF_CMPL, false); - return 0; - } else { - ql_dbg(ql_dbg_tgt_mgt, vha, 0xf081, - "unable to find cmd in driver or LIO for tag 0x%x\n", - abts->exchange_addr_to_abort); - return -ENOENT; - } - } ql_dbg(ql_dbg_tgt_mgt, vha, 0xf00f, "qla_target(%d): task abort (tag=%d)\n", @@ -1870,17 +1839,27 @@ static int __qlt_24xx_handle_abts(struct scsi_qla_host *vha, mcmd->reset_count = vha->hw->chip_reset; mcmd->tmr_func = QLA_TGT_ABTS; - rc = ha->tgt.tgt_ops->handle_tmr(mcmd, lun, mcmd->tmr_func, - abts->exchange_addr_to_abort); - if (rc != 0) { - ql_dbg(ql_dbg_tgt_mgt, vha, 0xf052, - "qla_target(%d): tgt_ops->handle_tmr()" - " failed: %d", vha->vp_idx, rc); - mempool_free(mcmd, qla_tgt_mgmt_cmd_mempool); - return -EFAULT; + rc = ha->tgt.tgt_ops->handle_tmr(mcmd, -1, mcmd->tmr_func, + abts->exchange_addr_to_abort, false); + if (rc == 0) + return 0; + + ql_dbg(ql_dbg_tgt_mgt, vha, 0xf052, + "qla_target(%d): tgt_ops->handle_tmr() failed: %d", + vha->vp_idx, rc); + mempool_free(mcmd, qla_tgt_mgmt_cmd_mempool); + + /* cmd not in LIO lists, look in qla list */ + if (abort_cmd_for_tag(vha, abts->exchange_addr_to_abort)) { + /* send TASK_ABORT response immediately */ + qlt_24xx_send_abts_resp(vha, abts, FCP_TMF_CMPL, false); + return 0; } - return 0; + ql_dbg(ql_dbg_tgt_mgt, vha, 0xf081, + "unable to find cmd in driver or LIO for tag 0x%x\n", + abts->exchange_addr_to_abort); + return -ENOENT; } /* @@ -4195,7 +4174,7 @@ static int qlt_issue_task_mgmt(struct fc_port *sess, u64 lun, break; } - res = ha->tgt.tgt_ops->handle_tmr(mcmd, lun, mcmd->tmr_func, 0); + res = ha->tgt.tgt_ops->handle_tmr(mcmd, lun, mcmd->tmr_func, 0, true); if (res != 0) { ql_dbg(ql_dbg_tgt_tmr, vha, 0x1000b, "qla_target(%d): tgt.tgt_ops->handle_tmr() failed: %d\n", @@ -4272,8 +4251,9 @@ static int __qlt_abort_task(struct scsi_qla_host *vha, mcmd->reset_count = vha->hw->chip_reset; mcmd->tmr_func = QLA_TGT_2G_ABORT_TASK; - rc = ha->tgt.tgt_ops->handle_tmr(mcmd, unpacked_lun, mcmd->tmr_func, - le16_to_cpu(iocb->u.isp2x.seq_id)); + rc = ha->tgt.tgt_ops->handle_tmr(mcmd, unpacked_lun, TMR_ABORT_TASK, + le16_to_cpu(iocb->u.isp2x.seq_id), + true); if (rc != 0) { ql_dbg(ql_dbg_tgt_mgt, vha, 0xf060, "qla_target(%d): tgt_ops->handle_tmr() failed: %d\n", diff --git a/drivers/scsi/qla2xxx/qla_target.h b/drivers/scsi/qla2xxx/qla_target.h index a7f90dcaae37..bc9468f7a643 100644 --- a/drivers/scsi/qla2xxx/qla_target.h +++ b/drivers/scsi/qla2xxx/qla_target.h @@ -669,7 +669,7 @@ struct qla_tgt_func_tmpl { void (*handle_data)(struct qla_tgt_cmd *); void (*handle_dif_err)(struct qla_tgt_cmd *); int (*handle_tmr)(struct qla_tgt_mgmt_cmd *, uint32_t, uint16_t, - uint32_t); + uint32_t, bool); void (*free_cmd)(struct qla_tgt_cmd *); void (*free_mcmd)(struct qla_tgt_mgmt_cmd *); void (*free_session)(struct fc_port *); diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.c b/drivers/scsi/qla2xxx/tcm_qla2xxx.c index 8b878a2d7304..4d9180efb9aa 100644 --- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c +++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c @@ -580,10 +580,12 @@ static void tcm_qla2xxx_handle_dif_err(struct qla_tgt_cmd *cmd) * Called from qla_target.c:qlt_issue_task_mgmt() */ static int tcm_qla2xxx_handle_tmr(struct qla_tgt_mgmt_cmd *mcmd, uint32_t lun, - uint16_t tmr_func, uint32_t tag) + uint16_t tmr_func, uint32_t tag, + bool use_lun) { struct fc_port *sess = mcmd->sess; struct se_cmd *se_cmd = &mcmd->se_cmd; + unsigned int flags = TARGET_SCF_ACK_KREF; int transl_tmr_func = 0; switch (tmr_func) { @@ -621,8 +623,10 @@ static int tcm_qla2xxx_handle_tmr(struct qla_tgt_mgmt_cmd *mcmd, uint32_t lun, return -ENOSYS; } + if (!use_lun) + flags |= TARGET_SCF_IGNORE_TMR_LUN; return target_submit_tmr(se_cmd, sess->se_sess, NULL, lun, mcmd, - transl_tmr_func, GFP_ATOMIC, tag, TARGET_SCF_ACK_KREF); + transl_tmr_func, GFP_ATOMIC, tag, flags); } static int tcm_qla2xxx_queue_data_in(struct se_cmd *se_cmd)