linux/drivers/nvme/host
Michael Liang f21fb533fc nvme-tcp: fix premature queue removal and I/O failover
[ Upstream commit 77e40bbce9 ]

This patch addresses a data corruption issue observed in nvme-tcp during
testing.

In an NVMe native multipath setup, when an I/O timeout occurs, all
inflight I/Os are canceled almost immediately after the kernel socket is
shut down. These canceled I/Os are reported as host path errors,
triggering a failover that succeeds on a different path.

However, at this point, the original I/O may still be outstanding in the
host's network transmission path (e.g., the NIC’s TX queue). From the
user-space app's perspective, the buffer associated with the I/O is
considered completed since they're acked on the different path and may
be reused for new I/O requests.

Because nvme-tcp enables zero-copy by default in the transmission path,
this can lead to corrupted data being sent to the original target,
ultimately causing data corruption.

We can reproduce this data corruption by injecting delay on one path and
triggering i/o timeout.

To prevent this issue, this change ensures that all inflight
transmissions are fully completed from host's perspective before
returning from queue stop. To handle concurrent I/O timeout from multiple
namespaces under the same controller, always wait in queue stop
regardless of queue's state.

This aligns with the behavior of queue stopping in other NVMe fabric
transports.

Fixes: 3f2304f8c6 ("nvme-tcp: add NVMe over TCP host driver")
Signed-off-by: Michael Liang <mliang@purestorage.com>
Reviewed-by: Mohamed Khalfella <mkhalfella@purestorage.com>
Reviewed-by: Randy Jennings <randyj@purestorage.com>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
History 2025-05-09 09:39:40 +02:00
..
core.c nvme: fixup scan failure for non-ANA multipath controllers 2025-05-02 07:44:40 +02:00
fabrics.c nvme-fabrics: remove superfluous nvmf_host_put in nvmf_parse_options 2021-08-16 14:42:23 +02:00
fabrics.h nvme-fabrics: fix state check in nvmf_ctlr_matches_baseopts() 2022-02-08 18:34:05 +01:00
fault_inject.c nvme: enable to inject errors into admin commands 2019-06-21 11:15:50 +02:00
fc.c nvme-fc: go straight to connecting state when initializing 2025-04-10 14:31:49 +02:00
fc.h nvme-fc: Update header and host for common definitions for LS handling 2020-05-09 16:18:33 -06:00
hwmon.c nvme-pci: add quirk for missing secondary temperature thresholds 2023-06-09 10:32:22 +02:00
ioctl.c nvme/ioctl: add missing space in err message 2025-03-13 12:50:53 +01:00
Kconfig nvme: Have NVME_FABRICS select NVME_CORE instead of transport drivers 2021-08-16 21:03:18 +02:00
Makefile remove the lightnvm subsystem 2021-08-14 15:54:09 -06:00
multipath.c nvme-multipath: find NUMA path only for online numa-node 2024-07-18 13:07:35 +02:00
nvme.h nvme-pci: qdepth 1 quirk 2024-10-17 15:11:25 +02:00
pci.c nvme-pci: skip CMB blocks incompatible with PCI P2P DMA 2025-04-10 14:32:03 +02:00
rdma.c nvme-rdma: do not try to stop unallocated queues 2023-10-25 11:59:02 +02:00
tcp.c nvme-tcp: fix premature queue removal and I/O failover 2025-05-09 09:39:40 +02:00
trace.c nvme: add set feature tracing support 2021-08-16 14:42:23 +02:00
trace.h nvme: fix async event trace event 2023-05-11 23:00:28 +09:00
zns.c nvme: split nvme_report_zones 2021-06-03 10:29:26 +03:00