Commit fd948954 authored by Ben Walker's avatar Ben Walker Committed by Jim Harris
Browse files

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: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/424591


Reviewed-by: default avatarSeth Howell <seth.howell5141@gmail.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
parent 8f5cd346
Loading
Loading
Loading
Loading
+11 −7
Original line number Diff line number Diff line
@@ -723,16 +723,10 @@ _spdk_nvmf_qpair_deactivate(void *ctx)
int
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));

	if (!qpair_ctx) {
		SPDK_ERRLOG("Unable to allocate context for nvmf_qpair_disconnect\n");
		return -ENOMEM;
	}
	struct nvmf_qpair_disconnect_ctx *qpair_ctx;

	/* If we get a qpair in the uninitialized state, we can just destroy it immediately */
	if (qpair->state == SPDK_NVMF_QPAIR_UNINITIALIZED) {
		free(qpair_ctx);
		spdk_nvmf_transport_qpair_fini(qpair);
		if (cb_fn) {
			cb_fn(ctx);
@@ -740,6 +734,16 @@ spdk_nvmf_qpair_disconnect(struct spdk_nvmf_qpair *qpair, nvmf_qpair_disconnect_
		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->cb_fn = cb_fn;
	qpair_ctx->thread = qpair->group->thread;