From patchwork Wed Feb 15 00:26:12 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: 9573117 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 CEBE8600F6 for ; Wed, 15 Feb 2017 00:27:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C28E9205D6 for ; Wed, 15 Feb 2017 00:27:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B76BC26E76; Wed, 15 Feb 2017 00:27:00 +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 658F7205D6 for ; Wed, 15 Feb 2017 00:27:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751454AbdBOA1A (ORCPT ); Tue, 14 Feb 2017 19:27:00 -0500 Received: from esa1.hgst.iphmx.com ([68.232.141.245]:10895 "EHLO esa1.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751452AbdBOA07 (ORCPT ); Tue, 14 Feb 2017 19:26:59 -0500 X-IronPort-AV: E=Sophos;i="5.33,348,1477929600"; d="scan'208";a="86867948" Received: from unknown (HELO milsmgep14.sandisk.com) ([63.163.107.225]) by ob1.hgst.iphmx.com with ESMTP; 15 Feb 2017 08:26:23 +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 93.FB.18895.E20A3A85; Tue, 14 Feb 2017 16:26:22 -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:16 -0800 X-AuditID: 0ac94371-0fadb980000049cf-43-58a3a02e132e Received: from exp-402881.sdcorp.global.sandisk.com ( [10.177.9.6]) by (Symantec Messaging Gateway) with SMTP id D4.8D.11415.720A3A85; Tue, 14 Feb 2017 16:26:15 -0800 (PST) From: Bart Van Assche To: "Nicholas A . Bellinger" CC: , Bart Van Assche , Christoph Hellwig , Andy Grover , David Disseldorp Subject: [PATCH v6 33/33] target: Move target_remove_from_state_list() into target_release_cmd_kref() Date: Tue, 14 Feb 2017 16:26:12 -0800 Message-ID: <20170215002612.14566-34-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+NgFrrPLMWRmVeSWpSXmKPExsXCddJ5ka7egsURBhveWFnsn/WMyeLr/+ks FitXH2WyaFt9htGidelbJgdWj/vbjzB57L7ZwObxft9VNo/Np6s9Pm+SC2CN4rJJSc3JLEst 0rdL4Mp4uHY/c8FZ/opZ83qZGhj7ebsYOTkkBEwktjROYAGxhQSWMkmsnqbaxcgFZO9glGg9 95sNpmjRhXOsEImNjBKHJ59lB0mwCRhJfHs/E6xbBMhe3bOMCaSIGaR74srdYEXCAqkSu+fv YgaxWQRUJVatngEW5xVwkJj9EGaDvMSutousIDYnUHzGjpNAQzmAttlLPDpjDTJTQqCPVWLx zRVQvYISJ2c+AVvMLCAhcfDFC2aIF9QlTi6ZzzSBUWgWkrJZSMoWMDKtYhTLzcwpzk1PLTA0 0StOzEvJLM7WS87P3cQICfbCHYyvb3sfYhTgYFTi4T0huzhCiDWxrLgy9xCjBAezkggvWz1Q iDclsbIqtSg/vqg0J7X4EKM0B4uSOG+W7NQIIYH0xJLU7NTUgtQimCwTB6dUA6P44msuUj1f all+/Go0PbnpvjbLnJ/vXQ96XZf8PU2Shau/auekJ+oSvAU7L4vP4+q/b/CY9WCJS/0F9U0W ISv7C0wDr8+5EOXeKO0Rzhl6RuLqkhdxd3m/+px+YC7TvjHlb1GWYLCW82+lJ+5BRxwzis5b CwdPrYpNr2LWXDlBq8XnBIt7qhJLcUaioRZzUXEiAELffy5yAgAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrHJMWRmVeSWpSXmKPExsXCtZGTTVd9weIIg0dbzS32z3rGZHHwZxuj xdf/01ksVq4+ymTRtvoMo0Xr0rdMDmwe97cfYfLYfbOBzeP9vqtsHtPWnGfy2Hy62uPzJrkA tigum5TUnMyy1CJ9uwSujIdr9zMXnOWvmDWvl6mBsZ+3i5GTQ0LARGLRhXOsILaQwHpGiR0z QkBsNgEjiW/vZ7KA2CJA9uqeZUxdjFwczAK7GCUmTzgBlhAWSJXYPX8XM4jNIqAqsWr1DHYQ m1fAQeJB2xJ2iAXyErvaLoIt4ASKz9hxEqiXA2iZvcSjM9YTGLkXMDKsYhTLzcwpzk3PLDA0 1CtOzEvJLM7WS87P3cQICZHIHYxPJ5ofYmTi4JRqYPQJKMm92vSw8al2VFrTOjO+rf0Ru3r7 Oj/y9wVHVFkUXHDyfad5u2ZylL/7XZN/91jX/2n97/RwMRen4paXVe3V9SbTuf5m3Le3V37o xGU6JXPmjcaos9+/f5COFQrqv/j/lUBLtGL1mw5mBZY1Gy9nnNl1Z/uP8NN6m7W8a4+e2zDj xeVzJUosxRmJhlrMRcWJAPc1FkfBAQAA 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 The only code that iterates over the state list is the LUN reset code. Deferring removal from the state list is fine since that code grabs a reference to the command before it does any other processing. Leaving out the se_cmd.state_active test is fine because this test is already performed by target_remove_from_state_list(). Signed-off-by: Bart Van Assche Reviewed-by: Hannes Reinecke Cc: Christoph Hellwig Cc: Andy Grover Cc: David Disseldorp --- drivers/target/target_core_transport.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index e4c12f7e0437..f51251261208 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c @@ -604,8 +604,6 @@ static int transport_cmd_check_stop_to_fabric(struct se_cmd *cmd) { unsigned long flags; - target_remove_from_state_list(cmd); - spin_lock_irqsave(&cmd->t_state_lock, flags); /* * Determine if frontend context caller is requesting the stopping of @@ -2479,15 +2477,6 @@ int transport_generic_free_cmd(struct se_cmd *cmd, int wait_for_tasks) if (wait_for_tasks) target_wait_free_cmd(cmd); - if (cmd->se_cmd_flags & SCF_SE_LUN_CMD) { - /* - * Handle WRITE failure case where transport_generic_new_cmd() - * has already added se_cmd to state_list, but fabric has - * failed command before I/O submission. - */ - if (cmd->state_active) - target_remove_from_state_list(cmd); - } BUG_ON(!cmd->se_tfo); return target_put_sess_cmd(cmd); } @@ -2550,6 +2539,8 @@ static void target_release_cmd_kref(struct kref *kref) WARN_ON_ONCE(atomic_read(&se_cmd->tgt_ref.refcount) != 0); + target_remove_from_state_list(se_cmd); + if (se_cmd->lun_ref_active) percpu_ref_put(&se_cmd->se_lun->lun_ref);