From patchwork Fri Feb 10 01:28:49 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: 9565795 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 1616660572 for ; Fri, 10 Feb 2017 01:29:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0833F28532 for ; Fri, 10 Feb 2017 01:29:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F12E528548; Fri, 10 Feb 2017 01:29: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 9EC3028532 for ; Fri, 10 Feb 2017 01:29:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751467AbdBJB3m (ORCPT ); Thu, 9 Feb 2017 20:29:42 -0500 Received: from esa1.hgst.iphmx.com ([68.232.141.245]:18628 "EHLO esa1.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751478AbdBJB3i (ORCPT ); Thu, 9 Feb 2017 20:29:38 -0500 X-IronPort-AV: E=Sophos;i="5.33,348,1477929600"; d="scan'208";a="82349570" Received: from unknown (HELO milsmgep15.sandisk.com) ([63.163.107.21]) by ob1.hgst.iphmx.com with ESMTP; 10 Feb 2017 09:29:02 +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 33.97.57638.E571D985; Thu, 9 Feb 2017 17:29:02 -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:56 -0800 X-AuditID: 0ac94369-26dee9800001e126-06-589d175ec2ad Received: from exp-402881.sdcorp.global.sandisk.com ( [10.177.9.6]) by (Symantec Messaging Gateway) with SMTP id 19.9F.11415.7571D985; Thu, 9 Feb 2017 17:28:55 -0800 (PST) From: Bart Van Assche To: "Nicholas A . Bellinger" CC: , Bart Van Assche , Christoph Hellwig , Andy Grover , David Disseldorp Subject: [PATCH v5 19/22] target: Move target_remove_from_state_list() into target_release_cmd_kref() Date: Thu, 9 Feb 2017 17:28:49 -0800 Message-ID: <20170210012852.15735-20-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+NgFnrALMWRmVeSWpSXmKPExsXCddJ5kW6c+NwIg6uf+C32z3rGZPH1/3QW i5WrjzJZtK0+w2jRuvQtkwOrx/3tR5g8dt9sYPN4v+8qm8fm09UenzfJBbBGcdmkpOZklqUW 6dslcGV8Ob+TqWAbf8W9zpeMDYwfeLoYOTkkBEwkPv7awt7FyMUhJLCUSeLakr1sEM5WRold 87rZYapaHvxngUhsZJR4+OUPM0iCTcBI4tv7mSwgtgiQvbpnGRNIEbPADkaJiSt3g3ULC6RK bJp2mxXEZhFQkfh8ZDVYA6+Ag8TuU8eYIDbIS+xquwhWwwkUfzX7OpDNAbTNXmLHLgOQmRIC k1gl+nevYYPoFZQ4OfMJ2BxmAQmJgy9egB0kJKAucXLJfKYJjEKzkJTNQlK2gJFpFaNYbmZO cW56aoGhqV5xYl5KZnG2XnJ+7iZGSLhn7mC8+8T7EKMAB6MSD++LmjkRQqyJZcWVuYcYJTiY lUR47/PNjRDiTUmsrEotyo8vKs1JLT7EKM3BoiTOe05maoSQQHpiSWp2ampBahFMlomDU6qB MZA16gC/Queh6ilx+ZpfSyw1yqdO901cKxtWZtg398/n9tuBu1/PnSsxcb3yo64pRSsN1A// fO/5TeCgoa7483X8ATFnZaw4GH7EvZCbsvRjieez/CKblqlq3P6efYwKb2ZnLmsoa9hfuPZi 4KmEtccOWfk/nesYVhCaXWaz0EhMV3lfzrOzSizFGYmGWsxFxYkA+KZc0nMCAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrPJMWRmVeSWpSXmKPExsXCtZGTTTdcfG6EQc9RVYv9s54xWRz82cZo 8fX/dBaLlauPMlm0rT7DaNG69C2TA5vH/e1HmDx232xg83i/7yqbx7Q155k8Np+u9vi8SS6A LYrLJiU1J7MstUjfLoEr48v5nUwF2/gr7nW+ZGxg/MDTxcjJISFgItHy4D9LFyMXh5DAekaJ ZaemMYIk2ASMJL69n8kCYosA2at7ljGBFDEL7GKUmDzhBFhCWCBVYtO026wgNouAqsSV66fZ QWxeAQeJi8tbmSA2yEvsarsIVsMJFH81+zqQzQG0zV5ixy6DCYzcCxgZVjGK5WbmFOemZxYY GuoVJ+alZBZn6yXn525ihARJ5A7GpxPNDzEycXBKNTBme50PblsYYfU6ykchpvfR8mkLaj9L Oxxkd7S7eVPgZLvTMe/zewxO6/6NeP5nzpm7pv+3xK1PaIipXt6j25NhO8d4VmTCAzW9irdq rM9/pv9kXHbhjsCFbWHX1+a1TVwn6T/1d5Hmy/4fZ78YruFQtazbteJtpbE2/0+N0In6/boh yg+1Qo8psRRnJBpqMRcVJwIAl8aMzsIBAAA= 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 | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index 9deab861529c..af72f6b40a85 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 @@ -2486,13 +2484,6 @@ int transport_generic_free_cmd(struct se_cmd *cmd, int wait_for_tasks) } else { if (wait_for_tasks) target_wait_free_cmd(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); } /* * Since the iSCSI and iSER targets driver assume that a SCSI command @@ -2565,6 +2556,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);