diff options
author | Chuck Lever <chuck.lever@oracle.com> | 2015-03-30 14:34:02 -0400 |
---|---|---|
committer | Anna Schumaker <Anna.Schumaker@Netapp.com> | 2015-03-31 09:52:52 -0400 |
commit | 805272406a980cab0e11742e5423ba97b6f38836 (patch) | |
tree | 89f49bc3a2d999fe4c67339fef0cb767eccaf7b1 | |
parent | e23779451ee05e824fedbb68bd17fc5c77e40166 (diff) |
xprtrdma: Byte-align FRWR registration
The RPC/RDMA transport's FRWR registration logic registers whole
pages. This means areas in the first and last pages that are not
involved in the RDMA I/O are needlessly exposed to the server.
Buffered I/O is typically page-aligned, so not a problem there. But
for direct I/O, which can be byte-aligned, and for reply chunks,
which are nearly always smaller than a page, the transport could
expose memory outside the I/O buffer.
FRWR allows byte-aligned memory registration, so let's use it as
it was intended.
Reported-by: Sagi Grimberg <sagig@mellanox.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Tested-by: Devesh Sharma <Devesh.Sharma@Emulex.Com>
Tested-by: Meghana Cheripady <Meghana.Cheripady@Emulex.Com>
Tested-by: Veeresh U. Kokatnur <veereshuk@chelsio.com>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
-rw-r--r-- | net/sunrpc/xprtrdma/verbs.c | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/net/sunrpc/xprtrdma/verbs.c b/net/sunrpc/xprtrdma/verbs.c index 1aa55b74b1b7..60f3317c90ee 100644 --- a/net/sunrpc/xprtrdma/verbs.c +++ b/net/sunrpc/xprtrdma/verbs.c | |||
@@ -1924,23 +1924,19 @@ rpcrdma_register_frmr_external(struct rpcrdma_mr_seg *seg, | |||
1924 | offset_in_page((seg-1)->mr_offset + (seg-1)->mr_len)) | 1924 | offset_in_page((seg-1)->mr_offset + (seg-1)->mr_len)) |
1925 | break; | 1925 | break; |
1926 | } | 1926 | } |
1927 | dprintk("RPC: %s: Using frmr %p to map %d segments\n", | 1927 | dprintk("RPC: %s: Using frmr %p to map %d segments (%d bytes)\n", |
1928 | __func__, mw, i); | 1928 | __func__, mw, i, len); |
1929 | 1929 | ||
1930 | frmr->fr_state = FRMR_IS_VALID; | 1930 | frmr->fr_state = FRMR_IS_VALID; |
1931 | 1931 | ||
1932 | memset(&fastreg_wr, 0, sizeof(fastreg_wr)); | 1932 | memset(&fastreg_wr, 0, sizeof(fastreg_wr)); |
1933 | fastreg_wr.wr_id = (unsigned long)(void *)mw; | 1933 | fastreg_wr.wr_id = (unsigned long)(void *)mw; |
1934 | fastreg_wr.opcode = IB_WR_FAST_REG_MR; | 1934 | fastreg_wr.opcode = IB_WR_FAST_REG_MR; |
1935 | fastreg_wr.wr.fast_reg.iova_start = seg1->mr_dma; | 1935 | fastreg_wr.wr.fast_reg.iova_start = seg1->mr_dma + pageoff; |
1936 | fastreg_wr.wr.fast_reg.page_list = frmr->fr_pgl; | 1936 | fastreg_wr.wr.fast_reg.page_list = frmr->fr_pgl; |
1937 | fastreg_wr.wr.fast_reg.page_list_len = page_no; | 1937 | fastreg_wr.wr.fast_reg.page_list_len = page_no; |
1938 | fastreg_wr.wr.fast_reg.page_shift = PAGE_SHIFT; | 1938 | fastreg_wr.wr.fast_reg.page_shift = PAGE_SHIFT; |
1939 | fastreg_wr.wr.fast_reg.length = page_no << PAGE_SHIFT; | 1939 | fastreg_wr.wr.fast_reg.length = len; |
1940 | if (fastreg_wr.wr.fast_reg.length < len) { | ||
1941 | rc = -EIO; | ||
1942 | goto out_err; | ||
1943 | } | ||
1944 | 1940 | ||
1945 | /* Bump the key */ | 1941 | /* Bump the key */ |
1946 | key = (u8)(mr->rkey & 0x000000FF); | 1942 | key = (u8)(mr->rkey & 0x000000FF); |