Commit c3aaaa01 authored by Jim Harris's avatar Jim Harris Committed by Tomasz Zawadzki
Browse files

nvme: don't monitor hotplug events in secondary process



NVMe hotplug must be monitored in the primary process -
DPDK doesn't support trying to handle it in the
secondary process.

This issue was somewhat masked previously in secondary
processes, since usually it would just probe(NULL) which
meant probe all attached NVMe controllers.  So in the
secondary process, we would probe just once, and create
the hotplug fd - it would never actually try to monitor
it.

But when explicitly specifying multiple trids in a
secondary process, probe would get called multiple
times.  First time would be fine since it only creates
the hotplug fd.  But second time would segfault since
monitoring for hotplug requires checking the DPDK-allocated
context which doesn't exist in the secondary process.

Fixes issue #1063.

Signed-off-by: default avatarJim Harris <james.r.harris@intel.com>
Change-Id: I2a9a91e222c206034293d90e30e3f598c8d7baa8

Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/475015


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: default avatarAlexey Marchuk <alexeymar@mellanox.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
parent 27e88b8d
Loading
Loading
Loading
Loading
+8 −5
Original line number Diff line number Diff line
@@ -766,6 +766,8 @@ nvme_pcie_ctrlr_scan(struct spdk_nvme_probe_ctx *probe_ctx,
		enum_ctx.has_pci_addr = true;
	}

	/* Only the primary process can monitor hotplug. */
	if (spdk_process_is_primary()) {
		if (g_hotplug_fd < 0) {
			g_hotplug_fd = spdk_uevent_connect();
			if (g_hotplug_fd < 0) {
@@ -774,6 +776,7 @@ nvme_pcie_ctrlr_scan(struct spdk_nvme_probe_ctx *probe_ctx,
		} else {
			_nvme_pcie_hotplug_monitor(probe_ctx);
		}
	}

	if (enum_ctx.has_pci_addr == false) {
		return spdk_pci_enumerate(spdk_pci_nvme_get_driver(),