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: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Change-Id: I48a45bcba7c4b2c62d8c9d398ac35a584b533627 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/821 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
This commit is contained in:
parent
d7393e2e4f
commit
13595495a1
@ -1140,6 +1140,12 @@ spdk_get_io_channel(void *io_device)
|
|||||||
return NULL;
|
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) {
|
TAILQ_FOREACH(ch, &thread->io_channels, tailq) {
|
||||||
if (ch->dev == dev) {
|
if (ch->dev == dev) {
|
||||||
ch->ref++;
|
ch->ref++;
|
||||||
|
@ -801,6 +801,10 @@ thread_exit(void)
|
|||||||
thread = spdk_get_thread();
|
thread = spdk_get_thread();
|
||||||
spdk_thread_exit(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();
|
poll_threads();
|
||||||
CU_ASSERT(g_destroy_cb_calls == 1);
|
CU_ASSERT(g_destroy_cb_calls == 1);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user