public inbox for linux-nvme@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH] nvme: honor NVME_QUIRK_DEALLOCATE_ZEROES for unmap Write Zeroes
@ 2026-03-05 20:27 Robert Pang
  2026-03-06 14:24 ` Christoph Hellwig
  0 siblings, 1 reply; 5+ messages in thread
From: Robert Pang @ 2026-03-05 20:27 UTC (permalink / raw)
  To: Keith Busch, Jens Axboe, Christoph Hellwig, Sagi Grimberg,
	Zhang Yi
  Cc: bmarzins, brauner, chaitanyak, chengzhihao1, djwong, john.g.garry,
	martin.petersen, shinichiro.kawasaki, tytso, yangerkun, yi.zhang,
	yukuai3, robertpang, linux-nvme, linux-kernel

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



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] nvme: honor NVME_QUIRK_DEALLOCATE_ZEROES for unmap Write Zeroes
  2026-03-05 20:27 [PATCH] nvme: honor NVME_QUIRK_DEALLOCATE_ZEROES for unmap Write Zeroes Robert Pang
@ 2026-03-06 14:24 ` Christoph Hellwig
  2026-03-10 17:14   ` Robert Pang
  0 siblings, 1 reply; 5+ messages in thread
From: Christoph Hellwig @ 2026-03-06 14:24 UTC (permalink / raw)
  To: Robert Pang
  Cc: Keith Busch, Jens Axboe, Christoph Hellwig, Sagi Grimberg,
	Zhang Yi, bmarzins, brauner, chaitanyak, chengzhihao1, djwong,
	john.g.garry, martin.petersen, shinichiro.kawasaki, tytso,
	yangerkun, yi.zhang, yukuai3, linux-nvme, linux-kernel

On Thu, Mar 05, 2026 at 12:27:32PM -0800, Robert Pang wrote:
> However, certain devices already use the NVME_QUIRK_DEALLOCATE_ZEROES quirk to
> indicate that they deterministically return zeroes after a deallocate/discard

Those certain devices are completely obsolete first generation Intel
SSDs.

> 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

No. This was a hack that got sneaked in in the first days of the nvme
driver and never should have been there.  It most certainly should not
be extended to any new functionality.



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] nvme: honor NVME_QUIRK_DEALLOCATE_ZEROES for unmap Write Zeroes
  2026-03-06 14:24 ` Christoph Hellwig
@ 2026-03-10 17:14   ` Robert Pang
  2026-03-11  2:55     ` Zhang Yi
  0 siblings, 1 reply; 5+ messages in thread
From: Robert Pang @ 2026-03-10 17:14 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Keith Busch, Jens Axboe, Sagi Grimberg, Zhang Yi, bmarzins,
	brauner, chaitanyak, chengzhihao1, djwong, john.g.garry,
	martin.petersen, shinichiro.kawasaki, tytso, yangerkun, yi.zhang,
	yukuai3, linux-nvme, linux-kernel

Hi Christoph

On Fri, Mar 6, 2026 at 6:24 AM Christoph Hellwig <hch@lst.de> wrote:
>
> On Thu, Mar 05, 2026 at 12:27:32PM -0800, Robert Pang wrote:
> > However, certain devices already use the NVME_QUIRK_DEALLOCATE_ZEROES quirk to
> > indicate that they deterministically return zeroes after a deallocate/discard
>
> Those certain devices are completely obsolete first generation Intel
> SSDs.
>
> > 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
>
> No. This was a hack that got sneaked in in the first days of the nvme
> driver and never should have been there.  It most certainly should not
> be extended to any new functionality.
>

Thank you for your review and for providing the historical context
regarding this quirk. Given these insights, we can discard this patch
proposal.

