Commit 3741a852 authored by Jim Harris's avatar Jim Harris
Browse files

nvmf: simplify ctrlr_add_qpair_and_update_rsp code path



This prepares for upcoming patch to enable retrying
CONNECT commands when a duplicate QID is detected.

Most important part is moving the spdk_nvmf_request_complete
call into the ctrlr_add_qpair function.  This facilitates
deferring the spdk_nvmf_request_complete call when we want
to do a retry.

Note: for adding admin qpair, we now call
spdk_nvmf_request_complete instead of _nvmf_request_complete,
but this is actually no functional change.

Signed-off-by: default avatarJim Harris <james.r.harris@intel.com>
Change-Id: I1282be00441851ee2ed3c2dd281e68b4475d3d28
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/17361


Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <smatsumoto@nvidia.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
parent 3b54b0d7
Loading
Loading
Loading
Loading
+10 −7
Original line number Diff line number Diff line
@@ -210,16 +210,19 @@ nvmf_ctrlr_start_keep_alive_timer(struct spdk_nvmf_ctrlr *ctrlr)
}

static void
ctrlr_add_qpair_and_update_rsp(struct spdk_nvmf_qpair *qpair,
ctrlr_add_qpair_and_send_rsp(struct spdk_nvmf_qpair *qpair,
			     struct spdk_nvmf_ctrlr *ctrlr,
			       struct spdk_nvmf_fabric_connect_rsp *rsp)
			     struct spdk_nvmf_request *req)
{
	struct spdk_nvmf_fabric_connect_rsp *rsp = &req->rsp->connect_rsp;

	assert(ctrlr->admin_qpair->group->thread == spdk_get_thread());

	if (spdk_bit_array_get(ctrlr->qpair_mask, qpair->qid)) {
		SPDK_ERRLOG("Got I/O connect with duplicate QID %u\n", qpair->qid);
		rsp->status.sct = SPDK_NVME_SCT_COMMAND_SPECIFIC;
		rsp->status.sc = SPDK_NVME_SC_INVALID_QUEUE_IDENTIFIER;
		spdk_nvmf_request_complete(req);
		return;
	}

@@ -230,6 +233,7 @@ ctrlr_add_qpair_and_update_rsp(struct spdk_nvmf_qpair *qpair,
	rsp->status_code_specific.success.cntlid = ctrlr->cntlid;
	SPDK_DEBUGLOG(nvmf, "connect capsule response: cntlid = 0x%04x\n",
		      rsp->status_code_specific.success.cntlid);
	spdk_nvmf_request_complete(req);

	SPDK_DTRACE_PROBE4(nvmf_ctrlr_add_qpair, qpair, qpair->qid, ctrlr->subsys->subnqn,
			   ctrlr->hostnqn);
@@ -239,15 +243,13 @@ static void
_nvmf_ctrlr_add_admin_qpair(void *ctx)
{
	struct spdk_nvmf_request *req = ctx;
	struct spdk_nvmf_fabric_connect_rsp *rsp = &req->rsp->connect_rsp;
	struct spdk_nvmf_qpair *qpair = req->qpair;
	struct spdk_nvmf_ctrlr *ctrlr = qpair->ctrlr;

	ctrlr->admin_qpair = qpair;
	ctrlr->association_timeout = qpair->transport->opts.association_timeout;
	nvmf_ctrlr_start_keep_alive_timer(ctrlr);
	ctrlr_add_qpair_and_update_rsp(qpair, ctrlr, rsp);
	_nvmf_request_complete(req);
	ctrlr_add_qpair_and_send_rsp(qpair, ctrlr, req);
}

static void
@@ -592,7 +594,8 @@ nvmf_ctrlr_add_io_qpair(void *ctx)
		goto end;
	}

	ctrlr_add_qpair_and_update_rsp(qpair, ctrlr, rsp);
	ctrlr_add_qpair_and_send_rsp(qpair, ctrlr, req);
	return;
end:
	spdk_nvmf_request_complete(req);
}