nvmf: Require qpair disconnect to be performed from owning thread
I observed that spdk_nvmf_qpair_disconnect is only ever called from the thread that owns the qpair - i.e. the one associated with the poll group - with only one exception where the qpair wasn't fully initialized. Add a check that enforces this condition, as it will allow some major simplifications. Change-Id: Ied434c9ea63fd4f2a6f9eacdf8f3f26a7b6bcf3f Signed-off-by: Ben Walker <benjamin.walker@intel.com> Reviewed-on: https://review.gerrithub.io/424591 Reviewed-by: Seth Howell <seth.howell5141@gmail.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
This commit is contained in:
parent
8f5cd34671
commit
fd94895432
@ -723,16 +723,10 @@ _spdk_nvmf_qpair_deactivate(void *ctx)
|
|||||||
int
|
int
|
||||||
spdk_nvmf_qpair_disconnect(struct spdk_nvmf_qpair *qpair, nvmf_qpair_disconnect_cb cb_fn, void *ctx)
|
spdk_nvmf_qpair_disconnect(struct spdk_nvmf_qpair *qpair, nvmf_qpair_disconnect_cb cb_fn, void *ctx)
|
||||||
{
|
{
|
||||||
struct nvmf_qpair_disconnect_ctx *qpair_ctx = calloc(1, sizeof(struct nvmf_qpair_disconnect_ctx));
|
struct nvmf_qpair_disconnect_ctx *qpair_ctx;
|
||||||
|
|
||||||
if (!qpair_ctx) {
|
|
||||||
SPDK_ERRLOG("Unable to allocate context for nvmf_qpair_disconnect\n");
|
|
||||||
return -ENOMEM;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If we get a qpair in the uninitialized state, we can just destroy it immediately */
|
/* If we get a qpair in the uninitialized state, we can just destroy it immediately */
|
||||||
if (qpair->state == SPDK_NVMF_QPAIR_UNINITIALIZED) {
|
if (qpair->state == SPDK_NVMF_QPAIR_UNINITIALIZED) {
|
||||||
free(qpair_ctx);
|
|
||||||
spdk_nvmf_transport_qpair_fini(qpair);
|
spdk_nvmf_transport_qpair_fini(qpair);
|
||||||
if (cb_fn) {
|
if (cb_fn) {
|
||||||
cb_fn(ctx);
|
cb_fn(ctx);
|
||||||
@ -740,6 +734,16 @@ spdk_nvmf_qpair_disconnect(struct spdk_nvmf_qpair *qpair, nvmf_qpair_disconnect_
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* The queue pair must be disconnected from the thread that owns it */
|
||||||
|
assert(qpair->group->thread == spdk_get_thread());
|
||||||
|
|
||||||
|
qpair_ctx = calloc(1, sizeof(struct nvmf_qpair_disconnect_ctx));
|
||||||
|
|
||||||
|
if (!qpair_ctx) {
|
||||||
|
SPDK_ERRLOG("Unable to allocate context for nvmf_qpair_disconnect\n");
|
||||||
|
return -ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
qpair_ctx->qpair = qpair;
|
qpair_ctx->qpair = qpair;
|
||||||
qpair_ctx->cb_fn = cb_fn;
|
qpair_ctx->cb_fn = cb_fn;
|
||||||
qpair_ctx->thread = qpair->group->thread;
|
qpair_ctx->thread = qpair->group->thread;
|
||||||
|
Loading…
Reference in New Issue
Block a user