Skip to content

Commit 7b210e4

Browse files
Christoph Hellwigaxboe
authored andcommitted
nvme: disable Write Zeroes for qemu controllers
Qemu started out with a broken implementation of Write Zeroes written by yours truly. Disable Write Zeroes on qemu for now, eventually we need to go back and make all the qemu quirks version specific, but that is left for another time. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Keith Busch <keith.busch@intel.com> Tested-by: Ming Lei <ming.lei@redhat.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 404ec31 commit 7b210e4

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

drivers/nvme/host/core.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1531,7 +1531,8 @@ static inline void nvme_config_write_zeroes(struct nvme_ns *ns)
15311531
u32 max_sectors;
15321532
unsigned short bs = 1 << ns->lba_shift;
15331533

1534-
if (!(ns->ctrl->oncs & NVME_CTRL_ONCS_WRITE_ZEROES))
1534+
if (!(ns->ctrl->oncs & NVME_CTRL_ONCS_WRITE_ZEROES) ||
1535+
(ns->ctrl->quirks & NVME_QUIRK_DISABLE_WRITE_ZEROES))
15351536
return;
15361537
/*
15371538
* Even though NVMe spec explicitly states that MDTS is not

drivers/nvme/host/nvme.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,11 @@ enum nvme_quirks {
8787
* Ignore device provided subnqn.
8888
*/
8989
NVME_QUIRK_IGNORE_DEV_SUBNQN = (1 << 8),
90+
91+
/*
92+
* Broken Write Zeroes.
93+
*/
94+
NVME_QUIRK_DISABLE_WRITE_ZEROES = (1 << 9),
9095
};
9196

9297
/*

drivers/nvme/host/pci.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2975,7 +2975,8 @@ static const struct pci_device_id nvme_id_table[] = {
29752975
{ PCI_VDEVICE(INTEL, 0xf1a6), /* Intel 760p/Pro 7600p */
29762976
.driver_data = NVME_QUIRK_IGNORE_DEV_SUBNQN, },
29772977
{ PCI_VDEVICE(INTEL, 0x5845), /* Qemu emulated controller */
2978-
.driver_data = NVME_QUIRK_IDENTIFY_CNS, },
2978+
.driver_data = NVME_QUIRK_IDENTIFY_CNS |
2979+
NVME_QUIRK_DISABLE_WRITE_ZEROES, },
29792980
{ PCI_DEVICE(0x1bb1, 0x0100), /* Seagate Nytro Flash Storage */
29802981
.driver_data = NVME_QUIRK_DELAY_BEFORE_CHK_RDY, },
29812982
{ PCI_DEVICE(0x1c58, 0x0003), /* HGST adapter */

0 commit comments

Comments
 (0)