mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-11-01 17:08:10 +00:00
IB/rdmavt: Fix frwr memory registration
Current implementation was not properly handling frwr memory
registrations. This was uncovered by commit 27f26cec761das ("xprtrdma:
Plant XID in on-the-wire RDMA offset (FRWR)") in which xprtrdma, which is
used for NFS over RDMA, started failing as it was the first ULP to modify
the ib_mr iova resulting in the NFS server getting REMOTE ACCESS ERROR
when attempting to perform RDMA Writes to the client.
The fix is to properly capture the true iova, offset, and length in the
call to ib_map_mr_sg, and then update the iova when processing the
IB_WR_REG_MEM on the send queue.
Fixes: a41081aa59
("IB/rdmavt: Add support for ib_map_mr_sg")
Cc: stable@vger.kernel.org
Reviewed-by: Mike Marciniszyn <mike.marciniszyn@intel.com>
Reviewed-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Reviewed-by: Michael J. Ruhl <michael.j.ruhl@intel.com>
Signed-off-by: Josh Collier <josh.d.collier@intel.com>
Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
This commit is contained in:
parent
dc4060a5dc
commit
7c39f7f671
1 changed files with 10 additions and 7 deletions
|
@ -608,11 +608,6 @@ static int rvt_set_page(struct ib_mr *ibmr, u64 addr)
|
|||
if (unlikely(mapped_segs == mr->mr.max_segs))
|
||||
return -ENOMEM;
|
||||
|
||||
if (mr->mr.length == 0) {
|
||||
mr->mr.user_base = addr;
|
||||
mr->mr.iova = addr;
|
||||
}
|
||||
|
||||
m = mapped_segs / RVT_SEGSZ;
|
||||
n = mapped_segs % RVT_SEGSZ;
|
||||
mr->mr.map[m]->segs[n].vaddr = (void *)addr;
|
||||
|
@ -630,17 +625,24 @@ static int rvt_set_page(struct ib_mr *ibmr, u64 addr)
|
|||
* @sg_nents: number of entries in sg
|
||||
* @sg_offset: offset in bytes into sg
|
||||
*
|
||||
* Overwrite rvt_mr length with mr length calculated by ib_sg_to_pages.
|
||||
*
|
||||
* Return: number of sg elements mapped to the memory region
|
||||
*/
|
||||
int rvt_map_mr_sg(struct ib_mr *ibmr, struct scatterlist *sg,
|
||||
int sg_nents, unsigned int *sg_offset)
|
||||
{
|
||||
struct rvt_mr *mr = to_imr(ibmr);
|
||||
int ret;
|
||||
|
||||
mr->mr.length = 0;
|
||||
mr->mr.page_shift = PAGE_SHIFT;
|
||||
return ib_sg_to_pages(ibmr, sg, sg_nents, sg_offset,
|
||||
rvt_set_page);
|
||||
ret = ib_sg_to_pages(ibmr, sg, sg_nents, sg_offset, rvt_set_page);
|
||||
mr->mr.user_base = ibmr->iova;
|
||||
mr->mr.iova = ibmr->iova;
|
||||
mr->mr.offset = ibmr->iova - (u64)mr->mr.map[0]->segs[0].vaddr;
|
||||
mr->mr.length = (size_t)ibmr->length;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -671,6 +673,7 @@ int rvt_fast_reg_mr(struct rvt_qp *qp, struct ib_mr *ibmr, u32 key,
|
|||
ibmr->rkey = key;
|
||||
mr->mr.lkey = key;
|
||||
mr->mr.access_flags = access;
|
||||
mr->mr.iova = ibmr->iova;
|
||||
atomic_set(&mr->mr.lkey_invalid, 0);
|
||||
|
||||
return 0;
|
||||
|
|
Loading…
Reference in a new issue