public inbox for linux-nvme@lists.infradead.org
 help / color / mirror / Atom feed
From: Robert Pang <robertpang@google.com>
To: Keith Busch <kbusch@kernel.org>, Jens Axboe <axboe@kernel.dk>,
	Christoph Hellwig <hch@lst.de>,  Sagi Grimberg <sagi@grimberg.me>,
	Zhang Yi <yi.zhang@huaweicloud.com>
Cc: bmarzins@redhat.com, brauner@kernel.org, chaitanyak@nvidia.com,
	 chengzhihao1@huawei.com, djwong@kernel.org,
	john.g.garry@oracle.com,  martin.petersen@oracle.com,
	shinichiro.kawasaki@wdc.com, tytso@mit.edu,
	 yangerkun@huawei.com, yi.zhang@huawei.com, yukuai3@huawei.com,
	 robertpang@google.com, linux-nvme@lists.infradead.org,
	 linux-kernel@vger.kernel.org
Subject: [PATCH] nvme: honor NVME_QUIRK_DEALLOCATE_ZEROES for unmap Write Zeroes
Date: Thu,  5 Mar 2026 12:27:32 -0800	[thread overview]
Message-ID: <20260305202735.1773922-1-robertpang@google.com> (raw)

Currently, the NVMe driver sets max_hw_wzeroes_unmap_sectors to indicate the
support for unmap Write Zeroes based strictly on the Deallocate Logical Block
Features (dlfeat) in the Identify Namespace data (commit 545fb46e5bc6 "nvme: set
max_hw_wzeroes_unmap_sectors if device supports DEAC bit").

However, certain devices already use the NVME_QUIRK_DEALLOCATE_ZEROES quirk to
indicate that they deterministically return zeroes after a deallocate/discard
operation to support the Write Zeroes operation in nvme_setup_write_zeroes().
For these devices, it is appropriate to treat them as supporting the unmap Write
Zeroes operation.

Update nvme_update_disk_info() to allow the presence of the DEALLOCATE_ZEROES
quirk (combined with DSM support) to set max_hw_wzeroes_unmap_sectors to enable
the support for unmap Write Zeroes. This ensures consistency with how these
devices are handled elsewhere in the driver.

Signed-off-by: Robert Pang <robertpang@google.com>
Link: https://lore.kernel.org/linux-ext4/20260225000531.3658802-1-robertpang@google.com/T/#m5e776f78ecb7631372d82a5cb3d11f8f1f8afe06
---
 drivers/nvme/host/core.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index f5ebcaa2f859..3f5dd3f867e9 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -2120,9 +2120,10 @@ static bool nvme_update_disk_info(struct nvme_ns *ns, struct nvme_id_ns *id,
 	lim->io_min = phys_bs;
 	lim->io_opt = io_opt;
 	if ((ns->ctrl->quirks & NVME_QUIRK_DEALLOCATE_ZEROES) &&
-	    (ns->ctrl->oncs & NVME_CTRL_ONCS_DSM))
+	    (ns->ctrl->oncs & NVME_CTRL_ONCS_DSM)) {
 		lim->max_write_zeroes_sectors = UINT_MAX;
-	else
+		lim->max_hw_wzeroes_unmap_sectors = UINT_MAX;
+	} else
 		lim->max_write_zeroes_sectors = ns->ctrl->max_zeroes_sectors;
 	return valid;
 }
-- 
2.53.0.473.g4a7958ca14-goog



             reply	other threads:[~2026-03-05 20:28 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-05 20:27 Robert Pang [this message]
2026-03-06 14:24 ` [PATCH] nvme: honor NVME_QUIRK_DEALLOCATE_ZEROES for unmap Write Zeroes Christoph Hellwig
2026-03-10 17:14   ` Robert Pang
2026-03-11  2:55     ` Zhang Yi
2026-03-13  0:06       ` Robert Pang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260305202735.1773922-1-robertpang@google.com \
    --to=robertpang@google.com \
    --cc=axboe@kernel.dk \
    --cc=bmarzins@redhat.com \
    --cc=brauner@kernel.org \
    --cc=chaitanyak@nvidia.com \
    --cc=chengzhihao1@huawei.com \
    --cc=djwong@kernel.org \
    --cc=hch@lst.de \
    --cc=john.g.garry@oracle.com \
    --cc=kbusch@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=martin.petersen@oracle.com \
    --cc=sagi@grimberg.me \
    --cc=shinichiro.kawasaki@wdc.com \
    --cc=tytso@mit.edu \
    --cc=yangerkun@huawei.com \
    --cc=yi.zhang@huawei.com \
    --cc=yi.zhang@huaweicloud.com \
    --cc=yukuai3@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox