From patchwork Mon Mar 30 03:28:15 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Nicholas A. Bellinger" X-Patchwork-Id: 6118301 Return-Path: X-Original-To: patchwork-linux-scsi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 2827B9F1BE for ; Mon, 30 Mar 2015 03:29:38 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3147D2037C for ; Mon, 30 Mar 2015 03:29:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 202C820357 for ; Mon, 30 Mar 2015 03:29:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752847AbbC3D3d (ORCPT ); Sun, 29 Mar 2015 23:29:33 -0400 Received: from mail-ob0-f173.google.com ([209.85.214.173]:35710 "EHLO mail-ob0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752746AbbC3D3a (ORCPT ); Sun, 29 Mar 2015 23:29:30 -0400 Received: by obcjt1 with SMTP id jt1so110298951obc.2 for ; Sun, 29 Mar 2015 20:29:29 -0700 (PDT) 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:in-reply-to :references; bh=XRfdc9WTHaD54uTJqV+brIPDiXZwbnnLuyhJ3zXNOBw=; b=D8pxSv0lvLTZ+h7YBZ3YHdwD8NR1Es3ZBBXo7VrE4E2qv3iwErW7AgI2ZYHeJDQYjq nor05S3I2bP0CLmjnexOkxGCiNc7xmphHbm0XHzAnKjEytiTAulRfATUp99a63XpGT6F qb6/O7Whgq332Ct5Ze9//TwSuxFOViHKmhl6BpabqLahi0tDOcitenV+np6n8w3uZCXv Cec7OM4capMOeXfQd0da5G2BYUzIQ/gHPsknQ5sKzNo57Q8AeyhlPvUSDsNclvzU/B5l AUbZEGq9xLlZVKmOOOT/SJnKYv8osYuq8rUz6vjLtZbWdeILQoO4Mc/b53VKUoxAJdUe 9ZdA== X-Gm-Message-State: ALoCoQmgB98TugXpgd6QP7GmcjxeFPI6OOBsZlbBms3imXL95vhgay1Teb2blDeg9nrfMmXGOS2N X-Received: by 10.182.68.16 with SMTP id r16mr24575728obt.87.1427686169281; Sun, 29 Mar 2015 20:29:29 -0700 (PDT) Received: from localhost.localdomain (mail.linux-iscsi.org. [67.23.28.174]) by mx.google.com with ESMTPSA id wc6sm5439898obc.8.2015.03.29.20.29.28 (version=TLSv1 cipher=RC4-SHA bits=128/128); Sun, 29 Mar 2015 20:29:28 -0700 (PDT) From: "Nicholas A. Bellinger" To: target-devel Cc: linux-scsi , "Martin K. Petersen" , Sagi Grimberg , Quinn Tran , Nicholas Bellinger , Christoph Hellwig Subject: [PATCH-v2 06/15] target: Move cmd->prot_op check into target_check_read_prot Date: Mon, 30 Mar 2015 03:28:15 +0000 Message-Id: <1427686104-14231-7-git-send-email-nab@daterainc.com> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1427686104-14231-1-git-send-email-nab@daterainc.com> References: <1427686104-14231-1-git-send-email-nab@daterainc.com> 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.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, 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 moves the existing target_complete_ok_work() check for cmd->prot_op into it's own function, so it's easier to add future support for READ INSERT. Cc: Martin Petersen Cc: Sagi Grimberg Cc: Christoph Hellwig Signed-off-by: Nicholas Bellinger Reviewed-by: Martin K. Petersen --- drivers/target/target_core_transport.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index 51b62bd..e603e34 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c @@ -1980,16 +1980,22 @@ static void transport_handle_queue_full( schedule_work(&cmd->se_dev->qf_work_queue); } -static bool target_check_read_strip(struct se_cmd *cmd) +static bool target_check_read_prot(struct se_cmd *cmd) { sense_reason_t rc; - if (!(cmd->se_sess->sup_prot_ops & TARGET_PROT_DIN_STRIP)) { - rc = sbc_dif_read_strip(cmd); - if (rc) { - cmd->pi_err = rc; - return true; + switch (cmd->prot_op) { + case TARGET_PROT_DIN_STRIP: + if (!(cmd->se_sess->sup_prot_ops & TARGET_PROT_DIN_STRIP)) { + rc = sbc_dif_read_strip(cmd); + if (rc) { + cmd->pi_err = rc; + return true; + } } + break; + default: + break; } return false; @@ -2064,8 +2070,7 @@ static void target_complete_ok_work(struct work_struct *work) * backend had PI enabled, if the transport will not be * performing hardware READ_STRIP offload. */ - if (cmd->prot_op == TARGET_PROT_DIN_STRIP && - target_check_read_strip(cmd)) { + if (target_check_read_prot(cmd)) { ret = transport_send_check_condition_and_sense(cmd, cmd->pi_err, 0); if (ret == -EAGAIN || ret == -ENOMEM)