Best regards
Robert Pang


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] nvme: honor NVME_QUIRK_DEALLOCATE_ZEROES for unmap Write Zeroes
  2026-03-10 17:14   ` Robert Pang
@ 2026-03-11  2:55     ` Zhang Yi
  2026-03-13  0:06       ` Robert Pang
  0 siblings, 1 reply; 5+ messages in thread
From: Zhang Yi @ 2026-03-11  2:55 UTC (permalink / raw)
  To: Robert Pang
  Cc: Christoph Hellwig, Keith Busch, Jens Axboe, Sagi Grimberg,
	bmarzins, brauner, chaitanyak, chengzhihao1, djwong, john.g.garry,
	martin.petersen, shinichiro.kawasaki, tytso, yangerkun, yi.zhang,
	yukuai3, linux-nvme, linux-kernel

Hi Robert,

On 3/11/2026 1:14 AM, Robert Pang wrote:
> Hi Christoph
> 
> On Fri, Mar 6, 2026 at 6:24 AM Christoph Hellwig <hch@lst.de> wrote:
>>
>> On Thu, Mar 05, 2026 at 12:27:32PM -0800, Robert Pang wrote:
>>> However, certain devices already use the NVME_QUIRK_DEALLOCATE_ZEROES quirk to
>>> indicate that they deterministically return zeroes after a deallocate/discard
>>
>> Those certain devices are completely obsolete first generation Intel
>> SSDs.
>>
>>> 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
>>
>> No. This was a hack that got sneaked in in the first days of the nvme
>> driver and never should have been there.  It most certainly should not
>> be extended to any new functionality.
>>
> 
> Thank you for your review and for providing the historical context
> regarding this quirk. Given these insights, we can discard this patch
> proposal.
> 

I just wonder if you have such hardware and use cases, or if you simply
want to supplement this feature for those corner devices?

Best regards
Yi.

> Best regards
> Robert Pang



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] nvme: honor NVME_QUIRK_DEALLOCATE_ZEROES for unmap Write Zeroes
  2026-03-11  2:55     ` Zhang Yi
@ 2026-03-13  0:06       ` Robert Pang
  0 siblings, 0 replies; 5+ messages in thread
From: Robert Pang @ 2026-03-13  0:06 UTC (permalink / raw)
  To: Zhang Yi
  Cc: Christoph Hellwig, Keith Busch, Jens Axboe, Sagi Grimberg,
	bmarzins, brauner, chaitanyak, chengzhihao1, djwong, john.g.garry,
	martin.petersen, shinichiro.kawasaki, tytso, yangerkun, yi.zhang,
	yukuai3, linux-nvme, linux-kernel

Hi Zhang Yi

On Tue, Mar 10, 2026 at 7:56 PM Zhang Yi <yi.zhang@huaweicloud.com> wrote:
>
> Hi Robert,
>
> On 3/11/2026 1:14 AM, Robert Pang wrote:
> > Hi Christoph
> >
> > On Fri, Mar 6, 2026 at 6:24 AM Christoph Hellwig <hch@lst.de> wrote:
> >>
> >> On Thu, Mar 05, 2026 at 12:27:32PM -0800, Robert Pang wrote:
> >>> However, certain devices already use the NVME_QUIRK_DEALLOCATE_ZEROES quirk to
> >>> indicate that they deterministically return zeroes after a deallocate/discard
> >>
> >> Those certain devices are completely obsolete first generation Intel
> >> SSDs.
> >>
> >>> 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
> >>
> >> No. This was a hack that got sneaked in in the first days of the nvme
> >> driver and never should have been there.  It most certainly should not
> >> be extended to any new functionality.
> >>
> >
> > Thank you for your review and for providing the historical context
> > regarding this quirk. Given these insights, we can discard this patch
> > proposal.
> >
>
> I just wonder if you have such hardware and use cases, or if you simply
> want to supplement this feature for those corner devices?
>

It is the latter.

Best regards
Robert Pang

> Best regards
> Yi.


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-03-13  0:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-05 20:27 [PATCH] nvme: honor NVME_QUIRK_DEALLOCATE_ZEROES for unmap Write Zeroes Robert Pang
2026-03-06 14:24 ` Christoph Hellwig
2026-03-10 17:14   ` Robert Pang
2026-03-11  2:55     ` Zhang Yi
2026-03-13  0:06       ` Robert Pang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox