From d0cf194bc425cf018f3aab49df561c6874ae2cdd Mon Sep 17 00:00:00 2001 From: Changpeng Liu Date: Tue, 5 Jul 2022 15:04:14 +0800 Subject: [PATCH] nvmf/vfio-user: only relisten accept poller when connection is disconnected For the case `nvmf_subsystem_remove_listener` RPC call when VM is connected, we should not relisten the accept poller, because the endpoint will be destroyed for this case. Change-Id: Icf8299f26a3bbf7bbe44fd01edb4ede344692d25 Signed-off-by: Changpeng Liu Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/13548 Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins Reviewed-by: Jim Harris Reviewed-by: Ben Walker Reviewed-by: John Levon --- lib/nvmf/vfio_user.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/nvmf/vfio_user.c b/lib/nvmf/vfio_user.c index 5365e0fec..4bc967c48 100644 --- a/lib/nvmf/vfio_user.c +++ b/lib/nvmf/vfio_user.c @@ -417,6 +417,8 @@ struct nvmf_vfio_user_endpoint { * in source VM. */ bool need_resume; + /* Start the accept poller again after destroying the controller */ + bool need_relisten; TAILQ_ENTRY(nvmf_vfio_user_endpoint) link; }; @@ -4063,6 +4065,7 @@ vfio_user_register_accept_poller(struct nvmf_vfio_user_endpoint *endpoint) } endpoint->accept_thread = spdk_get_thread(); + endpoint->need_relisten = false; if (!spdk_interrupt_mode_is_enabled()) { return 0; @@ -4109,7 +4112,7 @@ _free_ctrlr(void *ctx) if (endpoint->need_async_destroy) { nvmf_vfio_user_destroy_endpoint(endpoint); - } else { + } else if (endpoint->need_relisten) { spdk_thread_send_msg(endpoint->accept_thread, _vfio_user_relisten, endpoint); } @@ -4662,6 +4665,7 @@ vfio_user_destroy_ctrlr(struct nvmf_vfio_user_ctrlr *ctrlr) assert(endpoint != NULL); pthread_mutex_lock(&endpoint->lock); + endpoint->need_relisten = true; if (TAILQ_EMPTY(&ctrlr->connected_sqs)) { endpoint->ctrlr = NULL; free_ctrlr(ctrlr);