event/subsystem: fix subsystem init failure handling

Deinitialize only those subsystem that
have been fully initialized.

Change-Id: I86cdd4cda0a80c107956843ed8198072e898a743
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/386892
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Dariusz Stojaczyk 2017-11-17 13:36:15 +01:00 committed by Jim Harris
parent d0a4c8e0a9
commit 5bdbe36ee9

View File

@ -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) {
g_next_subsystem = TAILQ_LAST(&g_subsystems, spdk_subsystem_list);
/* 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);
}