nvmf: Move QID error checks to common path

QIDs need to be validated for both I/O queues and admin
queues, so move the checking to a common path.

Change-Id: Icb2009b3fe4d70f146b741c046812d9df62cc2fb
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/413859
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
Ben Walker 2018-06-04 14:08:58 -07:00 committed by Jim Harris
parent b95fc6fc64
commit 4d58c1328a

View File

@ -76,6 +76,22 @@ ctrlr_add_qpair_and_update_rsp(struct spdk_nvmf_qpair *qpair,
struct spdk_nvmf_ctrlr *ctrlr,
struct spdk_nvmf_fabric_connect_rsp *rsp)
{
if (spdk_nvmf_ctrlr_get_qpair(ctrlr, 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;
return;
}
/* check if we would exceed ctrlr connection limit */
if (ctrlr->num_qpairs >= ctrlr->max_qpairs_allowed) {
SPDK_ERRLOG("qpair limit %d\n", ctrlr->num_qpairs);
rsp->status.sct = SPDK_NVME_SCT_COMMAND_SPECIFIC;
rsp->status.sc = SPDK_NVME_SC_INVALID_QUEUE_IDENTIFIER;
return;
}
qpair->ctrlr = ctrlr;
ctrlr->num_qpairs++;
TAILQ_INSERT_HEAD(&ctrlr->qpairs, qpair, link);
@ -211,7 +227,6 @@ static void
spdk_nvmf_ctrlr_add_io_qpair(void *ctx)
{
struct spdk_nvmf_request *req = ctx;
struct spdk_nvmf_fabric_connect_cmd *cmd = &req->cmd->connect_cmd;
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;
@ -247,21 +262,6 @@ spdk_nvmf_ctrlr_add_io_qpair(void *ctx)
goto end;
}
if (spdk_nvmf_ctrlr_get_qpair(ctrlr, cmd->qid)) {
SPDK_ERRLOG("Got I/O connect with duplicate QID %u\n", cmd->qid);
rsp->status.sct = SPDK_NVME_SCT_COMMAND_SPECIFIC;
rsp->status.sc = SPDK_NVME_SC_INVALID_QUEUE_IDENTIFIER;
goto end;
}
/* check if we would exceed ctrlr connection limit */
if (ctrlr->num_qpairs >= ctrlr->max_qpairs_allowed) {
SPDK_ERRLOG("qpair limit %d\n", ctrlr->num_qpairs);
rsp->status.sct = SPDK_NVME_SCT_COMMAND_SPECIFIC;
rsp->status.sc = SPDK_NVME_SC_INVALID_QUEUE_IDENTIFIER;
goto end;
}
ctrlr_add_qpair_and_update_rsp(qpair, ctrlr, rsp);
end: