Commit de3eb36a authored by Changpeng Liu's avatar Changpeng Liu Committed by Jim Harris
Browse files

bdev/nvme: exit controller removal callback if the destruction was started



For real PCIe drives, if we removed one drive, existing hotplug
monitor will trigger the remove callback twice, there is one
workaround for vfio-attached device hot remove detection which
will also trigger the hot removal callback.  For now we add
the check in the bdev_nvme layer so that coredump will not happen.

Fix issue #606.

Change-Id: I0605fbdf391fed20c4aa9a2d54b4f059f29dc483
Signed-off-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-on: https://review.gerrithub.io/c/445642


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
parent 1e5b58a1
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -1099,6 +1099,11 @@ remove_cb(void *cb_ctx, struct spdk_nvme_ctrlr *ctrlr)
	pthread_mutex_lock(&g_bdev_nvme_mutex);
	TAILQ_FOREACH(nvme_ctrlr, &g_nvme_ctrlrs, tailq) {
		if (nvme_ctrlr->ctrlr == ctrlr) {
			/* The controller's destruction was already started */
			if (nvme_ctrlr->destruct) {
				pthread_mutex_unlock(&g_bdev_nvme_mutex);
				return;
			}
			pthread_mutex_unlock(&g_bdev_nvme_mutex);
			for (i = 0; i < nvme_ctrlr->num_ns; i++) {
				uint32_t	nsid = i + 1;
@@ -1111,7 +1116,6 @@ remove_cb(void *cb_ctx, struct spdk_nvme_ctrlr *ctrlr)
			}

			pthread_mutex_lock(&g_bdev_nvme_mutex);
			assert(!nvme_ctrlr->destruct);
			nvme_ctrlr->destruct = true;
			if (nvme_ctrlr->ref == 0) {
				pthread_mutex_unlock(&g_bdev_nvme_mutex);