Commit 85d70c03 authored by Jim Harris's avatar Jim Harris Committed by Tomasz Zawadzki
Browse files

thread: don't move to EXITED if there are pending messages



At end of spdk_thread_poll(), if thread is in EXITING state,
we call thread_exit() to see if the thread can move to
EXITED state.  If there are any pollers, io_channels
or pending device unregistrations in progress, thread_exit()
will keep the thread in EXITING mode for this iteration.

But a thread may post messages to itself during this cleanup
process, so thread_exit() should also check if there are
any messages on its queue.

Found during testing of spdk_thread lifetime patch set.
rbd bdev module will send messages to itself like this
during cleanup.  Without this change, rbd module testing
with bdevperf would cause an spdk_thread to move to
EXITED state prematurely.

Signed-off-by: default avatarJim Harris <james.r.harris@intel.com>
Change-Id: Ie611026a67b7fa48640ae83be03e29a9c64883a2
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15533


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@nvidia.com>
parent dcb296a3
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -523,6 +523,11 @@ thread_exit(struct spdk_thread *thread, uint64_t now)
		goto exited;
	}

	if (spdk_ring_count(thread->messages) > 0) {
		SPDK_INFOLOG(thread, "thread %s still has messages\n", thread->name);
		return;
	}

	TAILQ_FOREACH(poller, &thread->active_pollers, tailq) {
		if (poller->state != SPDK_POLLER_STATE_UNREGISTERED) {
			SPDK_INFOLOG(thread,