From patchwork Mon Sep 17 21:35:46 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: 10603499 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 713F8157B for ; Mon, 17 Sep 2018 22:24:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 616A72A2E6 for ; Mon, 17 Sep 2018 22:24:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 540362A78C; Mon, 17 Sep 2018 22:24:31 +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 D722D2A2E6 for ; Mon, 17 Sep 2018 22:24:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728641AbeIRDxs (ORCPT ); Mon, 17 Sep 2018 23:53:48 -0400 Received: from com-out001.mailprotect.be ([83.217.72.83]:38161 "EHLO com-out001.mailprotect.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728202AbeIRDxs (ORCPT ); Mon, 17 Sep 2018 23:53:48 -0400 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=4onZYYHNEI66MfIbwQbLPbaSy3ek1q6X4yUitvLpkew=; b=Dh6tFlITmUaO PMG7CbPl7kkWycQqDVdDWOo9ipP9pqDymGLhsRHSsHdSp1TWoYpXUm+ytfDTmihPg9cVMCQMWhLrY tXRPoOP+MDjcTChmnq4yfjBEXJt+NpbxXKgl3P+SXQ3N4itRju3aJKD/G9twJhYjIPhSBziJPSO+2 iAa0DR3d195Ji+Gs/5/usSIXnjMuB/1qMFjciZx2bntO0hLR952g6z2v8g/FyQ/q4YabU4MvA0sPa F+vih6ITHAokzeXcg08H9ZBi4486zlxDFQF9jNx9kZEQXQmrqanUaMSyQm9BFVx1/UJkhGjw91UNw XNAUW8dz/TnlmlKHhRaykQ==; Received: from smtp-auth.mailprotect.be ([178.208.39.155]) by com-mpt-out001.mailprotect.be with esmtp (Exim 4.89) (envelope-from ) id 1g21Bz-000As6-5z; Mon, 17 Sep 2018 23:36:27 +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 1E85DC075C; Mon, 17 Sep 2018 23:36:24 +0200 (CEST) From: Bart Van Assche To: "Martin K . Petersen" Cc: Christoph Hellwig , target-devel@vger.kernel.org, Bart Van Assche , Nicholas Bellinger , Mike Christie , Hannes Reinecke Subject: [PATCH 09/17] target/core: Always call transport_complete_callback() upon failure Date: Mon, 17 Sep 2018 14:35:46 -0700 Message-Id: <20180917213554.987-10-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-SpamEx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0dpxIo9d2WgcHzHNTu4W3OyTlA5uhTP73RN8y cSzpfj5sSQhb3cc4IkKXIhy+I6DM7/owTL8J95f1/+MXnOL6CZv+n8/wRksD+x9JjG1O+eyolGM4 l8rlxuGfhU+34hrNm42X2UZAYRVVEuFqpn0Wcxxec4eIhtK5Pi2eqhlDMrilbtDDvtO4rayUOwaR 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 Call transport_complete_callback() not only if COMPARE AND WRITE fails but also if XDWRITEREAD fails. This makes the code more systematic. Signed-off-by: Bart Van Assche Cc: Nicholas Bellinger Cc: Mike Christie Cc: Christoph Hellwig Cc: Hannes Reinecke Reviewed-by: Christoph Hellwig Reviewed-by: Nicholas Bellinger --- drivers/target/target_core_sbc.c | 6 +++++- drivers/target/target_core_transport.c | 11 +++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/drivers/target/target_core_sbc.c b/drivers/target/target_core_sbc.c index 4719e6a98430..c155e12ae8b9 100644 --- a/drivers/target/target_core_sbc.c +++ b/drivers/target/target_core_sbc.c @@ -360,6 +360,10 @@ static sense_reason_t xdreadwrite_callback(struct se_cmd *cmd, bool success, unsigned int offset; sense_reason_t ret = TCM_NO_SENSE; int i, count; + + if (!success) + return 0; + /* * From sbc3r22.pdf section 5.48 XDWRITEREAD (10) command * @@ -431,7 +435,7 @@ static sense_reason_t compare_and_write_post(struct se_cmd *cmd, bool success, * sent to the backend driver. */ spin_lock_irq(&cmd->t_state_lock); - if (cmd->transport_state & CMD_T_SENT) { + if (success) { cmd->se_cmd_flags |= SCF_COMPARE_AND_WRITE_POST; *post_ret = 1; diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index ec3cb16b9e0e..79fa79afcdc2 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c @@ -1793,7 +1793,7 @@ EXPORT_SYMBOL(target_submit_tmr); void transport_generic_request_failure(struct se_cmd *cmd, sense_reason_t sense_reason) { - int ret = 0, post_ret = 0; + int ret = 0; pr_debug("-----[ Storage Engine Exception; sense_reason %d\n", sense_reason); @@ -1804,13 +1804,8 @@ void transport_generic_request_failure(struct se_cmd *cmd, */ transport_complete_task_attr(cmd); - /* - * Handle special case for COMPARE_AND_WRITE failure, where the - * callback is expected to drop the per device ->caw_sem. - */ - if ((cmd->se_cmd_flags & SCF_COMPARE_AND_WRITE) && - cmd->transport_complete_callback) - cmd->transport_complete_callback(cmd, false, &post_ret); + if (cmd->transport_complete_callback) + cmd->transport_complete_callback(cmd, false, NULL); if (transport_check_aborted_status(cmd, 1)) return;