From patchwork Mon Sep 17 21:35:51 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: 10603481 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 9F6285A4 for ; Mon, 17 Sep 2018 22:01:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 933DE2A804 for ; Mon, 17 Sep 2018 22:01:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 870F12A851; Mon, 17 Sep 2018 22:01: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=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 014862A804 for ; Mon, 17 Sep 2018 22:01:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728582AbeIRDaM (ORCPT ); Mon, 17 Sep 2018 23:30:12 -0400 Received: from out002.mailprotect.be ([83.217.72.86]:53033 "EHLO out002.mailprotect.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727698AbeIRDaM (ORCPT ); Mon, 17 Sep 2018 23:30:12 -0400 X-Greylist: delayed 1490 seconds by postgrey-1.27 at vger.kernel.org; Mon, 17 Sep 2018 23:30:11 EDT 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=mpjh938bUwNZQwUhp2duNZBvS2pHSH4OMxMjc5rM8SY=; b=WAmQBcu9kxJD CkcKqvEpa/yOuEF4VlUhxBRLyFcCpw4LRdX0fpn1VLCqO7IV6KmZVTRHUKi7YH69X7ColMvCFi0Fa GpWULYK+6ey6lG/X+tVtnDBLTgPjXQAkAWIdoyZdMhiba4e8MqZhFE47RqMO1wqueuyNWJK54/wuf 9MKYjoey6LgLmbe3F4WuptkaN9qLap0JZ79NktYZ4ZSkM2Z3+v1+M4OZ2EghBLV9Nft0BjwXh4x5a /zBobhPM46xuSq2nnGbLaebo8ZjctTEQeoQYo54AuOvmoUti/Xw7IQvvbZu+dRIDjctmfEFhA+B13 aD0RYJ0XEMQv1BNeXo1EtQ==; Received: from smtp-auth.mailprotect.be ([178.208.39.155]) by com-mpt-out002.mailprotect.be with esmtp (Exim 4.89) (envelope-from ) id 1g21C9-0002k1-La; Mon, 17 Sep 2018 23:36:38 +0200 Received: from asus.hsd1.ca.comcast.net (c-174-62-111-89.hsd1.ca.comcast.net [174.62.111.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 0033FC0718; Mon, 17 Sep 2018 23:36:34 +0200 (CEST) From: Bart Van Assche To: "Martin K . Petersen" Cc: Christoph Hellwig , target-devel@vger.kernel.org, Bart Van Assche , Himanshu Madhani , Quinn Tran , Nicholas Bellinger , Mike Christie , Hannes Reinecke Subject: [PATCH 14/17] target/qla2xxx: Simplify the code for handling aborted commands Date: Mon, 17 Sep 2018 14:35:51 -0700 Message-Id: <20180917213554.987-15-bvanassche@acm.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180917213554.987-1-bvanassche@acm.org> References: <20180917213554.987-1-bvanassche@acm.org> MIME-Version: 1.0 X-Originating-IP: 178.208.39.155 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: ham X-SpamExperts-Outgoing-Evidence: Combined (0.05) X-Recommended-Action: accept X-Filter-ID: EX5BVjFpneJeBchSMxfU5nAmT78rSLeu4M+xvsRf6St602E9L7XzfQH6nu9C/Fh9KJzpNe6xgvOx q3u0UDjvO1tLifGj39bI0bcPyaJsYTarjontMPw7f3NqDIrNV7pphXnBH4p08Ft9j1x3N/nLOyf9 76Q8ME2y5t8SHn73bTVr9cki/cijgcjDudGXg1LvOfazYb+rZRy9j5buyuObExSA8kjykoxVeXIO Vdz6dyioNvuH3nkWxL720WI6OU276t4Cj2DeKQ8ek/hqJuy0LxTXjZFxr0jZe/JypqFN0y5AqSsi KknCB77qmgCwiSsgJ7CjLTdBOtRpl1zkoNWegatXFeEfzSagBNwnP2TibSPGN0ExaDjCWJE9qkQd cN59UgJfD4bYz/GQCCl4kh0/KXTFgIfDMShmlQFqCr5hA8xy+28pF/HE/UXip0YpvmqSgtBtsvjK 9mpXvZ581yfqNVA0hlu/NpOnaXNvrIp4mRGgQUA9iOUB9gXW15it62GvKaV7puimXuHjFEy4159w bwEyzRfGbE8wCAa/6a8qkRhRVDBpguHd2Lz1b+OLmJqHIKAmDK/3e0LrVxuItiXdEKrwWp752KLQ 41i9PLuPBg4KEgxQF7G4ajroXShVPl5sItIRrXZlz+x5FiFWc3U/6s9i6Cp0W99UEIBJTcXgWdPl gTl6fJxyntEfhZCKje4ZHniVSmUCsheQO6X6HmaTkrI0q854skGDr1SFWz9TrEZQLgVqEDmqiK0l c17lHF9hQdumSwX5R/88G6ikH5H4tYHVHhzxKltKX/MiaOmx+aXxYXZV7IIcbpaDH/GiU/Hyil7X mbvPqtn3ZUs8zFLZJ7h93vt70VDNfKA9uS3gblHK8lTxaMmH7lgoalhCs8Biro56EJ1hdSsu2wzH a4u51SMJkHPV65dcRBgf/KQMl0AIhOvRcVLFhnx3XZQZL7+iK582OZJyAnMYNm2kqfVM4+l+PmxJ CFvdxzgiQpciHL5SExdGbsJC7MlhFtW/e+P6R/MvjbxdatYzIrok54Pw0rdYfvMVhkojKSyfViOo T2khlHXXr2xkw2MCcR8/LqlugStYx12aCdmJgllbwzHk4r6jX0Is2t8eEL3ZqG06Zzq2j64UVzq4 LQ+CdMU6UAEjzDg6HYuTCyYgL61SIkBTYZdM7f/xrp24ZnU4njv1I+BTNmCylqzc+LDeC5QO2gQo Lz/dsiahQ1DFoGJGH4QvNFk+tnqwh8ck65CgmBGw7T+FW23ixm1lnD8tuNiaIwOmNh0GIh9D7pp1 2abOL5tbNw== 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 Since the target core waits anyway until a target driver has finished processing a command, remove similar waiting code from the tcm_qla2xxx driver. With this change applied command abortion works as follows: * tcm_qla2xxx receives an ABTS and calls target_submit_tmr(). * The target core calls core_tmr_abort_task(). That function sets the CMD_T_ABORTED flag and next calls transport_wait_for_tasks(). * If CMD_T_ACTIVE is still set, __transport_wait_for_tasks() sets CMD_T_STOP and waits for t_transport_stop_comp. * When tcm_qla2xxx_handle_data_work() gets called, it either invokes transport_generic_request_failure() or target_execute_cmd(). * Both functions start with calling __transport_check_aborted_status() and return 1 if CMD_T_ABORTED was set. Otherwise the command that is being executed is completed and target_complete_cmd() completes t_transport_stop_comp. * Once transport_wait_for_tasks() returns the target core considers the TMF as finished. Signed-off-by: Bart Van Assche Cc: Himanshu Madhani Cc: Quinn Tran Cc: Nicholas Bellinger Cc: Mike Christie Cc: Christoph Hellwig Cc: Hannes Reinecke Acked-by: Himanshu Madhani --- drivers/scsi/qla2xxx/tcm_qla2xxx.c | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.c b/drivers/scsi/qla2xxx/tcm_qla2xxx.c index e03d12a5f986..2cedfd4f15a3 100644 --- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c +++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c @@ -414,21 +414,14 @@ static int tcm_qla2xxx_write_pending(struct se_cmd *se_cmd) static int tcm_qla2xxx_write_pending_status(struct se_cmd *se_cmd) { unsigned long flags; - /* - * Check for WRITE_PENDING status to determine if we need to wait for - * CTIO aborts to be posted via hardware in tcm_qla2xxx_handle_data(). - */ + bool wp; + spin_lock_irqsave(&se_cmd->t_state_lock, flags); - if (se_cmd->t_state == TRANSPORT_WRITE_PENDING || - se_cmd->t_state == TRANSPORT_COMPLETE_QF_WP) { - spin_unlock_irqrestore(&se_cmd->t_state_lock, flags); - wait_for_completion_timeout(&se_cmd->t_transport_stop_comp, - 50); - return 0; - } + wp = se_cmd->t_state == TRANSPORT_WRITE_PENDING || + se_cmd->t_state == TRANSPORT_COMPLETE_QF_WP; spin_unlock_irqrestore(&se_cmd->t_state_lock, flags); - return 0; + return wp; } static void tcm_qla2xxx_set_default_node_attrs(struct se_node_acl *nacl) @@ -508,15 +501,6 @@ static void tcm_qla2xxx_handle_data_work(struct work_struct *work) cmd->qpair->tgt_counters.qla_core_ret_ctio++; if (!cmd->write_data_transferred) { - /* - * Check if se_cmd has already been aborted via LUN_RESET, and - * waiting upon completion in tcm_qla2xxx_write_pending_status() - */ - if (cmd->se_cmd.transport_state & CMD_T_ABORTED) { - complete(&cmd->se_cmd.t_transport_stop_comp); - return; - } - switch (cmd->dif_err_code) { case DIF_ERR_GRD: cmd->se_cmd.pi_err =