From patchwork Tue Nov 27 23:52:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10701643 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9700815A7 for ; Tue, 27 Nov 2018 23:52:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 874A22C967 for ; Tue, 27 Nov 2018 23:52:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7BA7D2C9D5; Tue, 27 Nov 2018 23:52:47 +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=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,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 E41A02C9CC for ; Tue, 27 Nov 2018 23:52:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726570AbeK1KwT (ORCPT ); Wed, 28 Nov 2018 05:52:19 -0500 Received: from out002.mailprotect.be ([83.217.72.86]:53859 "EHLO out002.mailprotect.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726370AbeK1KwT (ORCPT ); Wed, 28 Nov 2018 05:52:19 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mailprotect.be; s=mail; h=Content-Transfer-Encoding:MIME-Version:References :In-Reply-To:Message-Id:Date:Subject:Cc:To:From:reply-to:sender:bcc: content-type; bh=9QmZQSMcDGmh37XhEPdL21MTWFj71ADnTSu+y56QXA4=; b=SoPzqJK21lkH T7HbATBD7zStreIbOV/RfvC7K9SSeMFX9iTH/q+USqi/Xv9ygHsGgVUmi0cPMQSHkE41DBKN7BWb9 i1SeIMerBWIf9IgKCQBtLnwgySsvRy5aNPq63ivfCMG2uku56GvTx2igILG3tpfJ3DGSAHFGR5Xe+ oWqGlQk3KXf7c9eM6he3kw3s4OpZ6l2KCuVO1JxJaYQri+umFT+h0A0b4dN4v5sbVHfXZVMjqecq0 KSu1Ia3mmtttw9N7yiopnHM+Yxm4V+TLfU+2YULaPwSbPIudDwko1BerUaZo7YS8li9MPYhF8mXiX SXh+OW0cNT4AEOenLoXckw==; Received: from smtp-auth.mailprotect.be ([178.208.39.159]) by com-mpt-out002.mailprotect.be with esmtp (Exim 4.89) (envelope-from ) id 1gRn9f-000H1L-Et; Wed, 28 Nov 2018 00:52:36 +0100 Received: from desktop-bart.svl.corp.google.com (unknown [104.133.8.89]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp-auth.mailprotect.be (Postfix) with ESMTPSA id B5645C03F9; Wed, 28 Nov 2018 00:52:32 +0100 (CET) From: Bart Van Assche To: "Martin K . Petersen" Cc: Christoph Hellwig , target-devel@vger.kernel.org, Bart Van Assche , Nicholas Bellinger , Mike Christie , David Disseldorp , Hannes Reinecke Subject: [PATCH v2 07/10] target/core: Simplify the code for aborting SCSI commands Date: Tue, 27 Nov 2018 15:52:01 -0800 Message-Id: <20181127235204.186731-8-bvanassche@acm.org> X-Mailer: git-send-email 2.20.0.rc0.387.gc7a69e6b6c-goog In-Reply-To: <20181127235204.186731-1-bvanassche@acm.org> References: <20181127235204.186731-1-bvanassche@acm.org> MIME-Version: 1.0 X-Originating-IP: 178.208.39.159 X-SpamExperts-Domain: mailprotect.be X-SpamExperts-Username: 178.208.39.128/27 Authentication-Results: mailprotect.be; auth=pass smtp.auth=178.208.39.128/27@mailprotect.be X-SpamExperts-Outgoing-Class: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OTDKJdIdZkgCIMo7V3eOzJJ/4nSzNzW4P2kDC4uGq3HDl7GPw DDt+pvlHhV6a5QjptwQBGybQnI83ChkUX8F6u4X0g9iAwvJfZx3lGs1VZ0iZG6egppXkjOrhVptJ 8gZRjxEnfx1IYQ/4lg9Ffvqg9IG0EE8tjDWZlB+G9Jc9fWekhCkYETsycmIe9DyBCzx4I5obgO+2 ucHiHFYFX/uMKqFwmrSG6vY4ocfmWv3Fe9Iziczdq+A= X-Report-Abuse-To: spam@com-mpt-mgt001.mailprotect.be 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 Instead of allowing the code that aborts a SCSI command to finish before all iSCSI data frames have been received, make that code wait until all iSCSI data frames have been received. Introduce a new member variable in the target driver template to communicate that information from the iSCSI target driver to the target core. This change allows to leave out the check whether or not it is already safe to send the TASK_ABORTED reply from transport_send_task_abort(). Cc: Nicholas Bellinger Cc: Mike Christie Cc: Christoph Hellwig Cc: David Disseldorp Cc: Hannes Reinecke Signed-off-by: Bart Van Assche --- drivers/target/iscsi/iscsi_target_configfs.c | 2 ++ drivers/target/target_core_transport.c | 22 ++------------------ include/target/target_core_fabric.h | 7 +++++++ 3 files changed, 11 insertions(+), 20 deletions(-) diff --git a/drivers/target/iscsi/iscsi_target_configfs.c b/drivers/target/iscsi/iscsi_target_configfs.c index 95d0a22b2ad6..1a81386dd7f7 100644 --- a/drivers/target/iscsi/iscsi_target_configfs.c +++ b/drivers/target/iscsi/iscsi_target_configfs.c @@ -1596,4 +1596,6 @@ const struct target_core_fabric_ops iscsi_ops = { .tfc_tpg_nacl_attrib_attrs = lio_target_nacl_attrib_attrs, .tfc_tpg_nacl_auth_attrs = lio_target_nacl_auth_attrs, .tfc_tpg_nacl_param_attrs = lio_target_nacl_param_attrs, + + .write_pending_must_be_called = true, }; diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index 855135812f22..05c3bef2b394 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c @@ -2584,7 +2584,8 @@ transport_generic_new_cmd(struct se_cmd *cmd) * Determine if frontend context caller is requesting the stopping of * this command for frontend exceptions. */ - if (cmd->transport_state & CMD_T_STOP) { + if (cmd->transport_state & CMD_T_STOP && + !cmd->se_tfo->write_pending_must_be_called) { pr_debug("%s:%d CMD_T_STOP for ITT: 0x%08llx\n", __func__, __LINE__, cmd->tag); @@ -3297,25 +3298,6 @@ void transport_send_task_abort(struct se_cmd *cmd) } spin_unlock_irqrestore(&cmd->t_state_lock, flags); - /* - * If there are still expected incoming fabric WRITEs, we wait - * until until they have completed before sending a TASK_ABORTED - * response. This response with TASK_ABORTED status will be - * queued back to fabric module by transport_check_aborted_status(). - */ - if (cmd->data_direction == DMA_TO_DEVICE) { - if (cmd->se_tfo->write_pending_status(cmd) != 0) { - spin_lock_irqsave(&cmd->t_state_lock, flags); - if (cmd->se_cmd_flags & SCF_SEND_DELAYED_TAS) { - spin_unlock_irqrestore(&cmd->t_state_lock, flags); - goto send_abort; - } - cmd->se_cmd_flags |= SCF_SEND_DELAYED_TAS; - spin_unlock_irqrestore(&cmd->t_state_lock, flags); - return; - } - } -send_abort: cmd->scsi_status = SAM_STAT_TASK_ABORTED; transport_lun_remove_cmd(cmd); diff --git a/include/target/target_core_fabric.h b/include/target/target_core_fabric.h index eb9d0923c55c..6859277fc409 100644 --- a/include/target/target_core_fabric.h +++ b/include/target/target_core_fabric.h @@ -101,6 +101,13 @@ struct target_core_fabric_ops { struct configfs_attribute **tfc_tpg_nacl_attrib_attrs; struct configfs_attribute **tfc_tpg_nacl_auth_attrs; struct configfs_attribute **tfc_tpg_nacl_param_attrs; + + /* + * Set this member variable to true if the SCSI transport protocol + * (e.g. iSCSI) requires that the Data-Out buffer is transferred in + * its entirety before a command is aborted. + */ + bool write_pending_must_be_called; }; int target_register_template(const struct target_core_fabric_ops *fo);