nvmf/rdma: Factor out getting lkey and checking length in fill_wr_sge() into get_lkey()
Factor out getting lkey and checking translation length in nvmf_rdma_fill_wr_sge() into a function nvmf_rdma_get_lkey(). Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Change-Id: I495ba9ae4a48b4aa7dc35a0bd72708753846dfdc Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/469349 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
5e8858d7a3
commit
5dbe96a053
@ -1619,24 +1619,38 @@ nvmf_rdma_fill_buffers_with_md_interleave(struct spdk_nvmf_rdma_transport *rtran
|
||||
}
|
||||
|
||||
static bool
|
||||
nvmf_rdma_fill_wr_sge(struct spdk_nvmf_rdma_device *device,
|
||||
struct spdk_nvmf_request *req, struct ibv_send_wr *wr)
|
||||
nvmf_rdma_get_lkey(struct spdk_nvmf_rdma_device *device, struct iovec *iov,
|
||||
uint32_t *_lkey)
|
||||
{
|
||||
uint64_t translation_len;
|
||||
struct iovec *iov = &req->iov[req->iovcnt];
|
||||
struct ibv_sge *sg_ele = &wr->sg_list[wr->num_sge];
|
||||
uint32_t lkey;
|
||||
|
||||
translation_len = iov->iov_len;
|
||||
|
||||
if (!g_nvmf_hooks.get_rkey) {
|
||||
sg_ele->lkey = ((struct ibv_mr *)spdk_mem_map_translate(device->map,
|
||||
lkey = ((struct ibv_mr *)spdk_mem_map_translate(device->map,
|
||||
(uint64_t)iov->iov_base, &translation_len))->lkey;
|
||||
} else {
|
||||
sg_ele->lkey = spdk_mem_map_translate(device->map,
|
||||
(uint64_t)iov->iov_base, &translation_len);
|
||||
lkey = spdk_mem_map_translate(device->map,
|
||||
(uint64_t)iov->iov_base, &translation_len);
|
||||
}
|
||||
|
||||
if (spdk_unlikely(translation_len < iov->iov_len)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
*_lkey = lkey;
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
nvmf_rdma_fill_wr_sge(struct spdk_nvmf_rdma_device *device,
|
||||
struct spdk_nvmf_request *req, struct ibv_send_wr *wr)
|
||||
{
|
||||
struct iovec *iov = &req->iov[req->iovcnt];
|
||||
struct ibv_sge *sg_ele = &wr->sg_list[wr->num_sge];
|
||||
|
||||
if (spdk_unlikely(!nvmf_rdma_get_lkey(device, iov, &sg_ele->lkey))) {
|
||||
/* 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");
|
||||
return false;
|
||||
|
Loading…
Reference in New Issue
Block a user