From patchwork Wed Feb 8 22:24:54 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: 9563679 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 230446020F for ; Wed, 8 Feb 2017 22:28:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EAC5C284F2 for ; Wed, 8 Feb 2017 22:28:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DFE522852D; Wed, 8 Feb 2017 22:28:36 +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 65A05284F2 for ; Wed, 8 Feb 2017 22:28:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751681AbdBHW2f (ORCPT ); Wed, 8 Feb 2017 17:28:35 -0500 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:63845 "EHLO esa2.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751537AbdBHW1w (ORCPT ); Wed, 8 Feb 2017 17:27:52 -0500 X-IronPort-AV: E=Sophos;i="5.35,348,1483977600"; d="scan'208";a="76618174" Received: from unknown (HELO milsmgep15.sandisk.com) ([63.163.107.21]) by ob1.hgst.iphmx.com with ESMTP; 09 Feb 2017 06:28:20 +0800 Received: from MILHUBIP03.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 B5.54.57638.ACA9B985; Wed, 8 Feb 2017 14:25:15 -0800 (PST) Received: from milsmgip12.sandisk.com (10.177.8.100) by MILHUBIP03.sdcorp.global.sandisk.com (10.177.9.96) with Microsoft SMTP Server id 14.3.319.2; Wed, 8 Feb 2017 14:25:11 -0800 X-AuditID: 0ac94369-26dee9800001e126-f9-589b9aca219b Received: from exp-402881.sdcorp.global.sandisk.com ( [10.177.9.6]) by (Symantec Messaging Gateway) with SMTP id B5.42.18148.7CA9B985; Wed, 8 Feb 2017 14:25:11 -0800 (PST) From: Bart Van Assche To: Bart Van Assche CC: , Christoph Hellwig , Andy Grover , David Disseldorp Subject: [PATCH v4 24/37] target: Remove several state tests from TMF code Date: Wed, 8 Feb 2017 14:24:54 -0800 Message-ID: <20170208222507.25715-25-bart.vanassche@sandisk.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170208222507.25715-1-bart.vanassche@sandisk.com> References: <20170208222507.25715-1-bart.vanassche@sandisk.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrGLMWRmVeSWpSXmKPExsXCddJ5ke7pWbMjDN7c57DYP+sZk8XX/9NZ LFauPspk0br0LZMDi8fumw1sHu/3XWXz2Hy62uPzJrkAligum5TUnMyy1CJ9uwSujHPbPAvW ildM/fiGrYFxjXAXIyeHhICJROvN3UxdjFwcQgJLmSS6XhyFcrYzSiyftI0ZpurxjV2sEImN jBInH/5lA0mwCRhJfHs/kwXEFhEwkPjde4ERpIhZoINRYn7PM1aQhLCAl8T/+71gRSwCKhKL Gq6CxXkFHCQmXjvJCLFBXmJX20WwOCdQfMLLZ2BxIQF7iVcHvoANlRBoY5WY9GAxI0SzoMTJ mU/AhjILSEgcfPGCGaJBXeLkkvlMExiFZiEpm4WkbAEj0ypGsdzMnOLc9NQCQ1O94sS8lMzi bL3k/NxNjJDQztzBePeJ9yFGAQ5GJR7eCsvZEUKsiWXFlbmHGCU4mJVEeFOmAYV4UxIrq1KL 8uOLSnNSiw8xSnOwKInznpOZGiEkkJ5YkpqdmlqQWgSTZeLglGpg7FC252zXnLdOqO67z6Ln Qt1venQb2Nl+mqmkdxWffJvwz7ZAsVrP8d71onNMX1aFiyYEH/2m/NY9fpv9twm1mxefiOQP ebJasjC1dVliRgNDjOA1W9bL7/huMx0RkrgsmS4eoyIwpV/iY9WdTsHE/z9bu55+Ud5dmZZY 3HQ6i6sp46F7VbcSS3FGoqEWc1FxIgAvBnsQaQIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrKJMWRmVeSWpSXmKPExsXCtZGTTff4rNkRBn1rjC32z3rGZHHwZxuj xdf/01ksVq4+ymTRuvQtkwOrx+6bDWwe7/ddZfOYtuY8k8fm09UenzfJBbBGcdmkpOZklqUW 6dslcGWc2+ZZsFa8YurHN2wNjGuEuxg5OSQETCQe39jF2sXIxSEksJ5R4unDmWwgCTYBI4lv 72eygNgiAgYSv3svMIIUMQt0MUpsOnOKHSQhLOAl8f9+L1gRi4CqxPv3D8CaeQUcJKa8eskC sUFeYlfbRVYQmxMoPuHlM0YQW0jAXuLVgS+MExi5FzAyrGIUy83MKc5NzywwNNIrTsxLySzO 1kvOz93ECAmIqB2M1yeaH2Jk4uCUamCctj2h+bx+zpV/cZ9nLhfm2WSY38GRNrNrXWtxgEdm 1czlF/fdUHvHmMZ0OGnX0YjOu1lvI33zuj6t/z3vZU73oq/1N2L8em8V7kpsVRTW/8ucfGY6 m3Zw2rX3/j8uTTRrXTTVZUIFv7bI7Sb/xUGr9qyd5BKTfnjVKfuGg9N6eW9G3F09VdhBiaU4 I9FQi7moOBEAkh2BxrgBAAA= 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 Whether or not a session is being torn down does not affect whether or not SCSI commands are in the task set. Hence remove the "tearing down" checks from the TMF code. The CMD_T_FABRIC_STOP test is left out because it overlaps with the CMD_T_COMPLETE and kref tests. The TRANSPORT_ISTATE_PROCESSING check is left out because it is now safe to wait for a command that is in that state. Signed-off-by: Bart Van Assche Reviewed-by: Hannes Reinecke Cc: Christoph Hellwig Cc: Andy Grover Cc: David Disseldorp --- drivers/target/target_core_tmr.c | 30 ++++++------------------------ 1 file changed, 6 insertions(+), 24 deletions(-) diff --git a/drivers/target/target_core_tmr.c b/drivers/target/target_core_tmr.c index 398526704001..e4c8ebbcb20c 100644 --- a/drivers/target/target_core_tmr.c +++ b/drivers/target/target_core_tmr.c @@ -98,9 +98,8 @@ static bool __target_check_io_state(struct se_cmd *se_cmd, assert_spin_locked(&sess->sess_cmd_lock); WARN_ON_ONCE(!irqs_disabled()); /* - * If command already reached CMD_T_COMPLETE state within - * target_complete_cmd() or CMD_T_FABRIC_STOP due to shutdown, - * this se_cmd has been passed to fabric driver and will + * If a command has already reached the CMD_T_COMPLETE state, + * it has already been passed to the fabric driver and will * not be aborted. * * Otherwise, obtain a local se_cmd->cmd_kref now for TMR @@ -108,15 +107,9 @@ static bool __target_check_io_state(struct se_cmd *se_cmd, * long as se_cmd->cmd_kref is still active unless zero. */ spin_lock(&se_cmd->t_state_lock); - if (se_cmd->transport_state & (CMD_T_COMPLETE | CMD_T_FABRIC_STOP)) { - pr_debug("Attempted to abort io tag: %llu already complete or" - " fabric stop, skipping\n", se_cmd->tag); - spin_unlock(&se_cmd->t_state_lock); - return false; - } - if (sess->sess_tearing_down) { - pr_debug("Attempted to abort io tag: %llu already shutdown," - " skipping\n", se_cmd->tag); + if (se_cmd->transport_state & CMD_T_COMPLETE) { + pr_debug("Response for command with tag %llu is being sent to initiator, skipping\n", + se_cmd->tag); spin_unlock(&se_cmd->t_state_lock); return false; } @@ -235,18 +228,7 @@ static void core_tmr_drain_tmr_list( spin_lock(&sess->sess_cmd_lock); spin_lock(&cmd->t_state_lock); - if (!(cmd->transport_state & CMD_T_ACTIVE) || - (cmd->transport_state & CMD_T_FABRIC_STOP)) { - spin_unlock(&cmd->t_state_lock); - spin_unlock(&sess->sess_cmd_lock); - continue; - } - if (cmd->t_state == TRANSPORT_ISTATE_PROCESSING) { - spin_unlock(&cmd->t_state_lock); - spin_unlock(&sess->sess_cmd_lock); - continue; - } - if (sess->sess_tearing_down) { + if (!(cmd->transport_state & CMD_T_ACTIVE)) { spin_unlock(&cmd->t_state_lock); spin_unlock(&sess->sess_cmd_lock); continue;