From 2e6ec373bf019f1dcebb8e074c29870f6fab9e6e Mon Sep 17 00:00:00 2001 From: Ziye Yang Date: Tue, 29 Nov 2016 13:18:30 +0800 Subject: [PATCH] nvme/rdma: fix the I/O qpair creation issue Change-Id: I357f4a83736977d319175445b4d65443f57b2c6f Signed-off-by: Ziye Yang --- include/spdk/nvme.h | 2 +- lib/nvme/nvme_pcie.c | 3 +++ lib/nvme/nvme_rdma.c | 21 ++++++++++++++++----- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/include/spdk/nvme.h b/include/spdk/nvme.h index a271786e72..2b956c59ce 100644 --- a/include/spdk/nvme.h +++ b/include/spdk/nvme.h @@ -99,7 +99,7 @@ struct spdk_nvme_ctrlr_opts { /** * The queue depth of each NVMe I/O queue. */ - int queue_size; + uint32_t queue_size; }; /** diff --git a/lib/nvme/nvme_pcie.c b/lib/nvme/nvme_pcie.c index 85bc379275..70b208d504 100644 --- a/lib/nvme/nvme_pcie.c +++ b/lib/nvme/nvme_pcie.c @@ -1302,6 +1302,9 @@ nvme_pcie_ctrlr_create_io_qpair(struct spdk_nvme_ctrlr *ctrlr, uint16_t qid, */ num_entries = nvme_min(NVME_IO_ENTRIES, ctrlr->cap.bits.mqes + 1); + /* Also should choose minmal between original and the value passed by users */ + num_entries = nvme_min(num_entries, ctrlr->opts.queue_size); + rc = nvme_qpair_construct(qpair, qid, num_entries, ctrlr, qprio); if (rc != 0) { spdk_free(pqpair); diff --git a/lib/nvme/nvme_rdma.c b/lib/nvme/nvme_rdma.c index 0b0ab5f870..669a559a98 100644 --- a/lib/nvme/nvme_rdma.c +++ b/lib/nvme/nvme_rdma.c @@ -63,6 +63,8 @@ #define NVME_HOST_ID_DEFAULT "12345679890" #define NVME_HOST_NQN "nqn.2016-06.io.spdk:host" +#define NVME_HOST_MAX_ENTRIES_PER_QUEUE (127) + /* NVME RDMA qpair Resouce Defaults */ @@ -788,10 +790,17 @@ nvme_rdma_qpair_fabric_connect(struct nvme_rdma_qpair *rqpair) strncpy((char *)nvmf_data->hostnqn, NVME_HOST_NQN, sizeof(nvmf_data->hostnqn)); strncpy((char *)nvmf_data->subnqn, ctrlr->probe_info.nqn, sizeof(nvmf_data->subnqn)); - rc = spdk_nvme_ctrlr_cmd_admin_raw(ctrlr, - (struct spdk_nvme_cmd *)&cmd, - nvmf_data, sizeof(*nvmf_data), - nvme_completion_poll_cb, &status); + if (nvme_qpair_is_admin_queue(&rqpair->qpair)) { + rc = spdk_nvme_ctrlr_cmd_admin_raw(ctrlr, + (struct spdk_nvme_cmd *)&cmd, + nvmf_data, sizeof(*nvmf_data), + nvme_completion_poll_cb, &status); + } else { + rc = spdk_nvme_ctrlr_cmd_io_raw(ctrlr, &rqpair->qpair, + (struct spdk_nvme_cmd *)&cmd, + nvmf_data, sizeof(*nvmf_data), + nvme_completion_poll_cb, &status); + } if (rc < 0) { SPDK_ERRLOG("spdk_nvme_rdma_req_fabric_connect failed\n"); @@ -948,7 +957,9 @@ nvme_rdma_ctrlr_create_qpair(struct spdk_nvme_ctrlr *ctrlr, uint16_t qid, num_entries = SPDK_NVMF_MIN_ADMIN_QUEUE_ENTRIES; ctrlr->adminq = qpair; } else { - num_entries = rctrlr->ctrlr.opts.queue_size; + num_entries = nvme_min(NVME_HOST_MAX_ENTRIES_PER_QUEUE, + ctrlr->cap.bits.mqes + 1); + num_entries = nvme_min(num_entries, rctrlr->ctrlr.opts.queue_size); } rc = nvme_qpair_construct(qpair, qid, num_entries, ctrlr, qprio);