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: Changpeng Liu <changpeng.liu@intel.com> Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15482 Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Shuhei Matsumoto <smatsumoto@nvidia.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Community-CI: Mellanox Build Bot
This commit is contained in:
parent
558638003a
commit
8c6de5ebfd
@ -1777,9 +1777,9 @@ vhost_user_dev_register(struct spdk_vhost_dev *vdev, const char *name, struct sp
|
|||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
vdev->registered = true;
|
|
||||||
user_dev->user_backend = user_backend;
|
user_dev->user_backend = user_backend;
|
||||||
user_dev->vdev = vdev;
|
user_dev->vdev = vdev;
|
||||||
|
user_dev->registered = true;
|
||||||
TAILQ_INIT(&user_dev->vsessions);
|
TAILQ_INIT(&user_dev->vsessions);
|
||||||
|
|
||||||
vhost_user_dev_set_coalescing(user_dev, SPDK_VHOST_COALESCING_DELAY_BASE_US,
|
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;
|
return -EBUSY;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vdev->registered && vhost_driver_unregister(vdev->path) != 0) {
|
/* There are no valid connections now, and it's not an error if the domain
|
||||||
SPDK_ERRLOG("Could not unregister controller %s with vhost library\n"
|
* socket was already removed by shutdown thread.
|
||||||
"Check if domain socket %s still exists\n",
|
*/
|
||||||
vdev->name, vdev->path);
|
vhost_driver_unregister(vdev->path);
|
||||||
return -EIO;
|
|
||||||
}
|
|
||||||
|
|
||||||
spdk_thread_send_msg(vdev->thread, vhost_dev_thread_exit, NULL);
|
spdk_thread_send_msg(vdev->thread, vhost_dev_thread_exit, NULL);
|
||||||
free(user_dev);
|
free(user_dev);
|
||||||
@ -1880,7 +1878,6 @@ vhost_user_session_shutdown(void *vhost_cb)
|
|||||||
}
|
}
|
||||||
spdk_vhost_unlock();
|
spdk_vhost_unlock();
|
||||||
vhost_driver_unregister(vdev->path);
|
vhost_driver_unregister(vdev->path);
|
||||||
vdev->registered = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SPDK_INFOLOG(vhost, "Exiting\n");
|
SPDK_INFOLOG(vhost, "Exiting\n");
|
||||||
|
@ -154,6 +154,8 @@ struct spdk_vhost_user_dev {
|
|||||||
uint32_t coalescing_delay_us;
|
uint32_t coalescing_delay_us;
|
||||||
uint32_t coalescing_iops_threshold;
|
uint32_t coalescing_iops_threshold;
|
||||||
|
|
||||||
|
bool registered;
|
||||||
|
|
||||||
/* Current connections to the device */
|
/* Current connections to the device */
|
||||||
TAILQ_HEAD(, spdk_vhost_session) vsessions;
|
TAILQ_HEAD(, spdk_vhost_session) vsessions;
|
||||||
|
|
||||||
@ -172,7 +174,6 @@ struct spdk_vhost_dev {
|
|||||||
char *path;
|
char *path;
|
||||||
|
|
||||||
struct spdk_thread *thread;
|
struct spdk_thread *thread;
|
||||||
bool registered;
|
|
||||||
|
|
||||||
uint64_t virtio_features;
|
uint64_t virtio_features;
|
||||||
uint64_t disabled_features;
|
uint64_t disabled_features;
|
||||||
|
Loading…
Reference in New Issue
Block a user