From 4314d72505e2b49adb4609a7bcc168c048bb3ce1 Mon Sep 17 00:00:00 2001 From: Dariusz Stojaczyk Date: Tue, 7 Nov 2017 20:23:21 +0100 Subject: [PATCH] fio_plugin: add spdk_fio_poll_thread Separated SPDK-related code from the FIO callback spdk_fio_getevents. This is required for upcoming patches. Change-Id: I8d30a3f910f29b13344df91fbbff51e00dfa0a0a Signed-off-by: Dariusz Stojaczyk Reviewed-on: https://review.gerrithub.io/386102 Tested-by: SPDK Automated Test System Reviewed-by: Jim Harris Reviewed-by: Daniel Verkamp Reviewed-by: Ben Walker --- examples/bdev/fio_plugin/fio_plugin.c | 37 +++++++++++++++++---------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/examples/bdev/fio_plugin/fio_plugin.c b/examples/bdev/fio_plugin/fio_plugin.c index 1b9a6289d..53dd6c435 100644 --- a/examples/bdev/fio_plugin/fio_plugin.c +++ b/examples/bdev/fio_plugin/fio_plugin.c @@ -534,6 +534,28 @@ spdk_fio_event(struct thread_data *td, int event) return fio_thread->iocq[event]; } +static size_t +spdk_fio_poll_thread(struct spdk_fio_thread *fio_thread) +{ + struct spdk_fio_msg *msg; + struct spdk_fio_poller *p, *tmp; + size_t count; + + /* Process new events */ + count = spdk_ring_dequeue(fio_thread->ring, (void **)&msg, 1); + if (count > 0) { + msg->cb_fn(msg->cb_arg); + free(msg); + } + + /* Call all pollers */ + TAILQ_FOREACH_SAFE(p, &fio_thread->pollers, link, tmp) { + p->cb_fn(p->cb_arg); + } + + return count; +} + static int spdk_fio_getevents(struct thread_data *td, unsigned int min, unsigned int max, const struct timespec *t) @@ -541,9 +563,6 @@ spdk_fio_getevents(struct thread_data *td, unsigned int min, struct spdk_fio_thread *fio_thread = td->io_ops_data; struct timespec t0, t1; uint64_t timeout = 0; - struct spdk_fio_msg *msg; - struct spdk_fio_poller *p, *tmp; - size_t count; if (t) { timeout = t->tv_sec * 1000000000L + t->tv_nsec; @@ -553,17 +572,7 @@ spdk_fio_getevents(struct thread_data *td, unsigned int min, fio_thread->iocq_count = 0; for (;;) { - /* Process new events */ - count = spdk_ring_dequeue(fio_thread->ring, (void **)&msg, 1); - if (count > 0) { - msg->cb_fn(msg->cb_arg); - free(msg); - } - - /* Call all pollers */ - TAILQ_FOREACH_SAFE(p, &fio_thread->pollers, link, tmp) { - p->cb_fn(p->cb_arg); - } + spdk_fio_poll_thread(fio_thread); if (fio_thread->iocq_count >= min) { return fio_thread->iocq_count;