thread: Eliminate function pointers in spdk_allocate_thread
These are no longer used by anything. Change-Id: I0db6bc88e4dc945ff4f64df2ac410e1d00a669c1 Signed-off-by: Ben Walker <benjamin.walker@intel.com> Reviewed-on: https://review.gerrithub.io/c/437601 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
parent
11654a6065
commit
6728c4f4c0
@ -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");
|
||||
|
@ -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.
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user