nvmf: assert that subsystem cb_fn/cb_arg don't get set twice

nvmf_subsystem_state_change() protects against going
starting the pause/change/resume chain again if we
haven't completed the previous chain.  But add
some asserts to make sure the cb_fn and cb_args
never get set twice.  This also requires setting
them back to NULL after they've been used.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: I56c6c89bfb108223f731d5ac28100abbb746ab2f
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/5531
Community-CI: Broadcom CI
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
Jim Harris 2020-12-11 00:19:52 +00:00 committed by Tomasz Zawadzki
parent 392b07463b
commit 3e96796391
2 changed files with 4 additions and 0 deletions

View File

@ -3409,6 +3409,8 @@ _nvmf_request_complete(void *ctx)
sgroup->io_outstanding == 0) {
sgroup->state = SPDK_NVMF_SUBSYSTEM_PAUSED;
sgroup->cb_fn(sgroup->cb_arg, 0);
sgroup->cb_fn = NULL;
sgroup->cb_arg = NULL;
}
}

View File

@ -1424,7 +1424,9 @@ nvmf_poll_group_pause_subsystem(struct spdk_nvmf_poll_group *group,
sgroup->state = SPDK_NVMF_SUBSYSTEM_PAUSING;
if (sgroup->io_outstanding > 0) {
assert(sgroup->cb_fn == NULL);
sgroup->cb_fn = cb_fn;
assert(sgroup->cb_arg == NULL);
sgroup->cb_arg = cb_arg;
return;
}