From 068b6fb34db814cff10b93a2ecbf5fe3f2d7ad70 Mon Sep 17 00:00:00 2001 From: Jim Harris Date: Thu, 1 Mar 2018 11:03:04 -0700 Subject: [PATCH] bdev/fio_plugin: flush any remaining events after done In some cases, an io_channel will be put (freed) as part of the last execution of a poller. Previously, the callback would set done=1 and would not continue executing events meaning the deferred put_io_channel events would not get executed. Signed-off-by: Jim Harris Change-Id: Ia5a6ea6873ceb1c3d5daf0545cdc3615d11712d2 Reviewed-on: https://review.gerrithub.io/402139 Tested-by: SPDK Automated Test System Reviewed-by: Changpeng Liu Reviewed-by: Daniel Verkamp --- examples/bdev/fio_plugin/fio_plugin.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/examples/bdev/fio_plugin/fio_plugin.c b/examples/bdev/fio_plugin/fio_plugin.c index 4f3094f1f..b4f465991 100644 --- a/examples/bdev/fio_plugin/fio_plugin.c +++ b/examples/bdev/fio_plugin/fio_plugin.c @@ -273,10 +273,18 @@ spdk_fio_init_env(struct thread_data *td) /* Initialize the bdev layer */ spdk_bdev_initialize(spdk_fio_bdev_init_done, &done); + /* First, poll until initialization is done. */ + do { + spdk_fio_poll_thread(fio_thread); + } while (!done); + + /* + * Continue polling until there are no more events. + * This handles any final events posted by pollers. + */ do { - /* Handle init and all cleanup events */ count = spdk_fio_poll_thread(fio_thread); - } while (!done || count > 0); + } while (count > 0); return 0; } @@ -677,16 +685,24 @@ spdk_fio_finish_env(void) spdk_bdev_finish(spdk_fio_module_finish_done, &done); + do { + spdk_fio_poll_thread(fio_thread); + } while (!done); + do { count = spdk_fio_poll_thread(fio_thread); - } while (!done || count > 0); + } while (count > 0); done = false; spdk_copy_engine_finish(spdk_fio_module_finish_done, &done); + do { + spdk_fio_poll_thread(fio_thread); + } while (!done); + do { count = spdk_fio_poll_thread(fio_thread); - } while (!done || count > 0); + } while (count > 0); spdk_fio_cleanup_thread(fio_thread); }