public inbox for linux-nvme@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH] nvme: don't apply NVME_QUIRK_DEALLOCATE_ZEROES when DSM is not supported
@ 2024-11-27  6:42 ` Christoph Hellwig
  2024-11-27  7:48   ` Chaitanya Kulkarni
                     ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Christoph Hellwig @ 2024-11-27  6:42 UTC (permalink / raw)
  To: kbusch, sagi, axboe; +Cc: linux-nvme, Saeed Mirzamohammadi

Commit 63dfa1004322 ("nvme: move NVME_QUIRK_DEALLOCATE_ZEROES out of
nvme_config_discard") started applying the NVME_QUIRK_DEALLOCATE_ZEROES
quirk even then the Dataset Management is not supported.  It turns out
that there versions of these old Intel SSDs that have DSM support
disabled in the firmware, which will now lead to errors everytime
a Write Zeroes command is issued.  Fix this by checking for DSM support
before applying the quirk.

Reported-by: Saeed Mirzamohammadi <saeed.mirzamohammadi@oracle.com>
Fixes: 63dfa1004322 ("nvme: move NVME_QUIRK_DEALLOCATE_ZEROES out of nvme_config_discard")
Tested-by: Saeed Mirzamohammadi <saeed.mirzamohammadi@oracle.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/nvme/host/core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index bfd71511c85f..5e5c9e15ad0c 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -2043,7 +2043,8 @@ static bool nvme_update_disk_info(struct nvme_ns *ns, struct nvme_id_ns *id,
 	lim->physical_block_size = min(phys_bs, atomic_bs);
 	lim->io_min = phys_bs;
 	lim->io_opt = io_opt;
-	if (ns->ctrl->quirks & NVME_QUIRK_DEALLOCATE_ZEROES)
+	if ((ns->ctrl->quirks & NVME_QUIRK_DEALLOCATE_ZEROES) &&
+	    (ns->ctrl->oncs & NVME_CTRL_ONCS_DSM))
 		lim->max_write_zeroes_sectors = UINT_MAX;
 	else
 		lim->max_write_zeroes_sectors = ns->ctrl->max_zeroes_sectors;
-- 
2.45.2



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

* Re: [PATCH] nvme: don't apply NVME_QUIRK_DEALLOCATE_ZEROES when DSM is not supported
  2024-11-27  6:42 ` [PATCH] nvme: don't apply NVME_QUIRK_DEALLOCATE_ZEROES when DSM is not supported Christoph Hellwig
@ 2024-11-27  7:48   ` Chaitanya Kulkarni
  2024-11-27 15:20   ` Nitesh Shetty
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 9+ messages in thread
From: Chaitanya Kulkarni @ 2024-11-27  7:48 UTC (permalink / raw)
  To: Christoph Hellwig, kbusch@kernel.org, sagi@grimberg.me,
	axboe@kernel.dk
  Cc: linux-nvme@lists.infradead.org, Saeed Mirzamohammadi

On 11/26/24 22:42, Christoph Hellwig wrote:
> Commit 63dfa1004322 ("nvme: move NVME_QUIRK_DEALLOCATE_ZEROES out of
> nvme_config_discard") started applying the NVME_QUIRK_DEALLOCATE_ZEROES
> quirk even then the Dataset Management is not supported.  It turns out
> that there versions of these old Intel SSDs that have DSM support
> disabled in the firmware, which will now lead to errors everytime
> a Write Zeroes command is issued.  Fix this by checking for DSM support
> before applying the quirk.
>
> Reported-by: Saeed Mirzamohammadi<saeed.mirzamohammadi@oracle.com>
> Fixes: 63dfa1004322 ("nvme: move NVME_QUIRK_DEALLOCATE_ZEROES out of nvme_config_discard")
> Tested-by: Saeed Mirzamohammadi<saeed.mirzamohammadi@oracle.com>
> Signed-off-by: Christoph Hellwig<hch@lst.de>

Looks good.

Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>

-ck



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

* Re: [PATCH] nvme: don't apply NVME_QUIRK_DEALLOCATE_ZEROES when DSM is not supported
  2024-11-27  6:42 ` [PATCH] nvme: don't apply NVME_QUIRK_DEALLOCATE_ZEROES when DSM is not supported Christoph Hellwig
  2024-11-27  7:48   ` Chaitanya Kulkarni
@ 2024-11-27 15:20   ` Nitesh Shetty
  2024-11-27 15:45   ` Keith Busch
  2024-12-02 17:54   ` Keith Busch
  3 siblings, 0 replies; 9+ messages in thread
From: Nitesh Shetty @ 2024-11-27 15:20 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: kbusch, sagi, axboe, linux-nvme, Saeed Mirzamohammadi

[-- Attachment #1: Type: text/plain, Size: 830 bytes --]

On 27/11/24 07:42AM, Christoph Hellwig wrote:
>Commit 63dfa1004322 ("nvme: move NVME_QUIRK_DEALLOCATE_ZEROES out of
>nvme_config_discard") started applying the NVME_QUIRK_DEALLOCATE_ZEROES
>quirk even then the Dataset Management is not supported.  It turns out
>that there versions of these old Intel SSDs that have DSM support
>disabled in the firmware, which will now lead to errors everytime
>a Write Zeroes command is issued.  Fix this by checking for DSM support
>before applying the quirk.
>
>Reported-by: Saeed Mirzamohammadi <saeed.mirzamohammadi@oracle.com>
>Fixes: 63dfa1004322 ("nvme: move NVME_QUIRK_DEALLOCATE_ZEROES out of nvme_config_discard")
>Tested-by: Saeed Mirzamohammadi <saeed.mirzamohammadi@oracle.com>
>Signed-off-by: Christoph Hellwig <hch@lst.de>
>---

Reviewed-by: Nitesh Shetty <nj.shetty@samsung.com>

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



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

* Re: [PATCH] nvme: don't apply NVME_QUIRK_DEALLOCATE_ZEROES when DSM is not supported
  2024-11-27  6:42 ` [PATCH] nvme: don't apply NVME_QUIRK_DEALLOCATE_ZEROES when DSM is not supported Christoph Hellwig
  2024-11-27  7:48   ` Chaitanya Kulkarni
  2024-11-27 15:20   ` Nitesh Shetty
@ 2024-11-27 15:45   ` Keith Busch
  2024-11-27 15:48     ` Christoph Hellwig
  2024-12-02 17:54   ` Keith Busch
  3 siblings, 1 reply; 9+ messages in thread
From: Keith Busch @ 2024-11-27 15:45 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: sagi, axboe, linux-nvme, Saeed Mirzamohammadi

On Wed, Nov 27, 2024 at 07:42:18AM +0100, Christoph Hellwig wrote:
> Commit 63dfa1004322 ("nvme: move NVME_QUIRK_DEALLOCATE_ZEROES out of
> nvme_config_discard") started applying the NVME_QUIRK_DEALLOCATE_ZEROES
> quirk even then the Dataset Management is not supported.  It turns out
> that there versions of these old Intel SSDs that have DSM support
> disabled in the firmware, which will now lead to errors everytime
> a Write Zeroes command is issued.  Fix this by checking for DSM support
> before applying the quirk.

I still think this is wrong, and we should just remove the quirk for
this device. With the exception to this firmware version, this device
generally supports both discards and write zeroes. The only reason it
added this quirk was because the quirk used to mean something completely
different (specifically, it would set the "discard_zeroes_data"
attribute that's no longer used). It didn't mean to prefer discards over
write zeroes, but that's what it means now, and that's not what this
drive wants.


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

* Re: [PATCH] nvme: don't apply NVME_QUIRK_DEALLOCATE_ZEROES when DSM is not supported
  2024-11-27 15:45   ` Keith Busch
@ 2024-11-27 15:48     ` Christoph Hellwig
  2024-11-27 15:52       ` Keith Busch
  0 siblings, 1 reply; 9+ messages in thread
From: Christoph Hellwig @ 2024-11-27 15:48 UTC (permalink / raw)
  To: Keith Busch
  Cc: Christoph Hellwig, sagi, axboe, linux-nvme, Saeed Mirzamohammadi

On Wed, Nov 27, 2024 at 08:45:04AM -0700, Keith Busch wrote:
> I still think this is wrong, and we should just remove the quirk for
> this device. With the exception to this firmware version, this device
> generally supports both discards and write zeroes. The only reason it
> added this quirk was because the quirk used to mean something completely
> different (specifically, it would set the "discard_zeroes_data"
> attribute that's no longer used). It didn't mean to prefer discards over
> write zeroes, but that's what it means now, and that's not what this
> drive wants.

I'll have to trust you on this device, and certainly won't object
removing this weirdo quick.  But as long as we don't remove the
quirk entirely we'll also need this fix.  So I guess we should go
for both?


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

* Re: [PATCH] nvme: don't apply NVME_QUIRK_DEALLOCATE_ZEROES when DSM is not supported
  2024-11-27 15:48     ` Christoph Hellwig
@ 2024-11-27 15:52       ` Keith Busch
  0 siblings, 0 replies; 9+ messages in thread
From: Keith Busch @ 2024-11-27 15:52 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: sagi, axboe, linux-nvme, Saeed Mirzamohammadi

On Wed, Nov 27, 2024 at 04:48:12PM +0100, Christoph Hellwig wrote:
> On Wed, Nov 27, 2024 at 08:45:04AM -0700, Keith Busch wrote:
> > I still think this is wrong, and we should just remove the quirk for
> > this device. With the exception to this firmware version, this device
> > generally supports both discards and write zeroes. The only reason it
> > added this quirk was because the quirk used to mean something completely
> > different (specifically, it would set the "discard_zeroes_data"
> > attribute that's no longer used). It didn't mean to prefer discards over
> > write zeroes, but that's what it means now, and that's not what this
> > drive wants.
> 
> I'll have to trust you on this device, and certainly won't object
> removing this weirdo quick.  But as long as we don't remove the
> quirk entirely we'll also need this fix.  So I guess we should go
> for both?

Sure, that sounds good to me.


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

* Re: [PATCH] nvme: don't apply NVME_QUIRK_DEALLOCATE_ZEROES when DSM is not supported
  2024-11-27  6:42 ` [PATCH] nvme: don't apply NVME_QUIRK_DEALLOCATE_ZEROES when DSM is not supported Christoph Hellwig
                     ` (2 preceding siblings ...)
  2024-11-27 15:45   ` Keith Busch
@ 2024-12-02 17:54   ` Keith Busch
  2024-12-02 18:03     ` Saeed Mirzamohammadi
  3 siblings, 1 reply; 9+ messages in thread
From: Keith Busch @ 2024-12-02 17:54 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: sagi, axboe, linux-nvme, Saeed Mirzamohammadi

On Wed, Nov 27, 2024 at 07:42:18AM +0100, Christoph Hellwig wrote:
> Commit 63dfa1004322 ("nvme: move NVME_QUIRK_DEALLOCATE_ZEROES out of
> nvme_config_discard") started applying the NVME_QUIRK_DEALLOCATE_ZEROES
> quirk even then the Dataset Management is not supported.  It turns out
> that there versions of these old Intel SSDs that have DSM support
> disabled in the firmware, which will now lead to errors everytime
> a Write Zeroes command is issued.  Fix this by checking for DSM support
> before applying the quirk.
> 
> Reported-by: Saeed Mirzamohammadi <saeed.mirzamohammadi@oracle.com>
> Fixes: 63dfa1004322 ("nvme: move NVME_QUIRK_DEALLOCATE_ZEROES out of nvme_config_discard")
> Tested-by: Saeed Mirzamohammadi <saeed.mirzamohammadi@oracle.com>
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Thanks, applied to nvme-6.13.


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

* Re: [PATCH] nvme: don't apply NVME_QUIRK_DEALLOCATE_ZEROES when DSM is not supported
  2024-12-02 17:54   ` Keith Busch
@ 2024-12-02 18:03     ` Saeed Mirzamohammadi
  2024-12-02 18:08       ` Keith Busch
  0 siblings, 1 reply; 9+ messages in thread
From: Saeed Mirzamohammadi @ 2024-12-02 18:03 UTC (permalink / raw)
  To: Keith Busch
  Cc: Christoph Hellwig, Sagi Grimberg, Jens Axboe,
	linux-nvme@lists.infradead.org

Thanks! Can this be applied to 6.11+ stable releases as well since the broken commit is in 6.9.y?

Saeed

> On Dec 2, 2024, at 9:54 AM, Keith Busch <kbusch@kernel.org> wrote:
> 
> On Wed, Nov 27, 2024 at 07:42:18AM +0100, Christoph Hellwig wrote:
>> Commit 63dfa1004322 ("nvme: move NVME_QUIRK_DEALLOCATE_ZEROES out of
>> nvme_config_discard") started applying the NVME_QUIRK_DEALLOCATE_ZEROES
>> quirk even then the Dataset Management is not supported.  It turns out
>> that there versions of these old Intel SSDs that have DSM support
>> disabled in the firmware, which will now lead to errors everytime
>> a Write Zeroes command is issued.  Fix this by checking for DSM support
>> before applying the quirk.
>> 
>> Reported-by: Saeed Mirzamohammadi <saeed.mirzamohammadi@oracle.com>
>> Fixes: 63dfa1004322 ("nvme: move NVME_QUIRK_DEALLOCATE_ZEROES out of nvme_config_discard")
>> Tested-by: Saeed Mirzamohammadi <saeed.mirzamohammadi@oracle.com>
>> Signed-off-by: Christoph Hellwig <hch@lst.de>
> 
> Thanks, applied to nvme-6.13.


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

* Re: [PATCH] nvme: don't apply NVME_QUIRK_DEALLOCATE_ZEROES when DSM is not supported
  2024-12-02 18:03     ` Saeed Mirzamohammadi
@ 2024-12-02 18:08       ` Keith Busch
  0 siblings, 0 replies; 9+ messages in thread
From: Keith Busch @ 2024-12-02 18:08 UTC (permalink / raw)
  To: Saeed Mirzamohammadi
  Cc: Christoph Hellwig, Sagi Grimberg, Jens Axboe,
	linux-nvme@lists.infradead.org

On Mon, Dec 02, 2024 at 06:03:02PM +0000, Saeed Mirzamohammadi wrote:
> Thanks! Can this be applied to 6.11+ stable releases as well since the broken commit is in 6.9.y?

I don't think it can go to 6.9.y because it is not an LTS and that
branch appears to have already ended stable support.

Since this patch has the "Fixes" tag though, the stable auto patch
selection should grab it for the appropriate stable branches that are
still supported, so branches like 6.11.y and 6.6.y should get it. I'll
keep an eye out for it after the next pull request just to make sure.


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

end of thread, other threads:[~2024-12-02 19:13 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <CGME20241127152849epcas5p3872af708d33fbfb00fd3b703b879b273@epcas5p3.samsung.com>
2024-11-27  6:42 ` [PATCH] nvme: don't apply NVME_QUIRK_DEALLOCATE_ZEROES when DSM is not supported Christoph Hellwig
2024-11-27  7:48   ` Chaitanya Kulkarni
2024-11-27 15:20   ` Nitesh Shetty
2024-11-27 15:45   ` Keith Busch
2024-11-27 15:48     ` Christoph Hellwig
2024-11-27 15:52       ` Keith Busch
2024-12-02 17:54   ` Keith Busch
2024-12-02 18:03     ` Saeed Mirzamohammadi
2024-12-02 18:08       ` Keith Busch

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