From patchwork Wed Feb 8 22:25:04 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: 9563663 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 3B79960236 for ; Wed, 8 Feb 2017 22:28:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0F8D5284F2 for ; Wed, 8 Feb 2017 22:28:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0458A2852B; Wed, 8 Feb 2017 22:28:13 +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 97B332852B for ; Wed, 8 Feb 2017 22:28:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751670AbdBHW2K (ORCPT ); Wed, 8 Feb 2017 17:28:10 -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 S1751991AbdBHW1y (ORCPT ); Wed, 8 Feb 2017 17:27:54 -0500 X-IronPort-AV: E=Sophos;i="5.35,348,1483977600"; d="scan'208";a="76618192" Received: from unknown (HELO milsmgep15.sandisk.com) ([63.163.107.21]) by ob1.hgst.iphmx.com with ESMTP; 09 Feb 2017 06:28:22 +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 F6.54.57638.BCA9B985; 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-fd-589b9acb6563 Received: from exp-402881.sdcorp.global.sandisk.com ( [10.177.9.6]) by (Symantec Messaging Gateway) with SMTP id 49.42.18148.7CA9B985; Wed, 8 Feb 2017 14:25:12 -0800 (PST) From: Bart Van Assche To: Bart Van Assche CC: , Christoph Hellwig , Andy Grover , David Disseldorp Subject: [PATCH v4 34/37] target: Move target_remove_from_state_list() into target_release_cmd_kref() Date: Wed, 8 Feb 2017 14:25:04 -0800 Message-ID: <20170208222507.25715-35-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+NgFrrOLMWRmVeSWpSXmKPExsXCddJ5ke7pWbMjDP5MtbHYP+sZk8XX/9NZ LFauPspk0br0LZMDi8fumw1sHu/3XWXz2Hy62uPzJrkAligum5TUnMyy1CJ9uwSujCdbVzMW rOWv2DFpJksD43OeLkZODgkBE4n/P/eydjFycQgJLGWSmH92FzOEs51RYvmkbcwwVe/OT2GD SGxklPjYcZcVJMEmYCTx7f1MFhBbRMBA4nfvBUaQImaBDkaJ+T3PwIqEBVIlHuyexw5iswio SKxa+QYszivgIPHv6ktGiA3yErvaLoLFOYHiE14+A4sLCdhLvDrwBWyohEAbq8SZ3v/sEM2C EidnPgHbzCwgIXHwxQtmiAZ1iZNL5jNNYBSahaRsFpKyBYxMqxjFcjNzinPTUwsMTfWKE/NS Mouz9ZLzczcxQoI7cwfj3SfehxgFOBiVeHgrLGdHCLEmlhVX5h5ilOBgVhLhTZkGFOJNSays Si3Kjy8qzUktPsQozcGiJM57TmZqhJBAemJJanZqakFqEUyWiYNTqoExc+75pm6huYFJMvaG mSVTzjKFLDCddH56g57j48TVKyu+e067vmFH9mwTwYMrPubMS5noqXgh8bqfqKS6zIKpDjNC fNb5Xeu+Xc2f8DC843vGi9ydEYt6OANPS+Zyvn6t+8HWt0U16t9KiZU3LV5O0OXi83ocyJVj 7pK1JXvVo3cXQ/N7n1cpsRRnJBpqMRcVJwIA+5qMtmoCAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrKJMWRmVeSWpSXmKPExsXCtZGTTffErNkRBj80LPbPesZkcfBnG6PF 1//TWSxWrj7KZNG69C2TA6vH7psNbB7v911l85i25jyTx+bT1R6fN8kFsEZx2aSk5mSWpRbp 2yVwZTzZupqxYC1/xY5JM1kaGJ/zdDFyckgImEi8Oz+FrYuRi0NIYD2jxLkDj5hAEmwCRhLf 3s9kAbFFBAwkfvdeYAQpYhboYpTYdOYUO0hCWCBV4sHueWA2i4CqRPO1I8wgNq+Ag8TnzwvZ ITbIS+xqu8gKYnMCxSe8fMYIYgsJ2Eu8OvCFcQIj9wJGhlWMYrmZOcW56ZkFhkZ6xYl5KZnF 2XrJ+bmbGCEBEbWD8fpE80OMTBycUg2MKsfknytxtfxo1fVuXfNUckfBY4vFt02Xp1xw78v+ MENs46arNrmey4MnOXm+bS9M1l8bLj6jeaLmk1UvfXS9JV/eeHUoX7HOmDGH++WCah2d/R7H PKUXtZzYrHXP5om3ZFa6RqGkkdH7TU8K8i+weM/byirOVrKue02c8of2nZknd+0McgtRYinO SDTUYi4qTgQAkhvkOLgBAAA= 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 99531dc85f9c..9fd8b3788800 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c @@ -596,8 +596,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 @@ -2467,13 +2465,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 @@ -2546,6 +2537,8 @@ static void target_release_cmd_kref(struct kref *kref) WARN_ON_ONCE(atomic_read(&se_cmd->tgt_ref) != 0); + target_remove_from_state_list(se_cmd); + if (se_cmd->lun_ref_active) percpu_ref_put(&se_cmd->se_lun->lun_ref);