From 6fb6716d45fdcb015b23065e24a15d2d1aa78700 Mon Sep 17 00:00:00 2001 From: Ben Walker Date: Wed, 9 Mar 2022 10:34:54 -0700 Subject: [PATCH] fio_plugin/bdev: Support spdk_threads exiting at run time Now that the plugin supports SPDK-created spdk_threads, it needs to handle those threads being removed at run time. Signed-off-by: Ben Walker Change-Id: I8dee09bf95d1c8fe80f5793ee5476d3f3e1384fd Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/11867 Community-CI: Broadcom CI Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins Reviewed-by: Changpeng Liu Reviewed-by: Shuhei Matsumoto --- examples/bdev/fio_plugin/fio_plugin.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/examples/bdev/fio_plugin/fio_plugin.c b/examples/bdev/fio_plugin/fio_plugin.c index d4f4d3499..d1a08996c 100644 --- a/examples/bdev/fio_plugin/fio_plugin.c +++ b/examples/bdev/fio_plugin/fio_plugin.c @@ -359,7 +359,13 @@ spdk_init_thread_poll(void *arg) pthread_mutex_lock(&g_init_mtx); if (!TAILQ_EMPTY(&g_threads)) { TAILQ_FOREACH_SAFE(thread, &g_threads, link, tmp) { - spdk_fio_poll_thread(thread); + if (spdk_thread_is_exited(thread->thread)) { + TAILQ_REMOVE(&g_threads, thread, link); + free(thread->iocq); + spdk_thread_destroy(thread->thread); + } else { + spdk_fio_poll_thread(thread); + } } /* If there are exiting threads to poll, don't sleep. */