fio_plugin/bdev: Use thread context space for spdk_fio_thread

Instead of allocating this separately, use the thread context area.

Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Change-Id: I2d5f4d223b15ff663e57f52237b3cc4dab43c291
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/11865
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <smatsumoto@nvidia.com>
This commit is contained in:
Ben Walker 2022-03-09 10:26:13 -07:00 committed by Tomasz Zawadzki
parent 713333fdc9
commit c4f8bff2b3

View File

@ -133,23 +133,20 @@ static int
spdk_fio_init_thread(struct thread_data *td) spdk_fio_init_thread(struct thread_data *td)
{ {
struct spdk_fio_thread *fio_thread; struct spdk_fio_thread *fio_thread;
struct spdk_thread *thread;
fio_thread = calloc(1, sizeof(*fio_thread)); thread = spdk_thread_create("fio_thread", NULL);
if (!fio_thread) { if (!thread) {
SPDK_ERRLOG("failed to allocate thread local context\n");
return -1;
}
fio_thread->td = td;
td->io_ops_data = fio_thread;
fio_thread->thread = spdk_thread_create("fio_thread", NULL);
if (!fio_thread->thread) {
free(fio_thread);
SPDK_ERRLOG("failed to allocate thread\n"); SPDK_ERRLOG("failed to allocate thread\n");
return -1; return -1;
} }
spdk_set_thread(fio_thread->thread);
fio_thread = spdk_thread_get_ctx(thread);
fio_thread->td = td;
fio_thread->thread = thread;
td->io_ops_data = fio_thread;
spdk_set_thread(thread);
fio_thread->iocq_size = td->o.iodepth; fio_thread->iocq_size = td->o.iodepth;
fio_thread->iocq = calloc(fio_thread->iocq_size, sizeof(struct io_u *)); fio_thread->iocq = calloc(fio_thread->iocq_size, sizeof(struct io_u *));
@ -302,7 +299,7 @@ spdk_init_thread_poll(void *arg)
#endif #endif
} }
spdk_thread_lib_init(NULL, 0); spdk_thread_lib_init(NULL, sizeof(struct spdk_fio_thread));
/* Create an SPDK thread temporarily */ /* Create an SPDK thread temporarily */
rc = spdk_fio_init_thread(&td); rc = spdk_fio_init_thread(&td);
@ -387,9 +384,8 @@ spdk_init_thread_poll(void *arg)
TAILQ_FOREACH_SAFE(thread, &g_threads, link, tmp) { TAILQ_FOREACH_SAFE(thread, &g_threads, link, tmp) {
if (spdk_thread_is_exited(thread->thread)) { if (spdk_thread_is_exited(thread->thread)) {
TAILQ_REMOVE(&g_threads, thread, link); TAILQ_REMOVE(&g_threads, thread, link);
spdk_thread_destroy(thread->thread);
free(thread->iocq); free(thread->iocq);
free(thread); spdk_thread_destroy(thread->thread);
} else { } else {
spdk_thread_poll(thread->thread, 0, 0); spdk_thread_poll(thread->thread, 0, 0);
} }