fio_plugin: poll all remaining events on thread shutdown
There were unprocessed events in the event ring at the time of destroying it's thread. Polling until *done* flag is set is not sufficient. Since a single fio_getevents call will poll only a single message, any message positioned after the callback that sets the *done* flag would not be processed. Change-Id: I8fee384cb980373672bed4bc498f75774aa64a9e Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com> Reviewed-on: https://review.gerrithub.io/385802 Tested-by: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
This commit is contained in:
parent
4314d72505
commit
8865e0bf51
@ -98,8 +98,7 @@ static bool g_spdk_env_initialized = false;
|
|||||||
|
|
||||||
static int spdk_fio_init(struct thread_data *td);
|
static int spdk_fio_init(struct thread_data *td);
|
||||||
static void spdk_fio_cleanup(struct thread_data *td);
|
static void spdk_fio_cleanup(struct thread_data *td);
|
||||||
static int spdk_fio_getevents(struct thread_data *td, unsigned int min,
|
static size_t spdk_fio_poll_thread(struct spdk_fio_thread *fio_thread);
|
||||||
unsigned int max, const struct timespec *t);
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
spdk_fio_send_msg(spdk_thread_fn fn, void *ctx, void *thread_ctx)
|
spdk_fio_send_msg(spdk_thread_fn fn, void *ctx, void *thread_ctx)
|
||||||
@ -219,11 +218,13 @@ spdk_fio_init_thread(struct thread_data *td)
|
|||||||
static int
|
static int
|
||||||
spdk_fio_init_env(struct thread_data *td)
|
spdk_fio_init_env(struct thread_data *td)
|
||||||
{
|
{
|
||||||
|
struct spdk_fio_thread *fio_thread;
|
||||||
struct spdk_fio_options *eo;
|
struct spdk_fio_options *eo;
|
||||||
bool done = false;
|
bool done = false;
|
||||||
int rc;
|
int rc;
|
||||||
struct spdk_conf *config;
|
struct spdk_conf *config;
|
||||||
struct spdk_env_opts opts;
|
struct spdk_env_opts opts;
|
||||||
|
size_t count;
|
||||||
|
|
||||||
/* Parse the SPDK configuration file */
|
/* Parse the SPDK configuration file */
|
||||||
eo = td->eo;
|
eo = td->eo;
|
||||||
@ -269,6 +270,8 @@ spdk_fio_init_env(struct thread_data *td)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fio_thread = td->io_ops_data;
|
||||||
|
|
||||||
/* Initialize the copy engine */
|
/* Initialize the copy engine */
|
||||||
spdk_copy_engine_initialize();
|
spdk_copy_engine_initialize();
|
||||||
|
|
||||||
@ -277,9 +280,10 @@ spdk_fio_init_env(struct thread_data *td)
|
|||||||
spdk_fio_start_poller,
|
spdk_fio_start_poller,
|
||||||
spdk_fio_stop_poller);
|
spdk_fio_stop_poller);
|
||||||
|
|
||||||
while (!done) {
|
do {
|
||||||
spdk_fio_getevents(td, 0, 128, NULL);
|
/* Handle init and all cleanup events */
|
||||||
}
|
count = spdk_fio_poll_thread(fio_thread);
|
||||||
|
} while (!done || count > 0);
|
||||||
|
|
||||||
/* Destroy the temporary SPDK thread */
|
/* Destroy the temporary SPDK thread */
|
||||||
spdk_fio_cleanup(td);
|
spdk_fio_cleanup(td);
|
||||||
@ -391,8 +395,6 @@ spdk_fio_cleanup(struct thread_data *td)
|
|||||||
struct spdk_fio_thread *fio_thread = td->io_ops_data;
|
struct spdk_fio_thread *fio_thread = td->io_ops_data;
|
||||||
struct spdk_fio_target *target, *tmp;
|
struct spdk_fio_target *target, *tmp;
|
||||||
|
|
||||||
g_thread = NULL;
|
|
||||||
|
|
||||||
TAILQ_FOREACH_SAFE(target, &fio_thread->targets, link, tmp) {
|
TAILQ_FOREACH_SAFE(target, &fio_thread->targets, link, tmp) {
|
||||||
TAILQ_REMOVE(&fio_thread->targets, target, link);
|
TAILQ_REMOVE(&fio_thread->targets, target, link);
|
||||||
spdk_put_io_channel(target->ch);
|
spdk_put_io_channel(target->ch);
|
||||||
@ -400,6 +402,10 @@ spdk_fio_cleanup(struct thread_data *td)
|
|||||||
free(target);
|
free(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
while (spdk_fio_poll_thread(fio_thread) > 0) {}
|
||||||
|
|
||||||
|
g_thread = NULL;
|
||||||
|
|
||||||
spdk_free_thread();
|
spdk_free_thread();
|
||||||
spdk_ring_free(fio_thread->ring);
|
spdk_ring_free(fio_thread->ring);
|
||||||
free(fio_thread->iocq);
|
free(fio_thread->iocq);
|
||||||
@ -665,9 +671,11 @@ spdk_fio_module_finish_done(void *cb_arg)
|
|||||||
static void
|
static void
|
||||||
spdk_fio_finish_env(void)
|
spdk_fio_finish_env(void)
|
||||||
{
|
{
|
||||||
|
struct spdk_fio_thread *fio_thread;
|
||||||
struct thread_data *td;
|
struct thread_data *td;
|
||||||
int rc;
|
int rc;
|
||||||
bool done = false;
|
bool done = false;
|
||||||
|
size_t count;
|
||||||
|
|
||||||
td = calloc(1, sizeof(*td));
|
td = calloc(1, sizeof(*td));
|
||||||
if (!td) {
|
if (!td) {
|
||||||
@ -682,18 +690,19 @@ spdk_fio_finish_env(void)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fio_thread = td->io_ops_data;
|
||||||
spdk_bdev_finish(spdk_fio_module_finish_done, &done);
|
spdk_bdev_finish(spdk_fio_module_finish_done, &done);
|
||||||
|
|
||||||
while (!done) {
|
do {
|
||||||
spdk_fio_getevents(td, 0, 128, NULL);
|
count = spdk_fio_poll_thread(fio_thread);
|
||||||
}
|
} while (!done || count > 0);
|
||||||
done = false;
|
|
||||||
|
|
||||||
|
done = false;
|
||||||
spdk_copy_engine_finish(spdk_fio_module_finish_done, &done);
|
spdk_copy_engine_finish(spdk_fio_module_finish_done, &done);
|
||||||
|
|
||||||
while (!done) {
|
do {
|
||||||
spdk_fio_getevents(td, 0, 128, NULL);
|
count = spdk_fio_poll_thread(fio_thread);
|
||||||
}
|
} while (!done || count > 0);
|
||||||
|
|
||||||
/* Destroy the temporary SPDK thread */
|
/* Destroy the temporary SPDK thread */
|
||||||
spdk_fio_cleanup(td);
|
spdk_fio_cleanup(td);
|
||||||
|
Loading…
Reference in New Issue
Block a user