From patchwork Tue May 1 16:01:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Madhani, Himanshu" X-Patchwork-Id: 10374153 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 4CF9D60234 for ; Tue, 1 May 2018 16:02:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3BF1728426 for ; Tue, 1 May 2018 16:02:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 30C8728988; Tue, 1 May 2018 16:02:18 +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=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, MAILING_LIST_MULTI, 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 6300C28985 for ; Tue, 1 May 2018 16:02:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755990AbeEAQCQ (ORCPT ); Tue, 1 May 2018 12:02:16 -0400 Received: from mail-bn3nam01on0076.outbound.protection.outlook.com ([104.47.33.76]:15701 "EHLO NAM01-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753851AbeEAQCJ (ORCPT ); Tue, 1 May 2018 12:02:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=9Xf7KjiX/3Bhaqs2menxOTDHi1KMouMIuMtoE2YQ1Oo=; b=mYI+SZGV5oPWBR8M7toXePG95b2/QZwPP6KK51kK8i5v9fR/uQjEKGehwnqM8YVwT7X8Q5qnU5CMYPTq7Amx2xAuOfQnYXeuEvV0vrrTVLW0Z4Q7fvE+8WaJClEtREdXsx+5NxBDU3xEDHiC9O66Z8uRv3fniU8jpJjJLOp/p4s= Received: from SN4PR0701CA0015.namprd07.prod.outlook.com (2603:10b6:803:28::25) by CY4PR07MB3174.namprd07.prod.outlook.com (2603:10b6:903:cf::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.696.15; Tue, 1 May 2018 16:02:07 +0000 Received: from BY2FFO11FD017.protection.gbl (2a01:111:f400:7c0c::148) by SN4PR0701CA0015.outlook.office365.com (2603:10b6:803:28::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.715.18 via Frontend Transport; Tue, 1 May 2018 16:02:07 +0000 Received-SPF: Pass (protection.outlook.com: domain of cavium.com designates 50.232.66.26 as permitted sender) receiver=protection.outlook.com; client-ip=50.232.66.26; helo=CAEXCH02.caveonetworks.com; Received: from CAEXCH02.caveonetworks.com (50.232.66.26) by BY2FFO11FD017.mail.protection.outlook.com (10.1.14.105) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.20.696.11 via Frontend Transport; Tue, 1 May 2018 16:02:07 +0000 Received: from dut1171.mv.qlogic.com (172.29.51.171) by CAEXCH02.caveonetworks.com (10.17.4.29) with Microsoft SMTP Server id 14.2.347.0; Tue, 1 May 2018 09:02:01 -0700 Received: from dut1171.mv.qlogic.com (localhost [127.0.0.1]) by dut1171.mv.qlogic.com (8.14.7/8.14.7) with ESMTP id w41G1vcw027994; Tue, 1 May 2018 09:01:57 -0700 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id w41G1vNP027993; Tue, 1 May 2018 09:01:57 -0700 From: Himanshu Madhani To: , CC: , Subject: [PATCH 11/12] qla2xxx: Fix TMF and Multi-Queue config Date: Tue, 1 May 2018 09:01:53 -0700 Message-ID: <20180501160154.27915-12-himanshu.madhani@cavium.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20180501160154.27915-1-himanshu.madhani@cavium.com> References: <20180501160154.27915-1-himanshu.madhani@cavium.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:50.232.66.26; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(346002)(376002)(39860400002)(396003)(39380400002)(2980300002)(438002)(199004)(189003)(356003)(26005)(8936002)(54906003)(4326008)(86362001)(50226002)(47776003)(11346002)(186003)(5660300001)(8676002)(80596001)(1076002)(48376002)(2906002)(106466001)(50466002)(110136005)(42186006)(81156014)(16586007)(106002)(87636003)(76176011)(2616005)(44832011)(51416003)(476003)(478600001)(6666003)(36756003)(81166006)(59450400001)(446003)(72206003)(6346003)(486006)(305945005)(336012)(316002)(69596002)(126002); DIR:OUT; SFP:1101; SCL:1; SRVR:CY4PR07MB3174; H:CAEXCH02.caveonetworks.com; FPR:; SPF:Pass; LANG:en; PTR:50-232-66-26-static.hfc.comcastbusiness.net; A:1; MX:1; X-Microsoft-Exchange-Diagnostics: 1; BY2FFO11FD017; 1:7en1byDF1WxYDs+m+/II9EaXOCtNEPOdbIM0xlo8expypgXrFRJ7yxwHQusroWOhH/rhfMfw+L6aueI4d+CXPyNoYW/kYNOGrDiuEW2CQuuNS5QdAsIWFnXsnU+cqtem X-MS-PublicTrafficType: Email X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4608076)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060); SRVR:CY4PR07MB3174; X-Microsoft-Exchange-Diagnostics: 1; CY4PR07MB3174; 3:84+jdccUUXF45Vff0n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Qf2vTJrUa4p7QtkWNM7nEg5/53IIpoj7DbBF03zOffeZOwscNi6mztWSx5P8Ms+veSCJk1XO4PdEKNpIBd21BUrVaRcSfcKi+0x0YO+JFomGcN7p/eJOLSviH93F3bewZBjK89Io2oV0LsNPZd6C2oH6ABgxhO4rdj1GMKT39GJLxKJsFYy+h33V3K7GT/Y9841GUBAucOOGVGMDOJxoRDTVgr+1i4Oq4S8PDBotqm5cP0vyUumc3HR+BhStt5T5aZn6pqdV1AQrmrJEq0ugV1OEmZ3aOIcZ3YkUdErjdMqOSVJPOgt7ZKnNCxdM/algkz/Am5N6NFkm3AhibI9JCNXl/RYXmnKt4YZ1w+qJwObxS3AHK9m6crieBneQE0+h/rxqMJZzpnELYIwEXUr4q3aR6sNn711wWVE; 4:3G28sv3JrwNKN/GfKF+d2qsY808xYyDz1CkdcTRVmTKGizj5k/4CgnPEuW9Qz8TSP0Gckq1Nd5de2bJlr0cJuOVy/3CzLQjsFTnE0Dj8YL6N+SXPXhsgE1Tkia0GEp46mf5AX2SgQRwHmqfwV5eJ289l9Z3zZwK4EyZv70w1cV2x03DV/+loH6w9DEVTZ7yCvurCK63mg9e+ndzvNWhWonNpy35fYwP7MONQFLcBS/cRnnaivM6pNogqYjQ7hmdBopsJZDXuN1d/Ewm0rMKisg== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3231254)(944501410)(52105095)(10201501046)(3002001)(93006095)(93004095)(6041310)(20161123558120)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123564045)(6072148)(201708071742011); SRVR:CY4PR07MB3174; BCL:0; PCL:0; RULEID:; SRVR:CY4PR07MB3174; X-Forefront-PRVS: 06592CCE58 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY4PR07MB3174; 23:QFogZ74Unt6C0x4fH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ii?Q?t37XyZS/WXK/2pCGnR7Hqi0OewC3gwWvXV76bViYb94QyQzumMsmHZ4miShO?= =?us-ascii?Q?iH3mJfWNrO3w+g/67DBnIFfamg9jxn5VxfyxgcQ7INHIiTLNd9dcYEJSpKWN?= =?us-ascii?Q?QBMjWZXuZlkE8W6eKtAXkXwDuHvFq3MtzsT60OlzBYuZ5aMnkIrNBb2H1vLz?= =?us-ascii?Q?1d1J4lvk+dikae9KNvEDtM8bNkPphxMmCfo5A4SO2vlYQKK1XXgXlvJ8bw9Z?= =?us-ascii?Q?Tl11SrI5ED9tRyzypFasrvV+CW21NIJPKsgt/V3WrwdR/OPVBO/og=3D=3D?= X-Microsoft-Antispam-Message-Info: p7nji26e362th090MOjtDeKBpH2yquogqSDKdFN6jWbGI1vI9PGhG3ZXEYEDE+XojgvF0c28PPCPjTKTKDKRQiPZssphWyAyfrhLpdnOQuwn1svzGbhO0echUhz8PjAeOKMOFLMmttoB3GaDuRyRTbwzvmz3Vpu/Kv9fMPVQwMs3vMYNzywB+/noMuQz7ToB X-Microsoft-Exchange-Diagnostics: 1; CY4PR07MB3174; 6:ozkeqikdLyEuWPtEsogP/J/hOlSE0YwjzURpWPClyGQdNah/6oSXv308LLBAZV/Gwkr0RtYuEln72AXDVSV2fGbKcYhkbl0v2f2Easr4UPKfOeUVLWeY3SLQBWG47wunNogTxiNkE5KM76ZTsMxZeQUwElLaJ5Xc4NOAsIW5WalytLowRHNtO0FYWFM/6GIhUvu1gqJuIKagI3dVcCJMkI6YuAHh90jp8c+2dQPEca7SpUcHuM1bTu/FAVIBPZNWxIcwmy6WJc1cjlfWSn2zJoSH09LgkJiQYfjBf+AooCVdO6/gNydWgc7LdViByhB3HnNImpJj/vEu/HN7s2InFYCegV/3mnCWQ4YVB7o6SQEATnfoE7aa3N/cgq9an6SCKtIyg+foHDjDCoA/jzLPoUfLGg3f2YNd/jvPm57R0rfX/iz8llHmC6xpwMyxx+Apvg62LMvcWWLxRRBYajdXew==; 5:xFylsaUydKfTmolYQbb7bCXHCTUk/lQtUmXem1y5ag0S/KEwcsq74E/RRurY+fqalANraKU0eoiWZ1AKHpu8X/Ydes46eqRqAWLKu4UCxGKav3OryKdp2m1tE35hZ0Vy80LXlboL5rmy/vwp2xGxuuhKRkZ28f6ddcO4nqpLZaI=; 24:XdiKhB3tVC3uXF1MXp982a5ykTB3UdjxNIwKej0ix0/glUf2qCubpRZ6M+1D4NSoW+vU/SV37R2C8JlBWrT6OKecix+3SwaskldwVLxAsxw= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY4PR07MB3174; 7:wgVycayl6ZkF6gfkcAzPUR6KGAcRG6P6DofMsdBmwX++w8gaojnjfxaEakq7uO7wUBNNOMo19c0qWg1LBYNfPYOVFvms5QePkfbbpD4tLjQZVlICNu4/CSfzChCa4Oicr9yMKVeaCiXocJVfmT9MqeumQtXb9O0rkIboDKAbnvFhAZb2mgYhVDKcpUjW/grQIRozKyFlKD8hP7s1CGfuVJKQifD4hcb8IcqjcMVUWmnCix3HeqZPjVmclHZudj2u X-MS-Office365-Filtering-Correlation-Id: fb545257-f5d6-4686-76e4-08d5af7ce3b7 X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 May 2018 16:02:07.2022 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fb545257-f5d6-4686-76e4-08d5af7ce3b7 X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=711e4ccf-2e9b-4bcf-a551-4094005b6194; Ip=[50.232.66.26]; Helo=[CAEXCH02.caveonetworks.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR07MB3174 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Quinn Tran For target mode, task management command is queued to specific cpu base on where the scsi command is residing. This prevent race condition of task management command getting ahead of regular scsi command. Signed-off-by: Quinn Tran Signed-off-by: Himanshu Madhani --- drivers/scsi/qla2xxx/qla_target.c | 135 ++++++++++++++++++++++++++++++------- drivers/scsi/qla2xxx/qla_target.h | 4 +- drivers/scsi/qla2xxx/tcm_qla2xxx.c | 27 ++++++++ 3 files changed, 141 insertions(+), 25 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_target.c b/drivers/scsi/qla2xxx/qla_target.c index a77703f655ed..b85c833099ff 100644 --- a/drivers/scsi/qla2xxx/qla_target.c +++ b/drivers/scsi/qla2xxx/qla_target.c @@ -1924,13 +1924,84 @@ static void abort_cmds_for_lun(struct scsi_qla_host *vha, spin_unlock_irqrestore(&vha->cmd_list_lock, flags); } +static struct qla_qpair_hint *qlt_find_qphint(struct scsi_qla_host *vha, + uint64_t unpacked_lun) +{ + struct qla_tgt *tgt = vha->vha_tgt.qla_tgt; + struct qla_qpair_hint *h = NULL; + + if (vha->flags.qpairs_available) { + h = btree_lookup64(&tgt->lun_qpair_map, unpacked_lun); + if (!h) + h = &tgt->qphints[0]; + } else { + h = &tgt->qphints[0]; + } + + return h; +} + +static void qlt_do_tmr_work(struct work_struct *work) +{ + struct qla_tgt_mgmt_cmd *mcmd = + container_of(work, struct qla_tgt_mgmt_cmd, work); + struct qla_hw_data *ha = mcmd->vha->hw; + int rc = EIO; + uint32_t tag; + unsigned long flags; + + switch (mcmd->tmr_func) { + case QLA_TGT_ABTS: + tag = mcmd->orig_iocb.abts.exchange_addr_to_abort; + break; + default: + tag = 0; + break; + } + + rc = ha->tgt.tgt_ops->handle_tmr(mcmd, mcmd->unpacked_lun, + mcmd->tmr_func, tag); + + if (rc != 0) { + spin_lock_irqsave(mcmd->qpair->qp_lock_ptr, flags); + switch (mcmd->tmr_func) { + case QLA_TGT_ABTS: + qlt_24xx_send_abts_resp(mcmd->qpair, + &mcmd->orig_iocb.abts, + FCP_TMF_REJECTED, false); + break; + case QLA_TGT_LUN_RESET: + case QLA_TGT_CLEAR_TS: + case QLA_TGT_ABORT_TS: + case QLA_TGT_CLEAR_ACA: + case QLA_TGT_TARGET_RESET: + qlt_send_busy(mcmd->qpair, &mcmd->orig_iocb.atio, + qla_sam_status); + break; + + case QLA_TGT_ABORT_ALL: + case QLA_TGT_NEXUS_LOSS_SESS: + case QLA_TGT_NEXUS_LOSS: + qlt_send_notify_ack(mcmd->qpair, + &mcmd->orig_iocb.imm_ntfy, 0, 0, 0, 0, 0, 0); + break; + } + spin_unlock_irqrestore(mcmd->qpair->qp_lock_ptr, flags); + + ql_dbg(ql_dbg_tgt_mgt, mcmd->vha, 0xf052, + "qla_target(%d): tgt_ops->handle_tmr() failed: %d\n", + mcmd->vha->vp_idx, rc); + mempool_free(mcmd, qla_tgt_mgmt_cmd_mempool); + } +} + /* ha->hardware_lock supposed to be held on entry */ 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 qla_tgt_mgmt_cmd *mcmd; - int rc; + struct qla_qpair_hint *h = &vha->vha_tgt.qla_tgt->qphints[0]; if (abort_cmd_for_tag(vha, abts->exchange_addr_to_abort)) { /* send TASK_ABORT response immediately */ @@ -1955,23 +2026,29 @@ static int __qlt_24xx_handle_abts(struct scsi_qla_host *vha, memcpy(&mcmd->orig_iocb.abts, abts, sizeof(mcmd->orig_iocb.abts)); mcmd->reset_count = ha->base_qpair->chip_reset; mcmd->tmr_func = QLA_TGT_ABTS; - mcmd->qpair = ha->base_qpair; + mcmd->qpair = h->qpair; mcmd->vha = vha; /* * LUN is looked up by target-core internally based on the passed * abts->exchange_addr_to_abort tag. */ - rc = ha->tgt.tgt_ops->handle_tmr(mcmd, 0, 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; + mcmd->se_cmd.cpuid = h->cpuid; + + if (ha->tgt.tgt_ops->find_cmd_by_tag) { + struct qla_tgt_cmd *abort_cmd; + + abort_cmd = ha->tgt.tgt_ops->find_cmd_by_tag(sess, + abts->exchange_addr_to_abort); + if (abort_cmd && abort_cmd->qpair) { + mcmd->qpair = abort_cmd->qpair; + mcmd->se_cmd.cpuid = abort_cmd->se_cmd.cpuid; + } } + INIT_WORK(&mcmd->work, qlt_do_tmr_work); + queue_work_on(mcmd->se_cmd.cpuid, qla_tgt_wq, &mcmd->work); + return 0; } @@ -4320,7 +4397,7 @@ static int qlt_issue_task_mgmt(struct fc_port *sess, u64 lun, struct qla_hw_data *ha = vha->hw; struct qla_tgt_mgmt_cmd *mcmd; struct atio_from_isp *a = (struct atio_from_isp *)iocb; - int res; + struct qla_qpair_hint *h = &vha->vha_tgt.qla_tgt->qphints[0]; mcmd = mempool_alloc(qla_tgt_mgmt_cmd_mempool, GFP_ATOMIC); if (!mcmd) { @@ -4340,24 +4417,36 @@ static int qlt_issue_task_mgmt(struct fc_port *sess, u64 lun, mcmd->tmr_func = fn; mcmd->flags = flags; mcmd->reset_count = ha->base_qpair->chip_reset; - mcmd->qpair = ha->base_qpair; + mcmd->qpair = h->qpair; mcmd->vha = vha; + mcmd->se_cmd.cpuid = h->cpuid; + mcmd->unpacked_lun = lun; switch (fn) { case QLA_TGT_LUN_RESET: - abort_cmds_for_lun(vha, lun, a->u.isp24.fcp_hdr.s_id); - break; - } + case QLA_TGT_CLEAR_TS: + case QLA_TGT_ABORT_TS: + abort_cmds_for_lun(vha, lun, a->u.isp24.fcp_hdr.s_id); + /* drop through */ + case QLA_TGT_CLEAR_ACA: + h = qlt_find_qphint(vha, mcmd->unpacked_lun); + mcmd->qpair = h->qpair; + mcmd->se_cmd.cpuid = h->cpuid; + break; - res = ha->tgt.tgt_ops->handle_tmr(mcmd, lun, mcmd->tmr_func, 0); - if (res != 0) { - ql_dbg(ql_dbg_tgt_tmr, vha, 0x1000b, - "qla_target(%d): tgt.tgt_ops->handle_tmr() failed: %d\n", - sess->vha->vp_idx, res); - mempool_free(mcmd, qla_tgt_mgmt_cmd_mempool); - return -EFAULT; + case QLA_TGT_TARGET_RESET: + case QLA_TGT_NEXUS_LOSS_SESS: + case QLA_TGT_NEXUS_LOSS: + case QLA_TGT_ABORT_ALL: + default: + /* no-op */ + break; } + INIT_WORK(&mcmd->work, qlt_do_tmr_work); + queue_work_on(mcmd->se_cmd.cpuid, qla_tgt_wq, + &mcmd->work); + return 0; } @@ -5097,8 +5186,6 @@ static void qlt_handle_imm_notify(struct scsi_qla_host *vha, ql_dbg(ql_dbg_tgt_mgt, vha, 0xf038, "qla_target(%d): Immediate notify task %x\n", vha->vp_idx, iocb->u.isp2x.task_flags); - if (qlt_handle_task_mgmt(vha, iocb) == 0) - send_notify_ack = 0; break; case IMM_NTFY_ELS: diff --git a/drivers/scsi/qla2xxx/qla_target.h b/drivers/scsi/qla2xxx/qla_target.h index 728ce74358e7..fecf96f0225c 100644 --- a/drivers/scsi/qla2xxx/qla_target.h +++ b/drivers/scsi/qla2xxx/qla_target.h @@ -682,7 +682,7 @@ struct qla_tgt_cmd; * target module (tcm_qla2xxx). */ struct qla_tgt_func_tmpl { - + struct qla_tgt_cmd *(*find_cmd_by_tag)(struct fc_port *, uint64_t); int (*handle_cmd)(struct scsi_qla_host *, struct qla_tgt_cmd *, unsigned char *, uint32_t, int, int, int); void (*handle_data)(struct qla_tgt_cmd *); @@ -966,6 +966,8 @@ struct qla_tgt_mgmt_cmd { unsigned int flags; uint32_t reset_count; #define QLA24XX_MGMT_SEND_NACK 1 + struct work_struct work; + uint64_t unpacked_lun; union { struct atio_from_isp atio; struct imm_ntfy_from_isp imm_ntfy; diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.c b/drivers/scsi/qla2xxx/tcm_qla2xxx.c index aadfeaac3898..34ea4a8f98d2 100644 --- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c +++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c @@ -630,6 +630,32 @@ static int tcm_qla2xxx_handle_tmr(struct qla_tgt_mgmt_cmd *mcmd, u64 lun, transl_tmr_func, GFP_ATOMIC, tag, flags); } +static struct qla_tgt_cmd *tcm_qla2xxx_find_cmd_by_tag(struct fc_port *sess, + uint64_t tag) +{ + struct qla_tgt_cmd *cmd = NULL; + struct se_cmd *secmd; + unsigned long flags; + + if (!sess->se_sess) + return NULL; + + spin_lock_irqsave(&sess->se_sess->sess_cmd_lock, flags); + list_for_each_entry(secmd, &sess->se_sess->sess_cmd_list, se_cmd_list) { + /* skip task management functions, including tmr->task_cmd */ + if (secmd->se_cmd_flags & SCF_SCSI_TMR_CDB) + continue; + + if (secmd->tag == tag) { + cmd = container_of(secmd, struct qla_tgt_cmd, se_cmd); + break; + } + } + spin_unlock_irqrestore(&sess->se_sess->sess_cmd_lock, flags); + + return cmd; +} + static int tcm_qla2xxx_queue_data_in(struct se_cmd *se_cmd) { struct qla_tgt_cmd *cmd = container_of(se_cmd, @@ -1608,6 +1634,7 @@ static void tcm_qla2xxx_update_sess(struct fc_port *sess, port_id_t s_id, * Calls into tcm_qla2xxx used by qla2xxx LLD I/O path. */ static struct qla_tgt_func_tmpl tcm_qla2xxx_template = { + .find_cmd_by_tag = tcm_qla2xxx_find_cmd_by_tag, .handle_cmd = tcm_qla2xxx_handle_cmd, .handle_data = tcm_qla2xxx_handle_data, .handle_tmr = tcm_qla2xxx_handle_tmr,