Commit 8c6de5eb authored by Changpeng Liu's avatar Changpeng Liu
Browse files

lib/vhost: move `registered` flag to vhost-user device



Previously we use this flag to avoid to call `vhost_dev_unregister`
twice in `subsystem_fini`, but DPDK vhost library will check it,
we don't need this flag actually, but there is one race condition
between adding a new connection and unregistering the socket file
in different threads, so here we just move it to vhost-user device
as the first patch, and then use this flag in coming patch.

Change-Id: I658712dd20331a2e2eb5f4758bf76f748036a131
Signed-off-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15482


Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <smatsumoto@nvidia.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
parent 55863800
Loading
Loading
Loading
Loading
+5 −8
Original line number Diff line number Diff line
@@ -1777,9 +1777,9 @@ vhost_user_dev_register(struct spdk_vhost_dev *vdev, const char *name, struct sp
		return -EIO;
	}

	vdev->registered = true;
	user_dev->user_backend = user_backend;
	user_dev->vdev = vdev;
	user_dev->registered = true;
	TAILQ_INIT(&user_dev->vsessions);

	vhost_user_dev_set_coalescing(user_dev, SPDK_VHOST_COALESCING_DELAY_BASE_US,
@@ -1810,12 +1810,10 @@ vhost_user_dev_unregister(struct spdk_vhost_dev *vdev)
		return -EBUSY;
	}

	if (vdev->registered && vhost_driver_unregister(vdev->path) != 0) {
		SPDK_ERRLOG("Could not unregister controller %s with vhost library\n"
			    "Check if domain socket %s still exists\n",
			    vdev->name, vdev->path);
		return -EIO;
	}
	/* There are no valid connections now, and it's not an error if the domain
	 * socket was already removed by shutdown thread.
	 */
	vhost_driver_unregister(vdev->path);

	spdk_thread_send_msg(vdev->thread, vhost_dev_thread_exit, NULL);
	free(user_dev);
@@ -1880,7 +1878,6 @@ vhost_user_session_shutdown(void *vhost_cb)
		}
		spdk_vhost_unlock();
		vhost_driver_unregister(vdev->path);
		vdev->registered = false;
	}

	SPDK_INFOLOG(vhost, "Exiting\n");
+2 −1
Original line number Diff line number Diff line
@@ -154,6 +154,8 @@ struct spdk_vhost_user_dev {
	uint32_t coalescing_delay_us;
	uint32_t coalescing_iops_threshold;

	bool registered;

	/* Current connections to the device */
	TAILQ_HEAD(, spdk_vhost_session) vsessions;

@@ -172,7 +174,6 @@ struct spdk_vhost_dev {
	char *path;

	struct spdk_thread *thread;
	bool registered;

	uint64_t virtio_features;
	uint64_t disabled_features;