lib/nvmf: modify subsystem_state_change.

If we are already in the desired state,
just call the callback directly from the
subsystem_state_change function. That way
we save a lot of message passing.

Signed-off-by: Seth Howell <seth.howell@intel.com>
Change-Id: I6cf8563524610d9125d53266e3c0e179e064bf63
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/3760
Community-CI: Broadcom CI
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
This commit is contained in:
Seth Howell 2020-08-12 17:12:57 -07:00 committed by Tomasz Zawadzki
parent 8ff8bf0713
commit 848e9e2dd9

View File

@ -575,6 +575,15 @@ nvmf_subsystem_state_change(struct spdk_nvmf_subsystem *subsystem,
return -EBUSY;
}
/* If we are already in the requested state, just call the callback immediately. */
if (subsystem->state == requested_state) {
subsystem->changing_state = false;
if (cb_fn) {
cb_fn(subsystem, cb_arg, 0);
}
return 0;
}
intermediate_state = nvmf_subsystem_get_intermediate_state(subsystem->state, requested_state);
assert(intermediate_state != SPDK_NVMF_SUBSYSTEM_NUM_STATES);