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 <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/386102
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
Dariusz Stojaczyk 2017-11-07 20:23:21 +01:00 committed by Daniel Verkamp
parent aaa189ae7f
commit 4314d72505

View File

@ -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;