Received: by 2002:a05:6a10:8395:0:0:0:0 with SMTP id n21csp270765pxh; Wed, 10 Nov 2021 01:23:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJxDj39x43vr5NShWsuxuDtO6mevISpEzLPNeePtQ+TTbsmQcsn2YQXJzlc6cQJ4v5BQxN3E X-Received: by 2002:a17:906:4f05:: with SMTP id t5mr19422153eju.68.1636536226003; Wed, 10 Nov 2021 01:23:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636536225; cv=none; d=google.com; s=arc-20160816; b=FaI4glLaKAIO5p4K3BOhp+JFje58J8cypVfcNmyC7mdPoR4xG5VGAzkAs2ruSoKmvp CUlKDYPySuZBm6xQNQkchObu81Jz/mtYkU37GCY9GeJlTXSSWZJ31mbYnza6Og+e6fQ1 1rmBRiF5ZszJLX/GIIFUvQdlHnggkRjv3I0zTaPwo/fnBK4bDXPhO2Y9Uoqrj07b8T4Z Ud+++gRLOUjZ1if1koD1HhJGqojiYi4hRzsIg+E2Ak0PxXBdm33pHRmWv3qZ22KctEfa OCM5WljML9a8HxV1qTQVtx95Iiq4kK5xZPwV7Cv5rY2YYcD1OD9vd3D/mW65UnFMh4G1 ywpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature:dkim-signature; bh=4Vx7Jq/3ygdLtgCNIWs2uX60JH95t2qVuIdyOj4xUtA=; b=NHM9EBpzq8W2MBGhGWCBEY49bzWR40+v90CvYF+ilrT4kVbiQuwr0tLxR1xgzxyLgi HbAgKLdmpNG9hDpE6+vZL64F2B4s6XaGRJYKbRZJLW7K08ADYsrKkg8vuCLuUmsWYH/b 94TqKgkD70HoqV9rr5PP0Ikx2CFMciwMQvSbYVjh4PgUtZXzMD/02pQ2HDCA0bvR8cgs dam5kcrdZSZt9awOPNq6GQhJdmPq79am3lf+JoClbv8pjx1r2Q3nmr+p7swVZsn2/4co slcKFVQhtDqLrL0k88g9eEbqoi7vewa1FH/ClTcnkBETa8CJRHCakWEr74Mk4IEz041k PI5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@irrelevant.dk header.s=fm1 header.b=hMcdhu6D; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b="ew/cZYOR"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v28si31018658edx.614.2021.11.10.01.23.22; Wed, 10 Nov 2021 01:23:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@irrelevant.dk header.s=fm1 header.b=hMcdhu6D; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b="ew/cZYOR"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230404AbhKJJWB (ORCPT + 99 others); Wed, 10 Nov 2021 04:22:01 -0500 Received: from wout1-smtp.messagingengine.com ([64.147.123.24]:34847 "EHLO wout1-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230053AbhKJJV5 (ORCPT ); Wed, 10 Nov 2021 04:21:57 -0500 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id 757523200A2F; Wed, 10 Nov 2021 04:19:09 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Wed, 10 Nov 2021 04:19:10 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=irrelevant.dk; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; s=fm1; bh=4Vx7Jq/3ygdLtgCNIWs2uX60JH 95t2qVuIdyOj4xUtA=; b=hMcdhu6DhNINAStaSvRMFyrCr0m3lf8eG9VVkvcZrk lCKnMYaEpmO4+/3qOxJIdnRAnJQM7TtYADCGB1JhKzvqILyPzGyH/TQ5sfeDH2DM NbWZKqdXTgFq4/PeiW1DJtd++9wm133f7lWvN+5iHVrrXTXB/BQkK13lgVvRMIm2 LrTE34vIePLITLbTFN1t98E1t2LlrfCYc+c1v/yjqhKX6AZZnkyxcdV+FwBaTu+o nXgi8lPN14zir3Asf3EAvc4bOkFZGsL+gHhHVuvfESh5eVymydWdydhKQ5CbKItY 1Z6RCi5bH1UQUJUjc3wwMvrKBbU3L0kkIdrjdiFWkxHg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :message-id:mime-version:subject:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=4Vx7Jq/3ygdLtgCNI Ws2uX60JH95t2qVuIdyOj4xUtA=; b=ew/cZYORECEutDEnGTrywLYcGYbRpKBfs VSIlX9f99dYXu1vf31gMD1MMBVtoLnr5ApR4R1OaF0gByaeZ1Erh7DNeaxqYfQZZ T5p2GGU4hLv2549tvzRfQmO9xg7xtKoe2HmG7zTWFWrjb7v4X3pkWDMMNFYTfObN guWwruRJT66sm+4egDRYxbgk11WH+JlCgYRuRmLHxLduvJD5VOwE6DTyfjxNzZOl XQzhlhH2OEm91MSu0KeM3GCQ6q1+1FuvVQagNn8EFqGhEX/A7onffnSXYkw6zwfW DjSrDLHU2pQzkouadEJTu5xzkGin/oGbCauLCyVSQ54CPINCVjz8Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvuddrudejgddtudcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgggfestdekredtredttdenucfhrhhomhepmfhlrghushculfgv nhhsvghnuceoihhtshesihhrrhgvlhgvvhgrnhhtrdgukheqnecuggftrfgrthhtvghrnh epfeevledvieekudeuffetgeegfeehvdffffejueeuleduhedvgeejveejhfdtteehnecu vehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepihhtshesih hrrhgvlhgvvhgrnhhtrdgukh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 10 Nov 2021 04:19:07 -0500 (EST) From: Klaus Jensen To: linux-nvme@lists.infradead.org Cc: Jens Axboe , Christoph Hellwig , linux-kernel@vger.kernel.org, Keith Busch , Sagi Grimberg , Klaus Jensen Subject: [PATCH v2] nvme: fix write zeroes pi Date: Wed, 10 Nov 2021 10:19:06 +0100 Message-Id: <20211110091906.20958-1-its@irrelevant.dk> X-Mailer: git-send-email 2.33.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Klaus Jensen Write Zeroes sets PRACT when block integrity is enabled (as it should), but neglects to also set the reftag which is expected by reads. This causes protection errors on reads. Fix this by setting the reftag for type 1 and 2 (for type 3, reads will not check the reftag). Signed-off-by: Klaus Jensen --- v2: also set PRACT for type 3... drivers/nvme/host/core.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index 3825b596ca16..41885ecc69fc 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -914,10 +914,19 @@ static inline blk_status_t nvme_setup_write_zeroes(struct nvme_ns *ns, cpu_to_le64(nvme_sect_to_lba(ns, blk_rq_pos(req))); cmnd->write_zeroes.length = cpu_to_le16((blk_rq_bytes(req) >> ns->lba_shift) - 1); - if (nvme_ns_has_pi(ns)) + + if (nvme_ns_has_pi(ns)) { cmnd->write_zeroes.control = cpu_to_le16(NVME_RW_PRINFO_PRACT); - else - cmnd->write_zeroes.control = 0; + + switch (ns->pi_type) { + case NVME_NS_DPS_PI_TYPE1: + case NVME_NS_DPS_PI_TYPE2: + cmnd->write_zeroes.reftag = + cpu_to_le32(t10_pi_ref_tag(req)); + break; + } + } + return BLK_STS_OK; } -- 2.33.1