Skip to contentSkip to conversation

nvme: don't apply NVME_QUIRK_DEALLOCATE_ZEROES when DSM is not supported

PATCH Applied Christoph Hellwig 5 participants 9 messages Nov 27, 2024 – Dec 2, 2024 NVMe

lore
Share & tools
lore

Christoph Hellwig

author maintainer
#0 lore raw

PATCH 1/1 nvme: don't apply NVME_QUIRK_DEALLOCATE_ZEROES when DSM is not supported

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.

Fixes 63dfa1004322 ("nvme: move NVME_QUIRK_DEALLOCATE_ZEROES out of nvme_config_discard")
---
 drivers/nvme/host/core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/nvme/host/core.c +2 -1
index bfd71511c85f..5e5c9e15ad0c 100644
@@ -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;
Signature · 1 line
2.45.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Christoph Hellwig

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.

Quoted 4 lines
Fixes 63dfa1004322 ("nvme: move NVME_QUIRK_DEALLOCATE_ZEROES out of nvme_config_discard")

Looks good.

-ck

maintainer
#2 lore raw
In reply to Christoph Hellwig
Quoted 7 lines · Christoph Hellwig

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.

author maintainer
#3 lore raw
Quoted 8 lines · Keith Busch

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?

maintainer
#4 lore raw
Quoted 10 lines · Christoph Hellwig
Quoted 8 lines · Keith Busch

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.

Quoted 4 lines

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.

Reviewed-by on v1 1/1
#5 lore raw
In reply to Christoph Hellwig
Quoted 8 lines · Christoph Hellwig

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.

Quoted 5 lines
Fixes 63dfa1004322 ("nvme: move NVME_QUIRK_DEALLOCATE_ZEROES out of nvme_config_discard")

---

maintainer Applied
#6 lore raw
In reply to Christoph Hellwig
Quoted 8 lines · Christoph Hellwig

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.

Quoted 4 lines
Fixes 63dfa1004322 ("nvme: move NVME_QUIRK_DEALLOCATE_ZEROES out of nvme_config_discard")

Thanks, applied to nvme-6.13.

#7 lore raw

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

Saeed

Quoted 17 lines · Keith Busch
Quoted 8 lines · Christoph Hellwig

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.

Quoted 4 lines
Fixes 63dfa1004322 ("nvme: move NVME_QUIRK_DEALLOCATE_ZEROES out of nvme_config_discard")

Thanks, applied to nvme-6.13.

maintainer
#8 lore raw
Quoted 1 line · Saeed Mirzamohammadi

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.