mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-11 13:04:03 +08:00
svcrdma: Add common XDR decoders for RDMA and Read segments
Clean up: De-duplicate some code. Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
This commit is contained in:
parent
07e9a6325a
commit
f60a08697d
@ -124,4 +124,41 @@ rpcrdma_decode_buffer_size(u8 val)
|
||||
return ((unsigned int)val + 1) << 10;
|
||||
}
|
||||
|
||||
/**
|
||||
* xdr_decode_rdma_segment - Decode contents of an RDMA segment
|
||||
* @p: Pointer to the undecoded RDMA segment
|
||||
* @handle: Upon return, the RDMA handle
|
||||
* @length: Upon return, the RDMA length
|
||||
* @offset: Upon return, the RDMA offset
|
||||
*
|
||||
* Return value:
|
||||
* Pointer to the XDR item that follows the RDMA segment
|
||||
*/
|
||||
static inline __be32 *xdr_decode_rdma_segment(__be32 *p, u32 *handle,
|
||||
u32 *length, u64 *offset)
|
||||
{
|
||||
*handle = be32_to_cpup(p++);
|
||||
*length = be32_to_cpup(p++);
|
||||
return xdr_decode_hyper(p, offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* xdr_decode_read_segment - Decode contents of a Read segment
|
||||
* @p: Pointer to the undecoded Read segment
|
||||
* @position: Upon return, the segment's position
|
||||
* @handle: Upon return, the RDMA handle
|
||||
* @length: Upon return, the RDMA length
|
||||
* @offset: Upon return, the RDMA offset
|
||||
*
|
||||
* Return value:
|
||||
* Pointer to the XDR item that follows the Read segment
|
||||
*/
|
||||
static inline __be32 *xdr_decode_read_segment(__be32 *p, u32 *position,
|
||||
u32 *handle, u32 *length,
|
||||
u64 *offset)
|
||||
{
|
||||
*position = be32_to_cpup(p++);
|
||||
return xdr_decode_rdma_segment(p, handle, length, offset);
|
||||
}
|
||||
|
||||
#endif /* _LINUX_SUNRPC_RPC_RDMA_H */
|
||||
|
@ -40,7 +40,6 @@
|
||||
* New MRs are created on demand.
|
||||
*/
|
||||
|
||||
#include <linux/sunrpc/rpc_rdma.h>
|
||||
#include <linux/sunrpc/svc_rdma.h>
|
||||
|
||||
#include "xprt_rdma.h"
|
||||
|
@ -1176,10 +1176,7 @@ static int decode_rdma_segment(struct xdr_stream *xdr, u32 *length)
|
||||
if (unlikely(!p))
|
||||
return -EIO;
|
||||
|
||||
handle = be32_to_cpup(p++);
|
||||
*length = be32_to_cpup(p++);
|
||||
xdr_decode_hyper(p, &offset);
|
||||
|
||||
xdr_decode_rdma_segment(p, &handle, length, &offset);
|
||||
trace_xprtrdma_decode_seg(handle, *length, offset);
|
||||
return 0;
|
||||
}
|
||||
|
@ -466,9 +466,7 @@ static bool xdr_check_write_chunk(struct svc_rdma_recv_ctxt *rctxt, u32 maxlen)
|
||||
if (!p)
|
||||
return false;
|
||||
|
||||
handle = be32_to_cpup(p++);
|
||||
length = be32_to_cpup(p++);
|
||||
xdr_decode_hyper(p, &offset);
|
||||
xdr_decode_rdma_segment(p, &handle, &length, &offset);
|
||||
trace_svcrdma_decode_wseg(handle, length, offset);
|
||||
|
||||
total += length;
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
#include <rdma/rw.h>
|
||||
|
||||
#include <linux/sunrpc/xdr.h>
|
||||
#include <linux/sunrpc/rpc_rdma.h>
|
||||
#include <linux/sunrpc/svc_rdma.h>
|
||||
|
||||
@ -441,34 +442,32 @@ svc_rdma_build_writes(struct svc_rdma_write_info *info,
|
||||
seg = info->wi_segs + info->wi_seg_no * rpcrdma_segment_maxsz;
|
||||
do {
|
||||
unsigned int write_len;
|
||||
u32 seg_length, seg_handle;
|
||||
u64 seg_offset;
|
||||
u32 handle, length;
|
||||
u64 offset;
|
||||
|
||||
if (info->wi_seg_no >= info->wi_nsegs)
|
||||
goto out_overflow;
|
||||
|
||||
seg_handle = be32_to_cpup(seg);
|
||||
seg_length = be32_to_cpup(seg + 1);
|
||||
xdr_decode_hyper(seg + 2, &seg_offset);
|
||||
seg_offset += info->wi_seg_off;
|
||||
xdr_decode_rdma_segment(seg, &handle, &length, &offset);
|
||||
offset += info->wi_seg_off;
|
||||
|
||||
write_len = min(remaining, seg_length - info->wi_seg_off);
|
||||
write_len = min(remaining, length - info->wi_seg_off);
|
||||
ctxt = svc_rdma_get_rw_ctxt(rdma,
|
||||
(write_len >> PAGE_SHIFT) + 2);
|
||||
if (!ctxt)
|
||||
return -ENOMEM;
|
||||
|
||||
constructor(info, write_len, ctxt);
|
||||
ret = svc_rdma_rw_ctx_init(rdma, ctxt, seg_offset, seg_handle,
|
||||
ret = svc_rdma_rw_ctx_init(rdma, ctxt, offset, handle,
|
||||
DMA_TO_DEVICE);
|
||||
if (ret < 0)
|
||||
return -EIO;
|
||||
|
||||
trace_svcrdma_send_wseg(seg_handle, write_len, seg_offset);
|
||||
trace_svcrdma_send_wseg(handle, write_len, offset);
|
||||
|
||||
list_add(&ctxt->rw_list, &cc->cc_rwctxts);
|
||||
cc->cc_sqecount += ret;
|
||||
if (write_len == seg_length - info->wi_seg_off) {
|
||||
if (write_len == length - info->wi_seg_off) {
|
||||
seg += 4;
|
||||
info->wi_seg_no++;
|
||||
info->wi_seg_off = 0;
|
||||
@ -689,21 +688,17 @@ static int svc_rdma_build_read_chunk(struct svc_rqst *rqstp,
|
||||
ret = -EINVAL;
|
||||
info->ri_chunklen = 0;
|
||||
while (*p++ != xdr_zero && be32_to_cpup(p++) == info->ri_position) {
|
||||
u32 rs_handle, rs_length;
|
||||
u64 rs_offset;
|
||||
u32 handle, length;
|
||||
u64 offset;
|
||||
|
||||
rs_handle = be32_to_cpup(p++);
|
||||
rs_length = be32_to_cpup(p++);
|
||||
p = xdr_decode_hyper(p, &rs_offset);
|
||||
|
||||
ret = svc_rdma_build_read_segment(info, rqstp,
|
||||
rs_handle, rs_length,
|
||||
rs_offset);
|
||||
p = xdr_decode_rdma_segment(p, &handle, &length, &offset);
|
||||
ret = svc_rdma_build_read_segment(info, rqstp, handle, length,
|
||||
offset);
|
||||
if (ret < 0)
|
||||
break;
|
||||
|
||||
trace_svcrdma_send_rseg(rs_handle, rs_length, rs_offset);
|
||||
info->ri_chunklen += rs_length;
|
||||
trace_svcrdma_send_rseg(handle, length, offset);
|
||||
info->ri_chunklen += length;
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -106,7 +106,6 @@
|
||||
#include <rdma/rdma_cm.h>
|
||||
|
||||
#include <linux/sunrpc/debug.h>
|
||||
#include <linux/sunrpc/rpc_rdma.h>
|
||||
#include <linux/sunrpc/svc_rdma.h>
|
||||
|
||||
#include "xprt_rdma.h"
|
||||
@ -375,9 +374,7 @@ static ssize_t svc_rdma_encode_write_segment(__be32 *src,
|
||||
if (!p)
|
||||
return -EMSGSIZE;
|
||||
|
||||
handle = be32_to_cpup(src++);
|
||||
length = be32_to_cpup(src++);
|
||||
xdr_decode_hyper(src, &offset);
|
||||
xdr_decode_rdma_segment(src, &handle, &length, &offset);
|
||||
|
||||
*p++ = cpu_to_be32(handle);
|
||||
if (*remaining < length) {
|
||||
|
@ -55,7 +55,6 @@
|
||||
|
||||
#include <linux/sunrpc/addr.h>
|
||||
#include <linux/sunrpc/debug.h>
|
||||
#include <linux/sunrpc/rpc_rdma.h>
|
||||
#include <linux/sunrpc/svc_xprt.h>
|
||||
#include <linux/sunrpc/svc_rdma.h>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user