Commit 1068e22d authored by Ben Walker's avatar Ben Walker Committed by Darek Stojaczyk
Browse files

thread: spdk_free_thread now takes a thread parameter



Instead of implicitly grabbing the thread from the thread
local variable, make it explicit.

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


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: default avatarDarek Stojaczyk <dariusz.stojaczyk@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
parent aaa9a278
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -143,7 +143,7 @@ spdk_fio_cleanup_thread(struct spdk_fio_thread *fio_thread)

	spdk_set_thread(fio_thread->thread);

	spdk_free_thread();
	spdk_free_thread(fio_thread->thread);
	free(fio_thread->iocq);
	free(fio_thread);
}
+6 −3
Original line number Diff line number Diff line
@@ -199,12 +199,15 @@ void spdk_thread_lib_fini(void);
struct spdk_thread *spdk_allocate_thread(const char *name);

/**
 * Release any resources related to the calling thread for I/O channel allocation.
 * Release any resources related to the given thread and destroy it. Execution
 * continues on the current system thread after returning.
 *
 * All I/O channel references related to the calling thread must be released using
 * \param thread The thread to destroy.
 *
 * All I/O channel references associated with the thread must be released using
 * spdk_put_io_channel() prior to calling this function.
 */
void spdk_free_thread(void);
void spdk_free_thread(struct spdk_thread *thread);

/**
 * Perform one iteration worth of processing on the thread. This includes
+1 −1
Original line number Diff line number Diff line
@@ -355,7 +355,7 @@ _spdk_reactor_run(void *arg)

	spdk_set_thread(thread);
	_spdk_reactor_context_switch_monitor_stop(reactor, NULL);
	spdk_free_thread();
	spdk_free_thread(thread);
	return 0;
}

+5 −10
Original line number Diff line number Diff line
@@ -234,19 +234,16 @@ spdk_set_thread(struct spdk_thread *thread)
}

void
spdk_free_thread(void)
spdk_free_thread(struct spdk_thread *thread)
{
	struct spdk_thread *thread;
	struct spdk_io_channel *ch;

	thread = _get_thread();
	if (!thread) {
		SPDK_ERRLOG("No thread allocated\n");
		return;
	}

	SPDK_DEBUGLOG(SPDK_LOG_THREAD, "Freeing thread %s\n", thread->name);

	if (tls_thread == thread) {
		tls_thread = NULL;
	}

	TAILQ_FOREACH(ch, &thread->io_channels, tailq) {
		SPDK_ERRLOG("thread %s still has channel for io_device %s\n",
			    thread->name, ch->dev->name);
@@ -265,8 +262,6 @@ spdk_free_thread(void)
	}

	free(thread);

	tls_thread = NULL;
}

static inline uint32_t
+2 −1
Original line number Diff line number Diff line
@@ -103,7 +103,8 @@ free_threads(void)

	for (i = 0; i < g_ut_num_threads; i++) {
		set_thread(i);
		spdk_free_thread();
		spdk_free_thread(g_ut_threads[i].thread);
		g_ut_threads[i].thread = NULL;
	}

	g_ut_num_threads = 0;
Loading