From patchwork Sat Mar 5 07:07:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Nicholas A. Bellinger" X-Patchwork-Id: 8509361 Return-Path: X-Original-To: patchwork-linux-scsi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 5AE14C0553 for ; Sat, 5 Mar 2016 07:11:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 55F1A2017D for ; Sat, 5 Mar 2016 07:11:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E1A3520173 for ; Sat, 5 Mar 2016 07:11:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752465AbcCEHLU (ORCPT ); Sat, 5 Mar 2016 02:11:20 -0500 Received: from mail-ob0-f178.google.com ([209.85.214.178]:35486 "EHLO mail-ob0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750952AbcCEHLT (ORCPT ); Sat, 5 Mar 2016 02:11:19 -0500 Received: by mail-ob0-f178.google.com with SMTP id xx9so68525029obc.2 for ; Fri, 04 Mar 2016 23:11:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daterainc-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=zN9KkDsEkmi2BMmbd9Aiev4HRdIcJKzGM+tA3bKTaxY=; b=rbOAGPcGJRPAz75ATMoLWuG6YjxFA4CShwlOHs4M8SGk2crdU9n3lcOrgBpCk3xJXb Q0jzvHsi6bXcFfXQYwXW/l4ykR9aoB4uyn3VHjIUUQjkVbqp87NaydN7El9zVVFXZwGn KPbISKupyEox++hD0xHHxs8YCji0FhXL+WKcUZ++iAoadRjr4fER62c93a5H9X6DfMHa sSTeC/RJcOIwMxhyfEJ9qoOEg+APmRbc0jruDgKHF2pQiA7lPPURuFJAZ1IfEvBjXatK UnoE/fBTXZfchHElOQJLw97qIuud9cCiXqpGwnEAvG+PNpfYwr2Kf1MXRTVEdP37JJCz NJCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=zN9KkDsEkmi2BMmbd9Aiev4HRdIcJKzGM+tA3bKTaxY=; b=g5tK/+RKuH97lqfcfDSB56reEGuugd8gGE2CTqB4EIyzQm+ldd6NsGqsFXv+Ob4mT4 zNO07zOxg2RhN8N69TIAzSjjww8Mtiv/53F+jxlRuR9Kx8MbWTpkDDuCEiaSwdr8T7Ti o6hocOLEhQY1oe82rPy8uT6+xtSO7+RXg7123gLic9mgPX6xCf+Qm8+hCwi+wZXUvlih 1qBtgqN1bDVksrF9grRjIl3QyUOdMI0QWnuju6ok9h9dGaEpYsS9Zggh3/vTBXDr956h qjEuGYvdXExpxabwrPmVwtoWf5PWPPe0x99q7MbxBNpNNqudGe9l20atDZLNH7t8DlbV fR1Q== X-Gm-Message-State: AD7BkJJiKv5L7WZm/0BfmHKhXoUadUSUQmJ8kS2G1Rf6o10HPlrnc+8qkOJtNBgbZpAR4w== X-Received: by 10.182.28.167 with SMTP id c7mr260862obh.74.1457161878265; Fri, 04 Mar 2016 23:11:18 -0800 (PST) Received: from localhost.localdomain (mail.linux-iscsi.org. [67.23.28.174]) by smtp.gmail.com with ESMTPSA id b128sm4495160oig.26.2016.03.04.23.11.17 (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 04 Mar 2016 23:11:17 -0800 (PST) From: "Nicholas A. Bellinger" To: target-devel , linux-scsi Cc: Hannes Reinecke , Christoph Hellwig , Mike Christie , Sagi Grimberg , Andy Grover , Nicholas Bellinger , Sagi Grimberg , Mike Christie Subject: [PATCH-v2 1/2] target: Avoid DataIN transfers for non-GOOD SAM status Date: Sat, 5 Mar 2016 07:07:13 +0000 Message-Id: <1457161634-15756-1-git-send-email-nab@daterainc.com> X-Mailer: git-send-email 1.7.2.5 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Nicholas Bellinger This patch modifies existing transport_complete_*() code to avoid invoking target_core_fabric_ops->queue_data_in() driver callbacks for I/O READs with non-GOOD SAM status. Some initiators expect GOOD status when a DATA-IN payload transfer is involved, so to be safe go ahead and always invoke target_core_fabric_ops->queue_status() to generate fabric responses instead. Note this is a prerequisite for IBLOCK supporting retriable status, so SAM_STAT_BUSY + SAM_STAT_TASK_SET_FULL always generates fabric driver responses instead of initiating DataIN payload transfer when non-GOOD status is present Cc: Christoph Hellwig Cc: Hannes Reinecke Cc: Sagi Grimberg Cc: Andy Grover Cc: Mike Christie Signed-off-by: Nicholas Bellinger Reviewed-by: Christoph Hellwig --- drivers/target/target_core_transport.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index f5ad9e0..784dd22 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c @@ -1997,6 +1997,9 @@ static void transport_complete_qf(struct se_cmd *cmd) switch (cmd->data_direction) { case DMA_FROM_DEVICE: + if (cmd->scsi_status) + goto queue_status; + trace_target_cmd_complete(cmd); ret = cmd->se_tfo->queue_data_in(cmd); break; @@ -2007,6 +2010,7 @@ static void transport_complete_qf(struct se_cmd *cmd) } /* Fall through for DMA_TO_DEVICE */ case DMA_NONE: +queue_status: trace_target_cmd_complete(cmd); ret = cmd->se_tfo->queue_status(cmd); break; @@ -2128,6 +2132,9 @@ static void target_complete_ok_work(struct work_struct *work) queue_rsp: switch (cmd->data_direction) { case DMA_FROM_DEVICE: + if (cmd->scsi_status) + goto queue_status; + atomic_long_add(cmd->data_length, &cmd->se_lun->lun_stats.tx_data_octets); /* @@ -2167,6 +2174,7 @@ queue_rsp: } /* Fall through for DMA_TO_DEVICE */ case DMA_NONE: +queue_status: trace_target_cmd_complete(cmd); ret = cmd->se_tfo->queue_status(cmd); if (ret == -EAGAIN || ret == -ENOMEM)