Skip to content

Commit 8dd41d7

Browse files
committed
SUNRPC: Push svcxdr_init_encode() into svc_process_common()
Now that all vs_dispatch functions invoke svcxdr_init_encode(), it is common code and can be pushed down into the generic RPC server. Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
1 parent 7b402c8 commit 8dd41d7

File tree

6 files changed

+23
-10
lines changed

6 files changed

+23
-10
lines changed

fs/lockd/svc.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,6 @@ static int nlmsvc_dispatch(struct svc_rqst *rqstp, __be32 *statp)
704704
if (*statp != rpc_success)
705705
return 1;
706706

707-
svcxdr_init_encode(rqstp);
708707
if (!procp->pc_encode(rqstp, &rqstp->rq_res_stream))
709708
goto out_encode_err;
710709

fs/nfs/callback_xdr.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -984,8 +984,6 @@ nfs_callback_dispatch(struct svc_rqst *rqstp, __be32 *statp)
984984
{
985985
const struct svc_procedure *procp = rqstp->rq_procinfo;
986986

987-
svcxdr_init_encode(rqstp);
988-
989987
*statp = procp->pc_func(rqstp);
990988
return 1;
991989
}

fs/nfsd/nfscache.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ int nfsd_cache_lookup(struct svc_rqst *rqstp)
488488
case RC_NOCACHE:
489489
break;
490490
case RC_REPLSTAT:
491-
svc_putu32(&rqstp->rq_res.head[0], rp->c_replstat);
491+
xdr_stream_encode_be32(&rqstp->rq_res_stream, rp->c_replstat);
492492
rtn = RC_REPLY;
493493
break;
494494
case RC_REPLBUFF:

fs/nfsd/nfssvc.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,12 +1052,6 @@ int nfsd_dispatch(struct svc_rqst *rqstp, __be32 *statp)
10521052
goto out_dropit;
10531053
}
10541054

1055-
/*
1056-
* Need to grab the location to store the status, as
1057-
* NFSv4 does some encoding while processing
1058-
*/
1059-
svcxdr_init_encode(rqstp);
1060-
10611055
*statp = proc->pc_func(rqstp);
10621056
if (test_bit(RQ_DROPME, &rqstp->rq_flags))
10631057
goto out_update_drop;

include/linux/sunrpc/xdr.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,27 @@ xdr_stream_encode_u32(struct xdr_stream *xdr, __u32 n)
474474
return len;
475475
}
476476

477+
/**
478+
* xdr_stream_encode_be32 - Encode a big-endian 32-bit integer
479+
* @xdr: pointer to xdr_stream
480+
* @n: integer to encode
481+
*
482+
* Return values:
483+
* On success, returns length in bytes of XDR buffer consumed
484+
* %-EMSGSIZE on XDR buffer overflow
485+
*/
486+
static inline ssize_t
487+
xdr_stream_encode_be32(struct xdr_stream *xdr, __be32 n)
488+
{
489+
const size_t len = sizeof(n);
490+
__be32 *p = xdr_reserve_space(xdr, len);
491+
492+
if (unlikely(!p))
493+
return -EMSGSIZE;
494+
*p = n;
495+
return len;
496+
}
497+
477498
/**
478499
* xdr_stream_encode_u64 - Encode a 64-bit integer
479500
* @xdr: pointer to xdr_stream

net/sunrpc/svc.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1321,6 +1321,7 @@ svc_process_common(struct svc_rqst *rqstp, struct kvec *resv)
13211321
*/
13221322
if (procp->pc_xdrressize)
13231323
svc_reserve_auth(rqstp, procp->pc_xdrressize<<2);
1324+
svcxdr_init_encode(rqstp);
13241325

13251326
/* Call the function that processes the request. */
13261327
rc = process.dispatch(rqstp, statp);

0 commit comments

Comments
 (0)