From c4f0818bd324acb2c19efa995d170af5b46809db Mon Sep 17 00:00:00 2001 From: Ben Walker Date: Fri, 7 Dec 2018 13:30:44 -0700 Subject: [PATCH] fio: Perform bdev initialization inside a thread message This ensures that these calls are executed on an SPDK thread. Change-Id: I8cb4ee48c2f8bf4604e478e71e97bda856b6f0d0 Signed-off-by: Ben Walker Reviewed-on: https://review.gerrithub.io/436551 Tested-by: SPDK CI Jenkins Reviewed-by: Jim Harris Reviewed-by: Shuhei Matsumoto Chandler-Test-Pool: SPDK Automated Test System --- examples/bdev/fio_plugin/fio_plugin.c | 30 +++++++++++++++++---------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/examples/bdev/fio_plugin/fio_plugin.c b/examples/bdev/fio_plugin/fio_plugin.c index 32bf42587..c70b9f444 100644 --- a/examples/bdev/fio_plugin/fio_plugin.c +++ b/examples/bdev/fio_plugin/fio_plugin.c @@ -88,12 +88,6 @@ static size_t spdk_fio_poll_thread(struct spdk_fio_thread *fio_thread); /* Default polling timeout (us) */ #define SPDK_FIO_POLLING_TIMEOUT 1000000UL -static void -spdk_fio_bdev_init_done(void *cb_arg, int rc) -{ - *(bool *)cb_arg = true; -} - static int spdk_fio_init_thread(struct thread_data *td) { @@ -166,6 +160,24 @@ static pthread_mutex_t g_init_mtx = PTHREAD_MUTEX_INITIALIZER; static pthread_cond_t g_init_cond; static bool g_poll_loop = true; +static void +spdk_fio_bdev_init_done(void *cb_arg, int rc) +{ + *(bool *)cb_arg = true; +} + +static void +spdk_fio_bdev_init_start(void *arg) +{ + bool *done = arg; + + /* Initialize the copy engine */ + spdk_copy_engine_initialize(); + + /* Initialize the bdev layer */ + spdk_bdev_initialize(spdk_fio_bdev_init_done, done); +} + static void * spdk_init_thread_poll(void *arg) { @@ -240,14 +252,10 @@ spdk_init_thread_poll(void *arg) fio_thread = td.io_ops_data; - /* Initialize the copy engine */ - spdk_copy_engine_initialize(); - /* Initialize the bdev layer */ done = false; - spdk_bdev_initialize(spdk_fio_bdev_init_done, &done); + spdk_thread_send_msg(fio_thread->thread, spdk_fio_bdev_init_start, &done); - /* First, poll until initialization is done. */ do { spdk_fio_poll_thread(fio_thread); } while (!done);