diff --git a/examples/bdev/fio_plugin/fio_plugin.c b/examples/bdev/fio_plugin/fio_plugin.c index e7d48875e..f88709359 100644 --- a/examples/bdev/fio_plugin/fio_plugin.c +++ b/examples/bdev/fio_plugin/fio_plugin.c @@ -104,7 +104,7 @@ spdk_fio_init_thread(struct thread_data *td) fio_thread->td = td; td->io_ops_data = fio_thread; - fio_thread->thread = spdk_allocate_thread(NULL, NULL, NULL, NULL, "fio_thread"); + fio_thread->thread = spdk_allocate_thread("fio_thread"); if (!fio_thread->thread) { free(fio_thread); SPDK_ERRLOG("failed to allocate thread\n"); diff --git a/include/spdk/thread.h b/include/spdk/thread.h index a9e5fd44c..a40146c0e 100644 --- a/include/spdk/thread.h +++ b/include/spdk/thread.h @@ -178,27 +178,13 @@ void spdk_thread_lib_fini(void); /** * Initializes the calling thread for I/O channel allocation. * - * \param msg_fn A function that may be called from any thread and is passed a function - * pointer (spdk_msg_fn) that must be called on the same thread that spdk_allocate_thread - * was called from. - * DEPRECATED. Only used in tests. Pass NULL for this parameter. - * \param start_poller_fn Function to be called to start a poller for the thread. - * DEPRECATED. Only used in tests. Pass NULL for this parameter. - * \param stop_poller_fn Function to be called to stop a poller for the thread. - * DEPRECATED. Only used in tests. Pass NULL for this parameter. - * \param thread_ctx Context that will be passed to msg_fn, start_poller_fn, and stop_poller_fn. - * DEPRECATED. Only used in tests. Pass NULL for this parameter. * \param name Human-readable name for the thread; can be retrieved with spdk_thread_get_name(). * The string is copied, so the pointed-to data only needs to be valid during the * spdk_allocate_thread() call. May be NULL to specify no name. * * \return a pointer to the allocated thread on success or NULL on failure.. */ -struct spdk_thread *spdk_allocate_thread(spdk_thread_pass_msg msg_fn, - spdk_start_poller start_poller_fn, - spdk_stop_poller stop_poller_fn, - void *thread_ctx, - const char *name); +struct spdk_thread *spdk_allocate_thread(const char *name); /** * Release any resources related to the calling thread for I/O channel allocation. diff --git a/lib/event/reactor.c b/lib/event/reactor.c index 2da8301f6..b53a21a6f 100644 --- a/lib/event/reactor.c +++ b/lib/event/reactor.c @@ -291,7 +291,7 @@ _spdk_reactor_run(void *arg) char thread_name[32]; snprintf(thread_name, sizeof(thread_name), "reactor_%u", reactor->lcore); - thread = spdk_allocate_thread(NULL, NULL, NULL, NULL, thread_name); + thread = spdk_allocate_thread(thread_name); if (!thread) { return -1; } diff --git a/lib/rocksdb/env_spdk.cc b/lib/rocksdb/env_spdk.cc index 0da04ae79..5b0f6a59b 100644 --- a/lib/rocksdb/env_spdk.cc +++ b/lib/rocksdb/env_spdk.cc @@ -584,7 +584,7 @@ void SpdkInitializeThread(void) struct spdk_thread *thread; if (g_fs != NULL) { - thread = spdk_allocate_thread(NULL, NULL, NULL, NULL, "spdk_rocksdb"); + thread = spdk_allocate_thread("spdk_rocksdb"); spdk_set_thread(thread); g_sync_args.channel = spdk_fs_alloc_io_channel_sync(g_fs); } diff --git a/lib/thread/thread.c b/lib/thread/thread.c index 4dc980559..3f4f14146 100644 --- a/lib/thread/thread.c +++ b/lib/thread/thread.c @@ -103,10 +103,6 @@ struct spdk_poller { }; struct spdk_thread { - spdk_thread_pass_msg msg_fn; - spdk_start_poller start_poller_fn; - spdk_stop_poller stop_poller_fn; - void *thread_ctx; TAILQ_HEAD(, spdk_io_channel) io_channels; TAILQ_ENTRY(spdk_thread) tailq; char *name; @@ -184,10 +180,7 @@ spdk_thread_lib_fini(void) } struct spdk_thread * -spdk_allocate_thread(spdk_thread_pass_msg msg_fn, - spdk_start_poller start_poller_fn, - spdk_stop_poller stop_poller_fn, - void *thread_ctx, const char *name) +spdk_allocate_thread(const char *name) { struct spdk_thread *thread; @@ -197,22 +190,12 @@ spdk_allocate_thread(spdk_thread_pass_msg msg_fn, return NULL; } - if ((start_poller_fn != NULL && stop_poller_fn == NULL) || - (start_poller_fn == NULL && stop_poller_fn != NULL)) { - SPDK_ERRLOG("start_poller_fn and stop_poller_fn must either both be NULL or both be non-NULL\n"); - return NULL; - } - thread = calloc(1, sizeof(*thread)); if (!thread) { SPDK_ERRLOG("Unable to allocate memory for thread\n"); return NULL; } - thread->msg_fn = msg_fn; - thread->start_poller_fn = start_poller_fn; - thread->stop_poller_fn = stop_poller_fn; - thread->thread_ctx = thread_ctx; TAILQ_INIT(&thread->io_channels); TAILQ_INIT(&thread->active_pollers); TAILQ_INIT(&thread->timer_pollers); @@ -479,11 +462,6 @@ spdk_thread_send_msg(const struct spdk_thread *thread, spdk_msg_fn fn, void *ctx return; } - if (thread->msg_fn) { - thread->msg_fn(fn, ctx, thread->thread_ctx); - return; - } - msg = spdk_mempool_get(g_spdk_msg_mempool); if (!msg) { assert(false); @@ -516,10 +494,6 @@ spdk_poller_register(spdk_poller_fn fn, return NULL; } - if (thread->start_poller_fn) { - return thread->start_poller_fn(thread->thread_ctx, fn, arg, period_microseconds); - } - poller = calloc(1, sizeof(*poller)); if (poller == NULL) { SPDK_ERRLOG("Poller memory allocation failed\n"); @@ -568,11 +542,6 @@ spdk_poller_unregister(struct spdk_poller **ppoller) return; } - if (thread->stop_poller_fn) { - thread->stop_poller_fn(poller, thread->thread_ctx); - return; - } - if (poller->state == SPDK_POLLER_STATE_RUNNING) { /* * We are being called from the poller_fn, so set the state to unregistered diff --git a/test/common/lib/ut_multithread.c b/test/common/lib/ut_multithread.c index 51420bba3..c559751ce 100644 --- a/test/common/lib/ut_multithread.c +++ b/test/common/lib/ut_multithread.c @@ -87,7 +87,7 @@ allocate_threads(int num_threads) for (i = 0; i < g_ut_num_threads; i++) { set_thread(i); - thread = spdk_allocate_thread(NULL, NULL, NULL, NULL, NULL); + thread = spdk_allocate_thread(NULL); assert(thread != NULL); g_ut_threads[i].thread = thread; } diff --git a/test/unit/lib/blobfs/blobfs_sync_ut/blobfs_sync_ut.c b/test/unit/lib/blobfs/blobfs_sync_ut/blobfs_sync_ut.c index 34c5ca0bb..2caa65509 100644 --- a/test/unit/lib/blobfs/blobfs_sync_ut/blobfs_sync_ut.c +++ b/test/unit/lib/blobfs/blobfs_sync_ut/blobfs_sync_ut.c @@ -374,7 +374,7 @@ spdk_thread(void *arg) struct spdk_thread *thread; struct ut_request *req; - thread = spdk_allocate_thread(NULL, NULL, NULL, NULL, "thread1"); + thread = spdk_allocate_thread("thread1"); spdk_set_thread(thread); while (1) { @@ -428,7 +428,7 @@ int main(int argc, char **argv) return CU_get_error(); } - thread = spdk_allocate_thread(NULL, NULL, NULL, NULL, "thread0"); + thread = spdk_allocate_thread("thread0"); spdk_set_thread(thread); pthread_create(&spdk_tid, NULL, spdk_thread, NULL); diff --git a/test/unit/lib/nvmf/tcp.c/tcp_ut.c b/test/unit/lib/nvmf/tcp.c/tcp_ut.c index 18037dc23..ed431bee8 100644 --- a/test/unit/lib/nvmf/tcp.c/tcp_ut.c +++ b/test/unit/lib/nvmf/tcp.c/tcp_ut.c @@ -204,7 +204,7 @@ test_nvmf_tcp_create(void) struct spdk_nvmf_tcp_transport *ttransport; struct spdk_nvmf_transport_opts opts; - thread = spdk_allocate_thread(NULL, NULL, NULL, NULL, NULL); + thread = spdk_allocate_thread(NULL); SPDK_CU_ASSERT_FATAL(thread != NULL); spdk_set_thread(thread); @@ -276,7 +276,7 @@ test_nvmf_tcp_destroy(void) struct spdk_nvmf_transport *transport; struct spdk_nvmf_transport_opts opts; - thread = spdk_allocate_thread(NULL, NULL, NULL, NULL, NULL); + thread = spdk_allocate_thread(NULL); SPDK_CU_ASSERT_FATAL(thread != NULL); spdk_set_thread(thread); @@ -304,7 +304,7 @@ test_nvmf_tcp_poll_group_create(void) struct spdk_nvmf_transport_poll_group *group; struct spdk_thread *thread; - thread = spdk_allocate_thread(NULL, NULL, NULL, NULL, NULL); + thread = spdk_allocate_thread(NULL); SPDK_CU_ASSERT_FATAL(thread != NULL); spdk_set_thread(thread); diff --git a/test/unit/lib/thread/thread.c/thread_ut.c b/test/unit/lib/thread/thread.c/thread_ut.c index 7b17737be..9d999a19b 100644 --- a/test/unit/lib/thread/thread.c/thread_ut.c +++ b/test/unit/lib/thread/thread.c/thread_ut.c @@ -345,7 +345,7 @@ thread_name(void) const char *name; /* Create thread with no name, which automatically generates one */ - thread = spdk_allocate_thread(NULL, NULL, NULL, NULL, NULL); + thread = spdk_allocate_thread(NULL); spdk_set_thread(thread); thread = spdk_get_thread(); SPDK_CU_ASSERT_FATAL(thread != NULL); @@ -354,7 +354,7 @@ thread_name(void) spdk_free_thread(); /* Create thread named "test_thread" */ - thread = spdk_allocate_thread(NULL, NULL, NULL, NULL, "test_thread"); + thread = spdk_allocate_thread("test_thread"); spdk_set_thread(thread); thread = spdk_get_thread(); SPDK_CU_ASSERT_FATAL(thread != NULL);