From patchwork Wed Jun 28 05:59:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 9813527 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 8FA186020A for ; Wed, 28 Jun 2017 05:59:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 84B52280CF for ; Wed, 28 Jun 2017 05:59:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7952C283CB; Wed, 28 Jun 2017 05:59: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=-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 191DE280CF for ; Wed, 28 Jun 2017 05:59:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751666AbdF1F7p (ORCPT ); Wed, 28 Jun 2017 01:59:45 -0400 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:60593 "EHLO esa4.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751579AbdF1F7p (ORCPT ); Wed, 28 Jun 2017 01:59:45 -0400 X-IronPort-AV: E=Sophos;i="5.40,274,1496073600"; d="scan'208";a="29784227" Received: from sjappemgw12.hgst.com (HELO sjappemgw11.hgst.com) ([199.255.44.66]) by ob1.hgst.iphmx.com with ESMTP; 28 Jun 2017 13:59:45 +0800 Received: from washi.fujisawa.hgst.com ([10.80.170.19]) by sjappemgw11.hgst.com with ESMTP; 27 Jun 2017 22:59:06 -0700 From: Damien Le Moal To: target-devel@vger.kernel.org, linux-scsi@vger.kernel.org, "Nicholas A . Bellinger" Cc: "Martin K . Petersen" , Hannes Reinecke , Bart Van Assche Subject: [PATCH 5/5] target: core: Fix failed command sense data handling Date: Wed, 28 Jun 2017 14:59:00 +0900 Message-Id: <20170628055900.22889-6-damien.lemoal@wdc.com> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170628055900.22889-1-damien.lemoal@wdc.com> References: <20170628055900.22889-1-damien.lemoal@wdc.com> 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 For a target device without a transport->transport_complete method defined (e.g. target_core_user), target_complete_cmd() will always result in a failed command completion being processed through target failure completion work even when the command failure comes from the target processing and has valid sense data (and hence does not require sense data emulation as done in the failure work processing). To ensure that the failed command sense data is propagated as indicated by the target, make sure that the normal "ok" work completion path is used by moving the command SCF_TRANSPORT_TASK_SENSE flag test out of the transport_complete defined conditional. Signed-off-by: Damien Le Moal Reviewed-by: Mike Christie --- drivers/target/target_core_transport.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index f1b3a46..a18e4db 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c @@ -719,10 +719,11 @@ void target_complete_cmd(struct se_cmd *cmd, u8 scsi_status) dev->transport->transport_complete(cmd, cmd->t_data_sg, transport_get_sense_buffer(cmd)); - if (cmd->se_cmd_flags & SCF_TRANSPORT_TASK_SENSE) - success = 1; } + if (cmd->se_cmd_flags & SCF_TRANSPORT_TASK_SENSE) + success = 1; + /* * Check for case where an explicit ABORT_TASK has been received * and transport_wait_for_tasks() will be waiting for completion..