nvmf/fc: Use spdk_mempool_get_bulk in nvmf_fc_request_alloc_buffers

This follows the practice of RDMA transport and a preparation to
unify buffer management among transport types.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: Ic7dc8e6b826baf7f471d192630e8a048a35056ac
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/465866
Reviewed-by: Broadcom SPDK FC-NVMe CI <spdk-ci.pdl@broadcom.com>
Reviewed-by: Anil Veerabhadrappa <anil.veerabhadrappa@broadcom.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
Shuhei Matsumoto 2019-08-23 07:44:22 +09:00 committed by Jim Harris
parent c5b15dde18
commit e3b8c31d03

View File

@ -1291,35 +1291,32 @@ complete:
static int static int
nvmf_fc_request_alloc_buffers(struct spdk_nvmf_fc_request *fc_req) nvmf_fc_request_alloc_buffers(struct spdk_nvmf_fc_request *fc_req)
{ {
void *buf = NULL;
uint32_t length = fc_req->req.length; uint32_t length = fc_req->req.length;
uint32_t num_buffers;
uint32_t i = 0; uint32_t i = 0;
struct spdk_nvmf_fc_transport *fc_transport = fc_req->hwqp->fc_poll_group->fc_transport; struct spdk_nvmf_fc_transport *fc_transport = fc_req->hwqp->fc_poll_group->fc_transport;
struct spdk_nvmf_transport *transport = &fc_transport->transport; struct spdk_nvmf_transport *transport = &fc_transport->transport;
fc_req->req.iovcnt = 0; num_buffers = SPDK_CEIL_DIV(length, transport->opts.io_unit_size);
fc_req->data_from_pool = true;
while (length) { if (spdk_mempool_get_bulk(transport->data_buf_pool, fc_req->buffers, num_buffers)) {
buf = spdk_mempool_get(transport->data_buf_pool); return -ENOMEM;
if (!buf) {
goto nomem;
} }
fc_req->req.iov[i].iov_base = (void *)((uintptr_t)((char *)buf + fc_req->req.iovcnt = 0;
while (length) {
i = fc_req->req.iovcnt;
fc_req->req.iov[i].iov_base = (void *)((uintptr_t)((char *)fc_req->buffers[i] +
NVMF_DATA_BUFFER_MASK) & NVMF_DATA_BUFFER_MASK) &
~NVMF_DATA_BUFFER_MASK); ~NVMF_DATA_BUFFER_MASK);
fc_req->req.iov[i].iov_len = spdk_min(length, transport->opts.io_unit_size); fc_req->req.iov[i].iov_len = spdk_min(length, transport->opts.io_unit_size);
fc_req->req.iovcnt++; fc_req->req.iovcnt++;
fc_req->buffers[i] = buf; length -= fc_req->req.iov[i].iov_len;
length -= fc_req->req.iov[i++].iov_len;
} }
fc_req->data_from_pool = true;
return 0; return 0;
nomem:
nvmf_fc_request_free_buffers(fc_req);
fc_req->req.iovcnt = 0;
return -ENOMEM;
} }
static int static int