Skip to content

Commit d9e4084

Browse files
chuckleverJ. Bruce Fields
authored andcommitted
svcrdma: Generalize svc_rdma_xdr_decode_req()
Clean up: Pass in just the piece of the svc_rqst that is needed here. While we're in the area, add an informative documenting comment. Signed-off-by: Chuck Lever <[email protected]> Signed-off-by: J. Bruce Fields <[email protected]>
1 parent 84f225c commit d9e4084

File tree

3 files changed

+24
-12
lines changed

3 files changed

+24
-12
lines changed

include/linux/sunrpc/svc_rdma.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ extern int svc_rdma_handle_bc_reply(struct rpc_xprt *xprt,
199199
struct xdr_buf *rcvbuf);
200200

201201
/* svc_rdma_marshal.c */
202-
extern int svc_rdma_xdr_decode_req(struct rpcrdma_msg *, struct svc_rqst *);
202+
extern int svc_rdma_xdr_decode_req(struct xdr_buf *);
203203
extern int svc_rdma_xdr_encode_error(struct svcxprt_rdma *,
204204
struct rpcrdma_msg *,
205205
enum rpcrdma_errcode, __be32 *);

net/sunrpc/xprtrdma/svc_rdma_marshal.c

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -145,19 +145,32 @@ static __be32 *decode_reply_array(__be32 *va, __be32 *vaend)
145145
return (__be32 *)&ary->wc_array[nchunks];
146146
}
147147

148-
int svc_rdma_xdr_decode_req(struct rpcrdma_msg *rmsgp, struct svc_rqst *rqstp)
148+
/**
149+
* svc_rdma_xdr_decode_req - Parse incoming RPC-over-RDMA header
150+
* @rq_arg: Receive buffer
151+
*
152+
* On entry, xdr->head[0].iov_base points to first byte in the
153+
* RPC-over-RDMA header.
154+
*
155+
* On successful exit, head[0] points to first byte past the
156+
* RPC-over-RDMA header. For RDMA_MSG, this is the RPC message.
157+
* The length of the RPC-over-RDMA header is returned.
158+
*/
159+
int svc_rdma_xdr_decode_req(struct xdr_buf *rq_arg)
149160
{
161+
struct rpcrdma_msg *rmsgp;
150162
__be32 *va, *vaend;
151163
unsigned int len;
152164
u32 hdr_len;
153165

154166
/* Verify that there's enough bytes for header + something */
155-
if (rqstp->rq_arg.len <= RPCRDMA_HDRLEN_ERR) {
167+
if (rq_arg->len <= RPCRDMA_HDRLEN_ERR) {
156168
dprintk("svcrdma: header too short = %d\n",
157-
rqstp->rq_arg.len);
169+
rq_arg->len);
158170
return -EINVAL;
159171
}
160172

173+
rmsgp = (struct rpcrdma_msg *)rq_arg->head[0].iov_base;
161174
if (rmsgp->rm_vers != rpcrdma_version) {
162175
dprintk("%s: bad version %u\n", __func__,
163176
be32_to_cpu(rmsgp->rm_vers));
@@ -189,10 +202,10 @@ int svc_rdma_xdr_decode_req(struct rpcrdma_msg *rmsgp, struct svc_rqst *rqstp)
189202
be32_to_cpu(rmsgp->rm_body.rm_padded.rm_thresh);
190203

191204
va = &rmsgp->rm_body.rm_padded.rm_pempty[4];
192-
rqstp->rq_arg.head[0].iov_base = va;
205+
rq_arg->head[0].iov_base = va;
193206
len = (u32)((unsigned long)va - (unsigned long)rmsgp);
194-
rqstp->rq_arg.head[0].iov_len -= len;
195-
if (len > rqstp->rq_arg.len)
207+
rq_arg->head[0].iov_len -= len;
208+
if (len > rq_arg->len)
196209
return -EINVAL;
197210
return len;
198211
default:
@@ -205,7 +218,7 @@ int svc_rdma_xdr_decode_req(struct rpcrdma_msg *rmsgp, struct svc_rqst *rqstp)
205218
* chunk list and a reply chunk list.
206219
*/
207220
va = &rmsgp->rm_body.rm_chunks[0];
208-
vaend = (__be32 *)((unsigned long)rmsgp + rqstp->rq_arg.len);
221+
vaend = (__be32 *)((unsigned long)rmsgp + rq_arg->len);
209222
va = decode_read_list(va, vaend);
210223
if (!va) {
211224
dprintk("svcrdma: failed to decode read list\n");
@@ -222,10 +235,9 @@ int svc_rdma_xdr_decode_req(struct rpcrdma_msg *rmsgp, struct svc_rqst *rqstp)
222235
return -EINVAL;
223236
}
224237

225-
rqstp->rq_arg.head[0].iov_base = va;
238+
rq_arg->head[0].iov_base = va;
226239
hdr_len = (unsigned long)va - (unsigned long)rmsgp;
227-
rqstp->rq_arg.head[0].iov_len -= hdr_len;
228-
240+
rq_arg->head[0].iov_len -= hdr_len;
229241
return hdr_len;
230242
}
231243

net/sunrpc/xprtrdma/svc_rdma_recvfrom.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
636636

637637
/* Decode the RDMA header. */
638638
rmsgp = (struct rpcrdma_msg *)rqstp->rq_arg.head[0].iov_base;
639-
ret = svc_rdma_xdr_decode_req(rmsgp, rqstp);
639+
ret = svc_rdma_xdr_decode_req(&rqstp->rq_arg);
640640
if (ret < 0)
641641
goto out_err;
642642
if (ret == 0)

0 commit comments

Comments
 (0)