From fabf6a83ccaf1301a3261ea8691e75ef828b859f Mon Sep 17 00:00:00 2001 From: Changpeng Liu Date: Wed, 19 Oct 2022 11:19:33 +0800 Subject: [PATCH] lib/vhost: remove session `initialized` flag Session in vhost means an active socket connection from client(e.g: QEMU or SPDK vhost initiator), but the device state could be `started` or `stopped` because users may remove the driver of the device in VM, so in `foreach_session` we can always call the callback function without checking the session state, and the callback function may check the device state if necessary. Change-Id: Id0fc8c7f6f0915a55a738f0c87ebe6539f7fb2db Signed-off-by: Changpeng Liu Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15038 Community-CI: Mellanox Build Bot Reviewed-by: Ben Walker Reviewed-by: Jim Harris Tested-by: SPDK CI Jenkins --- lib/vhost/rte_vhost_user.c | 10 +++------- lib/vhost/vhost_internal.h | 1 - 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/lib/vhost/rte_vhost_user.c b/lib/vhost/rte_vhost_user.c index 249236351..682fa3f52 100644 --- a/lib/vhost/rte_vhost_user.c +++ b/lib/vhost/rte_vhost_user.c @@ -964,7 +964,6 @@ new_connection(int vid) return -1; } vsession->started = false; - vsession->initialized = false; vsession->next_stats_check_time = 0; vsession->stats_check_interval = SPDK_VHOST_STATS_CHECK_INTERVAL_MS * spdk_get_ticks_hz() / 1000UL; @@ -1144,7 +1143,6 @@ start_device(int vid) vdev = vsession->vdev; vhost_user_session_set_coalescing(vdev, vsession, NULL); - vsession->initialized = true; spdk_thread_send_msg(vdev->thread, vhost_user_session_start, vsession); out: @@ -1362,11 +1360,9 @@ foreach_session(void *arg1) } TAILQ_FOREACH(vsession, &to_user_dev(vdev)->vsessions, tailq) { - if (vsession->initialized) { - rc = ev_ctx->cb_fn(vdev, vsession, ev_ctx->user_ctx); - if (rc < 0) { - goto out; - } + rc = ev_ctx->cb_fn(vdev, vsession, ev_ctx->user_ctx); + if (rc < 0) { + goto out; } } diff --git a/lib/vhost/vhost_internal.h b/lib/vhost/vhost_internal.h index 1f03afede..149a84d1a 100644 --- a/lib/vhost/vhost_internal.h +++ b/lib/vhost/vhost_internal.h @@ -114,7 +114,6 @@ struct spdk_vhost_session { /* Unique session name. */ char *name; - bool initialized; bool started; bool interrupt_mode;