Commit 6728c4f4 authored by Ben Walker's avatar Ben Walker Committed by Darek Stojaczyk
Browse files

thread: Eliminate function pointers in spdk_allocate_thread



These are no longer used by anything.

Change-Id: I0db6bc88e4dc945ff4f64df2ac410e1d00a669c1
Signed-off-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/c/437601


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarDarek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
parent 11654a60
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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");
+1 −15
Original line number Diff line number Diff line
@@ -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.
+1 −1
Original line number Diff line number Diff line
@@ -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;
	}
+1 −1
Original line number Diff line number Diff line
@@ -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);
	}
+1 −32
Original line number Diff line number Diff line
@@ -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
Loading