Commit 4e331534 authored by Ziye Yang's avatar Ziye Yang Committed by Changpeng Liu
Browse files

event/subsystem: solve the subsystem init and destroy conflict



We have conflict to handle the NVMf subsystem shut
down. The situation is that:

If there is shutdown request (e.g., ctrlr+c),
we may have subsystem finalization and subsystem
initialization conflict (e.g., have NVMf subsystem fini and
intialization together), we will have coredump
issue like #682.

If we interrupt the initialization of the subsystem,
following works should do:

1  Do not initilize the next subsystem.
2  Recycle the resources in each subsystem via the
spdk_subsystem_fini related function. And this patch will
do the general thing, but will not consider the detailed
interrupt policy in each subsystem.

Change-Id: I2438b4a2462acb05d8c8e06dfff3da3d388d4b70
Signed-off-by: default avatarZiye Yang <ziye.yang@intel.com>
Reviewed-on: https://review.gerrithub.io/c/446189


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarSeth Howell <seth.howell5141@gmail.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
parent 1d29b231
Loading
Loading
Loading
Loading
+11 −5
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@ struct spdk_subsystem_list g_subsystems = TAILQ_HEAD_INITIALIZER(g_subsystems);
struct spdk_subsystem_depend_list g_subsystems_deps = TAILQ_HEAD_INITIALIZER(g_subsystems_deps);
static struct spdk_subsystem *g_next_subsystem;
static bool g_subsystems_initialized = false;
static bool g_subsystems_init_interrupted = false;
static struct spdk_event *g_app_start_event;
static struct spdk_event *g_app_stop_event;
static uint32_t g_fini_core;
@@ -116,6 +117,11 @@ subsystem_sort(void)
void
spdk_subsystem_init_next(int rc)
{
	/* The initialization is interrupted by the spdk_subsystem_fini, so just return */
	if (g_subsystems_init_interrupted) {
		return;
	}

	if (rc) {
		SPDK_ERRLOG("Init subsystem %s failed\n", g_next_subsystem->name);
		spdk_app_stop(rc);
@@ -190,11 +196,11 @@ _spdk_subsystem_fini_next(void *arg1, void *arg2)
			g_next_subsystem = TAILQ_LAST(&g_subsystems, spdk_subsystem_list);
		}
	} else {
		/* We rewind the g_next_subsystem unconditionally - even when some subsystem failed
		 * to initialize. It is assumed that subsystem which failed to initialize does not
		 * need to be deinitialized.
		 */
		if (g_subsystems_initialized || g_subsystems_init_interrupted) {
			g_next_subsystem = TAILQ_PREV(g_next_subsystem, spdk_subsystem_list, tailq);
		} else {
			g_subsystems_init_interrupted = true;
		}
	}

	while (g_next_subsystem) {