From 0b20f2e552d978d84780e0ab968bb7fa65f7707e Mon Sep 17 00:00:00 2001 From: Ziye Yang Date: Thu, 20 Dec 2018 00:27:29 +0800 Subject: [PATCH] nvmf/rdma: Remove data buffer num dependency on SPDK_NVMF_MAX_SGL_ENTRIES The least needed data buffer number should only be larger for completing one RDMA (read/write RDMA). Change-Id: I44eb51db279fc055f687eb78b6a642dbb5cb23f3 Signed-off-by: Ziye Yang Reviewed-on: https://review.gerrithub.io/437808 Tested-by: SPDK CI Jenkins Reviewed-by: Shuhei Matsumoto Reviewed-by: Changpeng Liu Chandler-Test-Pool: SPDK Automated Test System --- lib/nvmf/rdma.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/nvmf/rdma.c b/lib/nvmf/rdma.c index e09068e94..4dacd87df 100644 --- a/lib/nvmf/rdma.c +++ b/lib/nvmf/rdma.c @@ -1597,6 +1597,14 @@ spdk_nvmf_rdma_create(struct spdk_nvmf_transport_opts *opts) opts->io_unit_size = opts->max_io_size; } + if (opts->num_shared_buffers < (SPDK_NVMF_MAX_SGL_ENTRIES * 2)) { + SPDK_ERRLOG("The number of shared data buffers (%d) is less than" + "the minimum number required to guarantee that forward progress can be made (%d)\n", + opts->num_shared_buffers, (SPDK_NVMF_MAX_SGL_ENTRIES * 2)); + spdk_nvmf_rdma_destroy(&rtransport->transport); + return NULL; + } + sge_count = opts->max_io_size / opts->io_unit_size; if (sge_count > NVMF_DEFAULT_TX_SGE) { SPDK_ERRLOG("Unsupported IO Unit size specified, %d bytes\n", opts->io_unit_size); @@ -1620,7 +1628,7 @@ spdk_nvmf_rdma_create(struct spdk_nvmf_transport_opts *opts) } rtransport->data_buf_pool = spdk_mempool_create("spdk_nvmf_rdma", - opts->num_shared_buffers * (SPDK_NVMF_MAX_SGL_ENTRIES * 2), + opts->num_shared_buffers, opts->io_unit_size + NVMF_DATA_BUFFER_ALIGNMENT, SPDK_MEMPOOL_DEFAULT_CACHE_SIZE, SPDK_ENV_SOCKET_ID_ANY); @@ -1770,10 +1778,10 @@ spdk_nvmf_rdma_destroy(struct spdk_nvmf_transport *transport) if (rtransport->data_buf_pool != NULL) { if (spdk_mempool_count(rtransport->data_buf_pool) != - transport->opts.num_shared_buffers * (SPDK_NVMF_MAX_SGL_ENTRIES * 2)) { + transport->opts.num_shared_buffers) { SPDK_ERRLOG("transport buffer pool count is %zu but should be %u\n", spdk_mempool_count(rtransport->data_buf_pool), - transport->opts.num_shared_buffers * (SPDK_NVMF_MAX_SGL_ENTRIES * 2)); + transport->opts.num_shared_buffers); } }