Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1950836pxb; Thu, 4 Nov 2021 11:18:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxP8SmW+WbB9r1Km6Jb3q/dPQANvmIptqW4ZfppYNHW7fQaRqP1aZiyq8BdEl9QiyiIBS1g X-Received: by 2002:a17:907:3f24:: with SMTP id hq36mr50257120ejc.390.1636049929692; Thu, 04 Nov 2021 11:18:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1636049929; cv=none; d=google.com; s=arc-20160816; b=cprh8/+FPC1A0POS+dF8JFOMgOiGduZ5EzItTpn661vJuJ5wDPY6RdadYDyaX/WCHa WdHQ68riqGbJYwf+VnxlAS71fhXeNoyXJNyX/I6/ym/X40nFEb+2KEiU+zD2XRPpP3cx 5xr17fWseym8Vj8OpZLKG2U0jeylx8z20KrnphEw0A3shd3lrncIgOXQrjqg7Sf+DSc9 Hbs5Bh27Hx9O9nGtDWCwEqTrrts/d0mgIt3Mrx3ehfUfhmQIr0ADGuAc9lpQI9tIh1Y9 RLGoGjsuy/xFiC54LcQFWNksR1ukTX/Aeahn0dbAccUWd9yjXTa/vj3eSAN8ItU25M8y GrbQ== 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=w8SXwluvnftokouhNusEDuQ9l965fakiYdRXEaqZ+LA=; b=rA3hlmI8X+KXTme+aNImpHgkj7S2FMGuWr+TVTicIsFR9LHxwl0CB+WcO1OdaGK8qv /OFY8Ws2BFMc3RGpKa8APLAZbP+XKkVYT8exP8RqFAE5pV/cSCyS5/yxRf1QZKTLaWbE 4du2FxphGn3qXaDUqlOBl1CVb+uzNLE1as/M0BoRsgCXe8/feDrw0cIqwZFS633MfaBX duTJFpTPDpvB+AmHbobnn+IhtVoYFS7dvNXrnyEEZdURTuHqv+mJ32T/9Yk5Hi40R+Ke +S6XNxTDJoxBrF4oz2kI1bxOAMvPmvD4iApIa3+mrL1WLcwk5CdRmAcden0SOXXuICI1 so2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@irrelevant.dk header.s=fm1 header.b=U28rfx9+; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=MU+jO1rq; 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 nd25si13003464ejc.391.2021.11.04.11.18.19; Thu, 04 Nov 2021 11:18:49 -0700 (PDT) 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=U28rfx9+; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=MU+jO1rq; 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 S234119AbhKDSTH (ORCPT + 99 others); Thu, 4 Nov 2021 14:19:07 -0400 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:42017 "EHLO out1-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234101AbhKDSTB (ORCPT ); Thu, 4 Nov 2021 14:19:01 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 97B505C0189; Thu, 4 Nov 2021 14:16:22 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Thu, 04 Nov 2021 14:16:22 -0400 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=w8SXwluvnftokouhNusEDuQ9l9 65fakiYdRXEaqZ+LA=; b=U28rfx9+l9/4rOT0qSHPgOSkSlloPz1exkNbkEOuQl WXImsCRHuJS9utWAJBIYFn3TmJ5PBYfd1PZ3EatlbR1/BD2EFEIiBBGM4gI0uBkt OvA/E2L92OvBnyxf3oUK87FTmnE/U0yOi/Z0X2XXv5HqpkyonnBFqJEThqNbuCmS yXK7QxU59PGq6NCnUiV2Ef14/NOXFPR4tiqxCSBSbAfCHBS/LTPlPGg32VKJ94su pfcpIR4UdJnRuy/aK7ydB0jp07iPRJ2VkNvHJ/zJsZBWl+C3uW9VQWGQAetqkoSi HSKz5KeS0YNgbXVHnXC2zo4MUh8yF7Egpul9YespX5RQ== 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=w8SXwluvnftokouhN usEDuQ9l965fakiYdRXEaqZ+LA=; b=MU+jO1rqTbu0uKtQgR9/YhVZeC6qL2tqd 421R5c+BygvoF/gm/3tSKU+Y545x23pL86IOlUKYcwSvGsOC0C7uIJ1QtObhsII7 Y2781RvsgSg0bP0NESX36pQUOT61mqfktaISM+slacOC1kiukSgYPNrUz9+MHmIU evGe0HUF/mdmLsl7yHEs84WzUPJ4CysnZ/SNNZppJOmcum77PxxsxCxTcV9zlCS+ OnX4mPOdpToVbYdF2tmXJMvQWCXtBBFc/VL/zxT/6FmLfEJRQ2yVbnP16qwTsUQi F1ZUwubs3Mgf/8F/QCmgNddCgk4rE0usOqgld/uKBmfv8GFrVlB7g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvuddrtdeggddutdehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffoggfgsedtkeertdertddtnecuhfhrohhmpefmlhgruhhsucfl vghnshgvnhcuoehithhssehirhhrvghlvghvrghnthdrughkqeenucggtffrrghtthgvrh hnpeefveelvdeikeduueffteeggeefhedvffffjeeuueeludehvdegjeevjefhtdetheen ucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehithhsse hirhhrvghlvghvrghnthdrughk X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 4 Nov 2021 14:16:20 -0400 (EDT) From: Klaus Jensen To: linux-nvme@lists.infradead.org Cc: Keith Busch , Christoph Hellwig , Jens Axboe , Sagi Grimberg , linux-kernel@vger.kernel.org, Klaus Jensen Subject: [PATCH] nvme: fix write zeroes pi Date: Thu, 4 Nov 2021 19:16:18 +0100 Message-Id: <20211104181618.864157-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 --- drivers/nvme/host/core.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index 3825b596ca16..532bad4de025 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -914,10 +914,15 @@ 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)) + + switch (ns->pi_type) { + case NVME_NS_DPS_PI_TYPE1: + case NVME_NS_DPS_PI_TYPE2: cmnd->write_zeroes.control = cpu_to_le16(NVME_RW_PRINFO_PRACT); - else - cmnd->write_zeroes.control = 0; + cmnd->write_zeroes.reftag = cpu_to_le32(t10_pi_ref_tag(req)); + break; + } + return BLK_STS_OK; } -- 2.33.1