From patchwork Mon Mar 30 03:28:10 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: 6118251 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 B902C9F1BE for ; Mon, 30 Mar 2015 03:29:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id ADEC22037F for ; Mon, 30 Mar 2015 03:29:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9300F2037D for ; Mon, 30 Mar 2015 03:29:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752688AbbC3D3X (ORCPT ); Sun, 29 Mar 2015 23:29:23 -0400 Received: from mail-oi0-f49.google.com ([209.85.218.49]:36683 "EHLO mail-oi0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752563AbbC3D3W (ORCPT ); Sun, 29 Mar 2015 23:29:22 -0400 Received: by oicf142 with SMTP id f142so107794390oic.3 for ; Sun, 29 Mar 2015 20:29:21 -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=OxpNvgMqvTdhG80sSRSNnAg7dugsHSV88h9Y58fRB+Q=; b=f1KxACx3DpK75vVp0REGvyjSlsSIrnJibfa+xTuoIROPJaC2JfHwcOztXoX3/BMfdG wC5jlwD8AaK9LRquRl7jzEyJxoH1tVwa2jGxNj9aVBOZslFYiUg10B9z/yJlp8LfwRjC VGb/5wAMTHkDZOLRy+ZnPzsOSSPj91ZsMy22C8/6sqmlzsJxBLHQ0+BIoMwmJLQoFBmk e1rmaZKbM5BKFcF2rzrI1UhBQXEg5I51lkXH7MkulGUPdTERWUwy2cRU/zS5Lr5WOoat xIhwIdaSA6uwLeATY+88lBgiUucn2kfJOBp/Q0ZehZ2L9Gp+J69lyYknVuZunC662YUy o/bg== X-Gm-Message-State: ALoCoQmw7uuBOYilX3YmRy5WsVQ/nk+k0oizpAHg5QMdfZgqECPpBxDOSYD8O+xVPZXTMHj14V6k X-Received: by 10.182.148.71 with SMTP id tq7mr25348377obb.78.1427686161756; Sun, 29 Mar 2015 20:29:21 -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.21 (version=TLSv1 cipher=RC4-SHA bits=128/128); Sun, 29 Mar 2015 20:29:21 -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 01/15] target: Convert DIF emulation to use cmd->prot_type Date: Mon, 30 Mar 2015 03:28:10 +0000 Message-Id: <1427686104-14231-2-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 changes existing DIF emulation to check the command descriptor's prot_type, instead of what the backend device is exposing in pi_prot_type. Since this value is already set in sbc_check_prot(), go ahead and use it to allow protected fabrics to function with unprotected devices. Cc: Martin Petersen Cc: Sagi Grimberg Cc: Christoph Hellwig Signed-off-by: Nicholas Bellinger Reviewed-by: Sagi Grimberg Reviewed-by: Martin K. Petersen --- drivers/target/target_core_sbc.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/target/target_core_sbc.c b/drivers/target/target_core_sbc.c index 9a2f9d3..95a7a74 100644 --- a/drivers/target/target_core_sbc.c +++ b/drivers/target/target_core_sbc.c @@ -1167,7 +1167,7 @@ sbc_dif_generate(struct se_cmd *cmd) sdt = paddr + offset; sdt->guard_tag = cpu_to_be16(crc_t10dif(daddr + j, dev->dev_attrib.block_size)); - if (dev->dev_attrib.pi_prot_type == TARGET_DIF_TYPE1_PROT) + if (cmd->prot_type == TARGET_DIF_TYPE1_PROT) sdt->ref_tag = cpu_to_be32(sector & 0xffffffff); sdt->app_tag = 0; @@ -1186,9 +1186,10 @@ sbc_dif_generate(struct se_cmd *cmd) } static sense_reason_t -sbc_dif_v1_verify(struct se_device *dev, struct se_dif_v1_tuple *sdt, +sbc_dif_v1_verify(struct se_cmd *cmd, struct se_dif_v1_tuple *sdt, const void *p, sector_t sector, unsigned int ei_lba) { + struct se_device *dev = cmd->se_dev; int block_size = dev->dev_attrib.block_size; __be16 csum; @@ -1201,7 +1202,7 @@ sbc_dif_v1_verify(struct se_device *dev, struct se_dif_v1_tuple *sdt, return TCM_LOGICAL_BLOCK_GUARD_CHECK_FAILED; } - if (dev->dev_attrib.pi_prot_type == TARGET_DIF_TYPE1_PROT && + if (cmd->prot_type == TARGET_DIF_TYPE1_PROT && be32_to_cpu(sdt->ref_tag) != (sector & 0xffffffff)) { pr_err("DIFv1 Type 1 reference failed on sector: %llu tag: 0x%08x" " sector MSB: 0x%08x\n", (unsigned long long)sector, @@ -1209,7 +1210,7 @@ sbc_dif_v1_verify(struct se_device *dev, struct se_dif_v1_tuple *sdt, return TCM_LOGICAL_BLOCK_REF_TAG_CHECK_FAILED; } - if (dev->dev_attrib.pi_prot_type == TARGET_DIF_TYPE2_PROT && + if (cmd->prot_type == TARGET_DIF_TYPE2_PROT && be32_to_cpu(sdt->ref_tag) != ei_lba) { pr_err("DIFv1 Type 2 reference failed on sector: %llu tag: 0x%08x" " ei_lba: 0x%08x\n", (unsigned long long)sector, @@ -1293,7 +1294,7 @@ sbc_dif_verify_write(struct se_cmd *cmd, sector_t start, unsigned int sectors, (unsigned long long)sector, sdt->guard_tag, sdt->app_tag, be32_to_cpu(sdt->ref_tag)); - rc = sbc_dif_v1_verify(dev, sdt, daddr + j, sector, + rc = sbc_dif_v1_verify(cmd, sdt, daddr + j, sector, ei_lba); if (rc) { kunmap_atomic(paddr); @@ -1354,7 +1355,7 @@ __sbc_dif_verify_read(struct se_cmd *cmd, sector_t start, unsigned int sectors, continue; } - rc = sbc_dif_v1_verify(dev, sdt, daddr + j, sector, + rc = sbc_dif_v1_verify(cmd, sdt, daddr + j, sector, ei_lba); if (rc) { kunmap_atomic(paddr);