Commit 13595495 authored by Shuhei Matsumoto's avatar Shuhei Matsumoto Committed by Tomasz Zawadzki
Browse files

lib/thread: Stop new I/O channel after thread is marked as exited



This is a preparation to support voluntary thread termination by
calling spdk_thread_exit().

By the last patch, the asynchronous release of I/O channel will
complete even after spdk_thread_exit() because pending messages will
be reaped.

Then this patch stops new allocation of I/O channel after
spdk_thread_exit().

Hence we will be able to release all I/O channels for exiting
thread within finite time.

Signed-off-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I48a45bcba7c4b2c62d8c9d398ac35a584b533627
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/821


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@mellanox.com>
parent d7393e2e
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -1140,6 +1140,12 @@ spdk_get_io_channel(void *io_device)
		return NULL;
	}

	if (spdk_unlikely(thread->exit)) {
		SPDK_ERRLOG("Thread %s is marked as exited\n", thread->name);
		pthread_mutex_unlock(&g_devlist_mutex);
		return NULL;
	}

	TAILQ_FOREACH(ch, &thread->io_channels, tailq) {
		if (ch->dev == dev) {
			ch->ref++;
+4 −0
Original line number Diff line number Diff line
@@ -801,6 +801,10 @@ thread_exit(void)
	thread = spdk_get_thread();
	spdk_thread_exit(thread);

	/* Thread will not be able to get I/O channel after it is marked as exited. */
	ch = spdk_get_io_channel(&g_device1);
	CU_ASSERT(ch == NULL);

	poll_threads();
	CU_ASSERT(g_destroy_cb_calls == 1);