Commit 5bdbe36e authored by Dariusz Stojaczyk's avatar Dariusz Stojaczyk Committed by Jim Harris
Browse files

event/subsystem: fix subsystem init failure handling



Deinitialize only those subsystem that
have been fully initialized.

Change-Id: I86cdd4cda0a80c107956843ed8198072e898a743
Signed-off-by: default avatarDariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/386892


Tested-by: default avatarSPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent d0a4c8e0
Loading
Loading
Loading
Loading
+13 −3
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ static TAILQ_HEAD(spdk_subsystem_list, spdk_subsystem) g_subsystems =
static TAILQ_HEAD(subsystem_depend, spdk_subsystem_depend) g_depends =
	TAILQ_HEAD_INITIALIZER(g_depends);
static struct spdk_subsystem *g_next_subsystem;
static bool g_subsystems_initialized = false;
static struct spdk_event *g_app_start_event;
static struct spdk_event *g_app_stop_event;
static uint32_t g_fini_core;
@@ -117,9 +118,8 @@ void
spdk_subsystem_init_next(int rc)
{
	if (rc) {
		spdk_app_stop(rc);
		assert(g_next_subsystem != NULL);
		SPDK_ERRLOG("Init subsystem %s failed\n", g_next_subsystem->name);
		spdk_app_stop(rc);
		return;
	}

@@ -130,6 +130,7 @@ spdk_subsystem_init_next(int rc)
	}

	if (!g_next_subsystem) {
		g_subsystems_initialized = true;
		spdk_event_call(g_app_start_event);
		return;
	}
@@ -183,8 +184,17 @@ _spdk_subsystem_fini_next(void *arg1, void *arg2)
	assert(g_fini_core == spdk_env_get_current_core());

	if (!g_next_subsystem) {
		/* If the initialized flag is false, then we've failed to initialize
		 * the very first subsystem and no de-init is needed
		 */
		if (g_subsystems_initialized) {
			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.
		 */
		g_next_subsystem = TAILQ_PREV(g_next_subsystem, spdk_subsystem_list, tailq);
	}