Commit 5d541746 authored by GangCao's avatar GangCao Committed by Tomasz Zawadzki
Browse files

nvmf: properly cleanup when failing to create subsystem



In the case of using CONF file, if two subsystems are assigned
with same subnqn, it fails at the second subsystem creation,
however the state machine is not set correctly.

The fix here is to properly set the state machine to roll back
the operations and destroy the created subsystem and exit the
application cleanly.

Change-Id: I4356802a12f7a2982485f61a69eceeb979033788
Signed-off-by: default avatarGangCao <gang.cao@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/476904


Community-CI: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent c3227517
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -93,12 +93,17 @@ _spdk_nvmf_shutdown_cb(void *arg1)
	if (g_tgt_state < NVMF_TGT_RUNNING) {
		spdk_thread_send_msg(spdk_get_thread(), _spdk_nvmf_shutdown_cb, NULL);
		return;
	} else if (g_tgt_state > NVMF_TGT_RUNNING) {
	} else if (g_tgt_state != NVMF_TGT_RUNNING && g_tgt_state != NVMF_TGT_ERROR) {
		/* Already in Shutdown status, ignore the signal */
		return;
	}

	if (g_tgt_state == NVMF_TGT_ERROR) {
		/* Parse configuration error */
		g_tgt_state = NVMF_TGT_FINI_FREE_RESOURCES;
	} else {
		g_tgt_state = NVMF_TGT_FINI_STOP_SUBSYSTEMS;
	}
	nvmf_tgt_advance_state();
}