nvmf/rdma: Simplify nvmf_rdma_fill_wr_sge() by using cached pointers
Cache pointers to iovec and ibv_sge at the head of the function and use them throughout. Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Change-Id: I493759bf3989ced4390d077280cd44c122847d08 Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/469348 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Seth Howell <seth.howell@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Alexey Marchuk <alexeymar@mellanox.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
89a28bfd1b
commit
5e8858d7a3
@ -1623,25 +1623,27 @@ nvmf_rdma_fill_wr_sge(struct spdk_nvmf_rdma_device *device,
|
|||||||
struct spdk_nvmf_request *req, struct ibv_send_wr *wr)
|
struct spdk_nvmf_request *req, struct ibv_send_wr *wr)
|
||||||
{
|
{
|
||||||
uint64_t translation_len;
|
uint64_t translation_len;
|
||||||
|
struct iovec *iov = &req->iov[req->iovcnt];
|
||||||
|
struct ibv_sge *sg_ele = &wr->sg_list[wr->num_sge];
|
||||||
|
|
||||||
translation_len = req->iov[req->iovcnt].iov_len;
|
translation_len = iov->iov_len;
|
||||||
|
|
||||||
if (!g_nvmf_hooks.get_rkey) {
|
if (!g_nvmf_hooks.get_rkey) {
|
||||||
wr->sg_list[wr->num_sge].lkey = ((struct ibv_mr *)spdk_mem_map_translate(device->map,
|
sg_ele->lkey = ((struct ibv_mr *)spdk_mem_map_translate(device->map,
|
||||||
(uint64_t)req->iov[req->iovcnt].iov_base, &translation_len))->lkey;
|
(uint64_t)iov->iov_base, &translation_len))->lkey;
|
||||||
} else {
|
} else {
|
||||||
wr->sg_list[wr->num_sge].lkey = spdk_mem_map_translate(device->map,
|
sg_ele->lkey = spdk_mem_map_translate(device->map,
|
||||||
(uint64_t)req->iov[req->iovcnt].iov_base, &translation_len);
|
(uint64_t)iov->iov_base, &translation_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (spdk_unlikely(translation_len < req->iov[req->iovcnt].iov_len)) {
|
if (spdk_unlikely(translation_len < iov->iov_len)) {
|
||||||
/* This is a very rare case that can occur when using DPDK version < 19.05 */
|
/* This is a very rare case that can occur when using DPDK version < 19.05 */
|
||||||
SPDK_ERRLOG("Data buffer split over multiple RDMA Memory Regions. Removing it from circulation.\n");
|
SPDK_ERRLOG("Data buffer split over multiple RDMA Memory Regions. Removing it from circulation.\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
wr->sg_list[wr->num_sge].addr = (uintptr_t)(req->iov[req->iovcnt].iov_base);
|
sg_ele->addr = (uintptr_t)(iov->iov_base);
|
||||||
wr->sg_list[wr->num_sge].length = req->iov[req->iovcnt].iov_len;
|
sg_ele->length = iov->iov_len;
|
||||||
wr->num_sge++;
|
wr->num_sge++;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
Reference in New Issue
Block a user