From a658245f40ac342fa499876edf11842441e55c4c Mon Sep 17 00:00:00 2001 From: Dariusz Stojaczyk Date: Wed, 8 Nov 2017 15:53:32 +0100 Subject: [PATCH] fio_plugin: add persistent fio_thread for spdk init/finish This patch also replaces "temporary" SPDK threads for init/finish with a single persistent thread that's created at the time of init, and destroyed at the time of finish. Change-Id: I6da922cb50f06a9c31e22817d06c5dcbf19255b6 Signed-off-by: Dariusz Stojaczyk Reviewed-on: https://review.gerrithub.io/386247 Reviewed-by: Ben Walker Tested-by: SPDK Automated Test System Reviewed-by: Jim Harris Reviewed-by: Daniel Verkamp --- examples/bdev/fio_plugin/fio_plugin.c | 34 +++++++++------------------ 1 file changed, 11 insertions(+), 23 deletions(-) diff --git a/examples/bdev/fio_plugin/fio_plugin.c b/examples/bdev/fio_plugin/fio_plugin.c index d2a45f96e..5133d2086 100644 --- a/examples/bdev/fio_plugin/fio_plugin.c +++ b/examples/bdev/fio_plugin/fio_plugin.c @@ -285,9 +285,6 @@ spdk_fio_init_env(struct thread_data *td) count = spdk_fio_poll_thread(fio_thread); } while (!done || count > 0); - /* Destroy the temporary SPDK thread */ - spdk_fio_cleanup(td); - return 0; } @@ -390,9 +387,8 @@ spdk_fio_init(struct thread_data *td) } static void -spdk_fio_cleanup(struct thread_data *td) +spdk_fio_cleanup_thread(struct spdk_fio_thread *fio_thread) { - struct spdk_fio_thread *fio_thread = td->io_ops_data; struct spdk_fio_target *target, *tmp; TAILQ_FOREACH_SAFE(target, &fio_thread->targets, link, tmp) { @@ -410,7 +406,14 @@ spdk_fio_cleanup(struct thread_data *td) spdk_ring_free(fio_thread->ring); free(fio_thread->iocq); free(fio_thread); +} +static void +spdk_fio_cleanup(struct thread_data *td) +{ + struct spdk_fio_thread *fio_thread = td->io_ops_data; + + spdk_fio_cleanup_thread(fio_thread); td->io_ops_data = NULL; } @@ -672,25 +675,12 @@ static void spdk_fio_finish_env(void) { struct spdk_fio_thread *fio_thread; - struct thread_data *td; - int rc; bool done = false; size_t count; - td = calloc(1, sizeof(*td)); - if (!td) { - SPDK_ERRLOG("Unable to allocate thread_data\n"); - return; - } - /* Create an SPDK thread temporarily */ - rc = spdk_fio_init_thread(td); - if (rc < 0) { - SPDK_ERRLOG("Failed to create finish thread\n"); - free(td); - return; - } + /* the same thread that called spdk_fio_init_env */ + fio_thread = g_thread; - fio_thread = td->io_ops_data; spdk_bdev_finish(spdk_fio_module_finish_done, &done); do { @@ -704,9 +694,7 @@ spdk_fio_finish_env(void) count = spdk_fio_poll_thread(fio_thread); } while (!done || count > 0); - /* Destroy the temporary SPDK thread */ - spdk_fio_cleanup(td); - free(td); + spdk_fio_cleanup_thread(fio_thread); } static void fio_exit spdk_fio_unregister(void)