Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3714460pxv; Mon, 26 Jul 2021 10:04:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz2RLA4A1g0YXjwnUcjWhn4lsJMVVnwXEQoNTdq2uEDxHwcEsH9Q+DjAHg99rBHEUHUCKDE X-Received: by 2002:a17:907:d1b:: with SMTP id gn27mr17915026ejc.301.1627319045947; Mon, 26 Jul 2021 10:04:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627319045; cv=none; d=google.com; s=arc-20160816; b=tqs8Hgl2t9JoWAofXEGOy1xMMspempqhzo4EUZTMSF+2IBaWMpwgCKaIixqMoX9Qkl MrTTXIq4RcYrzZW/u0mSUggdi40DJQV8LygbY8SpsD1TH8hJGzNYeknwaljyEyKlixI1 bp2piRRKySvJPKvux5sT6SyHWdtjzKqKoSr5TQ4wB73wuJXRGtuWh1t7vCJBlG2SpEe+ z0ux4Ruf809HtTLs0XK3a1+WYeqqCU85d4YO8Mn/FifVcivXwQ37TEwo39RqHxlpghkf OIvcBYk8sSutjH9hz03tFITeL1R4SQH5j2g1LV8gnX8da6tp/B2cpSwcIXwII5CgiZP6 v1Zg== 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=N7+/slFN6loC3jAodymmeBZYkxl7/N8qF04KoBui4bY=; b=pGR7lfUofsZ/W/3YIfWbY2ojMkyT5YqSHQ3oPULFX+YNONG4yeUy/j7hP3xiVxvl79 1eBbJjrka6Sa/uC/GcGez4F7E52gY+9hPItr16PPfl/lCYj5WzRdfF0B8iuTtWBczHlR 5WagaCdh7Bye0x/4EdwEsXgECskMON5FnFIqfB4h1y/vmcLWs4nqCgTx+aHxZqwz4sIk c4Khj4n9HwKFVUhgJtQVM0aCL22QbEohILty5YA1ZuSdA9Vik5pwb34X50Lm8FrjyAXT kVpPacF4FIbUt48mXjzocn0cpmFlvIlo75437hjYKB2VLUgbJygiF6k9Ql0azAbaYSut oH6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Df9Bv1rX; 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 i11si408361edv.472.2021.07.26.10.03.30; Mon, 26 Jul 2021 10:04:05 -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=Df9Bv1rX; 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 S238276AbhGZPlQ (ORCPT + 99 others); Mon, 26 Jul 2021 11:41:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:38718 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237594AbhGZPXd (ORCPT ); Mon, 26 Jul 2021 11:23:33 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E1BC260240; Mon, 26 Jul 2021 16:04:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1627315442; bh=7EoFKsfVQOJmFmNvmQTuVHQ2W3N/DNsssLIlJoOW6jE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Df9Bv1rX4jOfkCP1pdel0AmEry5SjK5YB68cH5Ks5M6QgwOgItDRv4o8IJAydB7/R VIhfm5xdd2qXsnsc5lhmx21sNwuqDSlZhUF0npSaszHfmyJOy+ag9JO9fwZ1lUOJ3B Jg/f5aigRgiEcydx4XmQb8zOT11Se0ZEWJ7GyHx4= 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.10 097/167] nvme: set the PRACT bit when using Write Zeroes with T10 PI Date: Mon, 26 Jul 2021 17:38:50 +0200 Message-Id: <20210726153842.655674187@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210726153839.371771838@linuxfoundation.org> References: <20210726153839.371771838@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 f520a71a361f..ff5a16b17133 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -751,7 +751,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