lib/nvmf: handle the failed case when activating the subsystem

In the case of failing to spdk_nvmf_poll_group_add_subsystem()
operation, the subsystem still needs to initialize the related
queue so that later coming request can be properly queued.

Also needs to correctly handle the expected state in this failed
condition so that when destroying the subsystem, it could be
properly handled.

Change-Id: I419f2ac7164c25258c3911952c38b9433fca762b
Signed-off-by: GangCao <gang.cao@intel.com>
Reviewed-on: https://review.gerrithub.io/422799
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
GangCao 2018-08-20 18:48:27 -04:00 committed by Jim Harris
parent 1791ccfd4f
commit da01835d84
2 changed files with 9 additions and 3 deletions

View File

@ -883,17 +883,18 @@ spdk_nvmf_poll_group_add_subsystem(struct spdk_nvmf_poll_group *group,
struct spdk_nvmf_subsystem *subsystem,
spdk_nvmf_poll_group_mod_done cb_fn, void *cb_arg)
{
struct spdk_nvmf_subsystem_poll_group *sgroup;
int rc = 0;
struct spdk_nvmf_subsystem_poll_group *sgroup = &group->sgroups[subsystem->id];
TAILQ_INIT(&sgroup->queued);
rc = poll_group_update_subsystem(group, subsystem);
if (rc) {
sgroup->state = SPDK_NVMF_SUBSYSTEM_INACTIVE;
goto fini;
}
sgroup = &group->sgroups[subsystem->id];
sgroup->state = SPDK_NVMF_SUBSYSTEM_ACTIVE;
TAILQ_INIT(&sgroup->queued);
fini:
if (cb_fn) {
cb_fn(cb_arg, rc);

View File

@ -389,6 +389,11 @@ spdk_nvmf_subsystem_set_state(struct spdk_nvmf_subsystem *subsystem,
state == SPDK_NVMF_SUBSYSTEM_ACTIVE) {
expected_old_state = SPDK_NVMF_SUBSYSTEM_RESUMING;
}
/* This is for the case when activating the subsystem fails. */
if (actual_old_state == SPDK_NVMF_SUBSYSTEM_ACTIVATING &&
state == SPDK_NVMF_SUBSYSTEM_DEACTIVATING) {
expected_old_state = SPDK_NVMF_SUBSYSTEM_ACTIVATING;
}
actual_old_state = __sync_val_compare_and_swap(&subsystem->state, expected_old_state, state);
}
assert(actual_old_state == expected_old_state);