From patchwork Wed Feb 15 00:25:48 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: 9573075 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 9DDF56045F for ; Wed, 15 Feb 2017 00:26:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 91735283F4 for ; Wed, 15 Feb 2017 00:26:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8668F2842B; Wed, 15 Feb 2017 00:26:44 +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 068BA28418 for ; Wed, 15 Feb 2017 00:26:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751288AbdBOA0n (ORCPT ); Tue, 14 Feb 2017 19:26:43 -0500 Received: from esa1.hgst.iphmx.com ([68.232.141.245]:61609 "EHLO esa1.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750930AbdBOA0k (ORCPT ); Tue, 14 Feb 2017 19:26:40 -0500 X-IronPort-AV: E=Sophos;i="5.33,348,1477929600"; d="scan'208";a="86867733" Received: from unknown (HELO milsmgep15.sandisk.com) ([63.163.107.21]) by ob1.hgst.iphmx.com with ESMTP; 15 Feb 2017 08:26:19 +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 77.E4.57638.A20A3A85; Tue, 14 Feb 2017 16:26:19 -0800 (PST) Received: from milsmgip11.sandisk.com (10.177.8.100) by MILHUBIP04.sdcorp.global.sandisk.com (10.177.9.97) with Microsoft SMTP Server id 14.3.319.2; Tue, 14 Feb 2017 16:26:15 -0800 X-AuditID: 0ac94369-26dee9800001e126-6a-58a3a02ae4c0 Received: from exp-402881.sdcorp.global.sandisk.com ( [10.177.9.6]) by (Symantec Messaging Gateway) with SMTP id 5A.7D.11415.720A3A85; Tue, 14 Feb 2017 16:26:15 -0800 (PST) From: Bart Van Assche To: "Nicholas A . Bellinger" CC: , Bart Van Assche , Hannes Reinecke , Christoph Hellwig , Himanshu Madhani , Giridhar Malavali Subject: [PATCH v6 09/33] target: Make it possible to specify I_T nexus for SCSI abort Date: Tue, 14 Feb 2017 16:25:48 -0800 Message-ID: <20170215002612.14566-10-bart.vanassche@sandisk.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170215002612.14566-1-bart.vanassche@sandisk.com> References: <20170215002612.14566-1-bart.vanassche@sandisk.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrKLMWRmVeSWpSXmKPExsXCddJ5ka72gsURBovvs1rseXCOzWLBm71s FitXH2WyuLCnm9GibfUZRovWpW+ZHNg8ZvxexOJxf/sRJo/dNxvYPNZvucri8XmTXABrFJdN SmpOZllqkb5dAlfGp6n6BYeUK5Z3/2JuYFwq28XIySEhYCKx6ewpxi5GLg4hgaVMEvd3/2GD cHYwSvQv7GSEqWrqusUEkdjIKLHtwWewBJuAkcS39zNZQGwRIHt1zzKwImaBn4wS11feYQdJ CAuESTz4MhWsiEVAVWLFp8NgNq+Ag0Rb9zl2iA3yErvaLrKC2JxA8Rk7TgLVcABts5d4dMYa ZKaEwDRWiUd9H6F6BSVOznwCZjMLSEgcfPGCGcQWElCXOLlkPtMERqFZSMpmISlbwMi0ilEs NzOnODc9tcDQVK84MS8lszhbLzk/dxMjJPAzdzDefeJ9iFGAg1GJh/eE7OIIIdbEsuLK3EOM EhzMSiK8bPVAId6UxMqq1KL8+KLSnNTiQ4zSHCxK4rznZKZGCAmkJ5akZqemFqQWwWSZODil GhgNGI+cv/N+/0mdXRONubebZTIozhH/4ccS33tMMG1C1Mt7yuIZcpanbwtHXI2y9/gT2CfN 2HvpxfEVp3+vDDeVVavVO7hy2d/zZX5LJ3j8KOjP//zgcPMJ/fqFDSzrLqsuEDJ+9S1dUHlB z/2w1Pkqtf3CRxYaLZj8S2b3j+4VeW6lyy94FYopsRRnJBpqMRcVJwIAXp46mXgCAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrCJMWRmVeSWpSXmKPExsXCtZGTTVd9weIIgwMnhC0O/mxjtNjz4Byb xYI3e9ksVq4+ymRxYU83o0Xb6jOMFq1L3zI5sHvM+L2IxeP+9iNMHrtvNrB5TFtznslj/Zar LB6fN8kFsEVx2aSk5mSWpRbp2yVwZXyaql9wSLliefcv5gbGpbJdjJwcEgImEk1dt5i6GLk4 hATWM0r0dXxiB0mwCRhJfHs/kwXEFgGyV/csAytiFvjNKLHm2S+wImGBMIkHX6aCFbEIqEqs +HQYzOYVcJD4//QzC8QGeYldbRdZQWxOoPiMHSeB4hxA2+wlHp2xnsDIvYCRYRWjWG5mTnFu emaBoaFecWJeSmZxtl5yfu4mRki4RO5gfDrR/BAjEwenVAOjTdWtyzKup3XZqusj/0YvE+Mo Dg+5pm+ab2Vz+FddwKZJHp8qYvdXHHw54WxRJr+J60xlD/nrq32/rb3jecom6cHROsk9FfK7 XpenCus9LJsYqfuHLca4tLX4BMu7hd0c4r7nfqReeBfZ/HPO56gWv7Uh91lnsy2+7plxRub1 uePilXopp74osRRnJBpqMRcVJwIAtIJWRMcBAAA= 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 target_submit_tmr() only supports the I_T_L nexus for SCSI abort and other task management functions. Make it possible for target drivers to specify I_T nexus for SCSI abort by passing the TARGET_SCF_IGNORE_TMR_LUN flag to target_submit_tmr(). Signed-off-by: Bart Van Assche Cc: Hannes Reinecke Cc: Christoph Hellwig Cc: Himanshu Madhani Cc: Giridhar Malavali --- drivers/target/target_core_tmr.c | 17 ++++++++++++++++- drivers/target/target_core_transport.c | 18 +++++++++++++----- include/target/target_core_base.h | 1 + 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/drivers/target/target_core_tmr.c b/drivers/target/target_core_tmr.c index 311dc3c2f1dc..5eb164dac5cc 100644 --- a/drivers/target/target_core_tmr.c +++ b/drivers/target/target_core_tmr.c @@ -149,6 +149,13 @@ static bool __target_check_io_state(struct se_cmd *se_cmd, return kref_get_unless_zero(&se_cmd->cmd_kref); } +/** + * core_tmr_abort_task - abort a SCSI command + * @dev: LUN specified in task management function or NULL if no LUN has been + * specified. + * @tmr: Task management function. + * @se_sess: Session a.k.a. I_T nexus. + */ void core_tmr_abort_task( struct se_device *dev, struct se_tmr_req *tmr, @@ -161,7 +168,7 @@ void core_tmr_abort_task( spin_lock_irqsave(&se_sess->sess_cmd_lock, flags); list_for_each_entry(se_cmd, &se_sess->sess_cmd_list, se_cmd_list) { - if (dev != se_cmd->se_dev) + if (dev && dev != se_cmd->se_dev) continue; /* skip task management functions, including tmr->task_cmd */ @@ -181,6 +188,14 @@ void core_tmr_abort_task( list_del_init(&se_cmd->se_cmd_list); spin_unlock_irqrestore(&se_sess->sess_cmd_lock, flags); + /* + * Ensure that this ABORT request is visible to the LU RESET + * code. + */ + if (!tmr->tmr_dev) + WARN_ON_ONCE(transport_lookup_tmr_lun(tmr->task_cmd, + se_cmd->orig_fe_lun) < 0); + cancel_work_sync(&se_cmd->work); transport_wait_for_tasks(se_cmd); diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index ba74f53ef09d..2ed9721a7202 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c @@ -1577,18 +1577,18 @@ static void target_complete_tmr_failure(struct work_struct *work) } /** - * target_submit_tmr - lookup unpacked lun and submit uninitialized se_cmd - * for TMR CDBs + * target_submit_tmr - submit a SCSI task management function to the target core * * @se_cmd: command descriptor to submit * @se_sess: associated se_sess for endpoint * @sense: pointer to SCSI sense buffer - * @unpacked_lun: unpacked LUN to reference for struct se_lun + * @unpacked_lun: LUN the TMR applies to. Ignored if TARGET_SCF_IGNORE_TMR_LUN + * has been set in @flags. * @fabric_context: fabric context for TMR req * @tm_type: Type of TM request * @gfp: gfp type for caller * @tag: referenced task tag for TMR_ABORT_TASK - * @flags: submit cmd flags + * @flags: submit cmd flags (TARGET_SCF_*). * * Callable from all contexts. **/ @@ -1624,7 +1624,14 @@ int target_submit_tmr(struct se_cmd *se_cmd, struct se_session *se_sess, return ret; } - ret = transport_lookup_tmr_lun(se_cmd, unpacked_lun); + if (flags & TARGET_SCF_IGNORE_TMR_LUN) { + WARN_ON_ONCE(tm_type != TMR_ABORT_TASK); + se_cmd->se_lun = NULL; + se_cmd->se_dev = NULL; + se_cmd->se_tmr_req->tmr_dev = NULL; + } else { + ret = transport_lookup_tmr_lun(se_cmd, unpacked_lun); + } if (ret) { /* * For callback during failure handling, push this work off @@ -1634,6 +1641,7 @@ int target_submit_tmr(struct se_cmd *se_cmd, struct se_session *se_sess, schedule_work(&se_cmd->work); return 0; } + WARN_ON_ONCE(tm_type != TMR_ABORT_TASK && !se_cmd->se_dev); transport_generic_handle_tmr(se_cmd); return 0; } diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h index 12a339d6e288..c847f520b0e7 100644 --- a/include/target/target_core_base.h +++ b/include/target/target_core_base.h @@ -186,6 +186,7 @@ enum target_sc_flags_table { TARGET_SCF_ACK_KREF = 0x02, TARGET_SCF_UNKNOWN_SIZE = 0x04, TARGET_SCF_USE_CPUID = 0x08, + TARGET_SCF_IGNORE_TMR_LUN = 0x10, }; /* fabric independent task management function values */