aboutsummaryrefslogtreecommitdiffstats
path: root/net/sunrpc
diff options
context:
space:
mode:
authorChuck Lever <chuck.lever@oracle.com>2015-01-13 11:02:54 -0500
committerJ. Bruce Fields <bfields@redhat.com>2015-01-15 15:01:44 -0500
commit2397aa8b515f7bd77c8d5698170b6a98fdd6721c (patch)
treeb631bbfd5e6c736601a2007e3fc276bd5ee2131a /net/sunrpc
parent83f2bedfc6435ffeaa7b466058c5d22b5e8f428b (diff)
svcrdma: Clean up read chunk counting
The byte_count argument is not used, and the function is called only from one place. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Reviewed-by: Steve Wise <swise@opengridcomputing.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'net/sunrpc')
-rw-r--r--net/sunrpc/xprtrdma/svc_rdma_marshal.c16
-rw-r--r--net/sunrpc/xprtrdma/svc_rdma_recvfrom.c15
2 files changed, 12 insertions, 19 deletions
diff --git a/net/sunrpc/xprtrdma/svc_rdma_marshal.c b/net/sunrpc/xprtrdma/svc_rdma_marshal.c
index 65b146297f5a..b681855cf970 100644
--- a/net/sunrpc/xprtrdma/svc_rdma_marshal.c
+++ b/net/sunrpc/xprtrdma/svc_rdma_marshal.c
@@ -71,22 +71,6 @@ static u32 *decode_read_list(u32 *va, u32 *vaend)
71} 71}
72 72
73/* 73/*
74 * Determine number of chunks and total bytes in chunk list. The chunk
75 * list has already been verified to fit within the RPCRDMA header.
76 */
77void svc_rdma_rcl_chunk_counts(struct rpcrdma_read_chunk *ch,
78 int *ch_count, int *byte_count)
79{
80 /* compute the number of bytes represented by read chunks */
81 *byte_count = 0;
82 *ch_count = 0;
83 for (; ch->rc_discrim != 0; ch++) {
84 *byte_count = *byte_count + ntohl(ch->rc_target.rs_length);
85 *ch_count = *ch_count + 1;
86 }
87}
88
89/*
90 * Decodes a write chunk list. The expected format is as follows: 74 * Decodes a write chunk list. The expected format is as follows:
91 * descrim : xdr_one 75 * descrim : xdr_one
92 * nchunks : <count> 76 * nchunks : <count>
diff --git a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
index 2c67de032009..b3b7bb85844d 100644
--- a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
+++ b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
@@ -365,12 +365,22 @@ static int rdma_read_chunk_frmr(struct svcxprt_rdma *xprt,
365 return ret; 365 return ret;
366} 366}
367 367
368static unsigned int
369rdma_rcl_chunk_count(struct rpcrdma_read_chunk *ch)
370{
371 unsigned int count;
372
373 for (count = 0; ch->rc_discrim != xdr_zero; ch++)
374 count++;
375 return count;
376}
377
368static int rdma_read_chunks(struct svcxprt_rdma *xprt, 378static int rdma_read_chunks(struct svcxprt_rdma *xprt,
369 struct rpcrdma_msg *rmsgp, 379 struct rpcrdma_msg *rmsgp,
370 struct svc_rqst *rqstp, 380 struct svc_rqst *rqstp,
371 struct svc_rdma_op_ctxt *head) 381 struct svc_rdma_op_ctxt *head)
372{ 382{
373 int page_no, ch_count, ret; 383 int page_no, ret;
374 struct rpcrdma_read_chunk *ch; 384 struct rpcrdma_read_chunk *ch;
375 u32 page_offset, byte_count; 385 u32 page_offset, byte_count;
376 u64 rs_offset; 386 u64 rs_offset;
@@ -381,8 +391,7 @@ static int rdma_read_chunks(struct svcxprt_rdma *xprt,
381 if (!ch) 391 if (!ch)
382 return 0; 392 return 0;
383 393
384 svc_rdma_rcl_chunk_counts(ch, &ch_count, &byte_count); 394 if (rdma_rcl_chunk_count(ch) > RPCSVC_MAXPAGES)
385 if (ch_count > RPCSVC_MAXPAGES)
386 return -EINVAL; 395 return -EINVAL;
387 396
388 /* The request is completed when the RDMA_READs complete. The 397 /* The request is completed when the RDMA_READs complete. The