Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3710462pxv; Mon, 26 Jul 2021 09:59:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxhXdToE1PE+ME6+1Uhq6+v2te/N71UwKhUxfuNITH6Gqqx2O5oG7IxGxU3yLBR/4fv0ATO X-Received: by 2002:a05:6402:2206:: with SMTP id cq6mr22748118edb.209.1627318746950; Mon, 26 Jul 2021 09:59:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627318746; cv=none; d=google.com; s=arc-20160816; b=TF9ir9jitB7RaYcUGQRnzRoxIqLh05/Z2633/ms187rqsQSA3UpyADDhEKFihxeLLD FS9n4FR52BmimjKlwhMgJHdYa3qj5j05DjzirxlyYtOua90LQ3/OOB0ajMyabLwaN97Y MbdpAKTkpkjpIjOOQg9A/SSlTqd5gLlIiJIkp8JZbkG3gySDKgoqXobqs+kv+fZWaw+A 8uafDNBcQW/WksmlXb4s/xXuRuuxLPEvtobT3XI3BC1fTUOff5whZC4JRj9BMyvZryst F+A3dw7xWYpF2Jc9oVq10V8f5UGEOZq2ZOpSXLIg3pxWg9RheP8jWlPcRZcRnJIDskS/ 796Q== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ss0ybtVDeLhwFFulQoChjJBXl5bcpDNOGGVnCR+H4/s=; b=B30UztlMoXYhrksgwnfB0VkJ5jOMYU0Nv52evi1MGZsyjLUgm94ZFSKgVTih2TGvTI pRyizJrGfNGj2fAy9+scXTWi78Yf2Ctyczw1VnVV8fggqwE3pn8/qtEXyBRYtFUTKirX V6EfKdF3L78YGNvJ91uePul9mKMyLULFAYkb/JBSstLUseyRATFkLtU7t4Qm9n2zoXvW HTtBfvqOashg1Qp14nEKhc92a2q15txwsUa9kwtz8Hmsl5DW+R67so7XisRtsQyRzTyD AhXTdq5ZibZtts9FHGQN1wMx8uaLh/rxNBu5MwFBPqVmNDucfh+tpyzSw4fYjkf9Ik8o JEAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=p6DCIMNY; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k26si494535eds.397.2021.07.26.09.58.43; Mon, 26 Jul 2021 09:59:06 -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=@linuxfoundation.org header.s=korg header.b=p6DCIMNY; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234745AbhGZPd4 (ORCPT + 99 others); Mon, 26 Jul 2021 11:33:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:59840 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236415AbhGZPS5 (ORCPT ); Mon, 26 Jul 2021 11:18:57 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8F30660F92; Mon, 26 Jul 2021 15:59:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1627315166; bh=MnABV6DVcXmESIDHX0jSy5XVW7hAzG1Wu0KVHUTJxJo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=p6DCIMNYFXLrRL2vFRs/ZXOzbbEPkMdRilwI7+NnANTbFvoEklPAoX1KY6VBXCe/y aYKxdiEp/RYw/5CA44pXR2kW8D+Egirk6Xse2kEJYwt3rImDgOO3gWtNG+A9b2PVge 0O690EAhC0vucv7/WIDhppSkGMjc/gA2Y0y2T1QI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christoph Hellwig , Keith Busch , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 5.4 064/108] nvme: set the PRACT bit when using Write Zeroes with T10 PI Date: Mon, 26 Jul 2021 17:39:05 +0200 Message-Id: <20210726153833.745272830@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210726153831.696295003@linuxfoundation.org> References: <20210726153831.696295003@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Christoph Hellwig [ Upstream commit aaeb7bb061be545251606f4d9c82d710ca2a7c8e ] When using Write Zeroes on a namespace that has protection information enabled they behavior without the PRACT bit counter-intuitive and will generally lead to validation failures when reading the written blocks. Fix this by always setting the PRACT bit that generates matching PI data on the fly. Fixes: 6e02318eaea5 ("nvme: add support for the Write Zeroes command") Signed-off-by: Christoph Hellwig Reviewed-by: Keith Busch Reviewed-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/nvme/host/core.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index 710ab45eb679..a5b5a2305791 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -694,7 +694,10 @@ 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); - cmnd->write_zeroes.control = 0; + if (nvme_ns_has_pi(ns)) + cmnd->write_zeroes.control = cpu_to_le16(NVME_RW_PRINFO_PRACT); + else + cmnd->write_zeroes.control = 0; return BLK_STS_OK; } -- 2.30.2