mirror of
https://gitee.com/bianbu-linux/linux-6.6
synced 2025-04-24 14:07:52 -04:00
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 <jlayton@kernel.org> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
This commit is contained in:
parent
7b402c8db6
commit
8dd41d70f3
6 changed files with 23 additions and 10 deletions
|
@ -704,7 +704,6 @@ static int nlmsvc_dispatch(struct svc_rqst *rqstp, __be32 *statp)
|
||||||
if (*statp != rpc_success)
|
if (*statp != rpc_success)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
svcxdr_init_encode(rqstp);
|
|
||||||
if (!procp->pc_encode(rqstp, &rqstp->rq_res_stream))
|
if (!procp->pc_encode(rqstp, &rqstp->rq_res_stream))
|
||||||
goto out_encode_err;
|
goto out_encode_err;
|
||||||
|
|
||||||
|
|
|
@ -984,8 +984,6 @@ nfs_callback_dispatch(struct svc_rqst *rqstp, __be32 *statp)
|
||||||
{
|
{
|
||||||
const struct svc_procedure *procp = rqstp->rq_procinfo;
|
const struct svc_procedure *procp = rqstp->rq_procinfo;
|
||||||
|
|
||||||
svcxdr_init_encode(rqstp);
|
|
||||||
|
|
||||||
*statp = procp->pc_func(rqstp);
|
*statp = procp->pc_func(rqstp);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -488,7 +488,7 @@ found_entry:
|
||||||
case RC_NOCACHE:
|
case RC_NOCACHE:
|
||||||
break;
|
break;
|
||||||
case RC_REPLSTAT:
|
case RC_REPLSTAT:
|
||||||
svc_putu32(&rqstp->rq_res.head[0], rp->c_replstat);
|
xdr_stream_encode_be32(&rqstp->rq_res_stream, rp->c_replstat);
|
||||||
rtn = RC_REPLY;
|
rtn = RC_REPLY;
|
||||||
break;
|
break;
|
||||||
case RC_REPLBUFF:
|
case RC_REPLBUFF:
|
||||||
|
|
|
@ -1052,12 +1052,6 @@ int nfsd_dispatch(struct svc_rqst *rqstp, __be32 *statp)
|
||||||
goto out_dropit;
|
goto out_dropit;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Need to grab the location to store the status, as
|
|
||||||
* NFSv4 does some encoding while processing
|
|
||||||
*/
|
|
||||||
svcxdr_init_encode(rqstp);
|
|
||||||
|
|
||||||
*statp = proc->pc_func(rqstp);
|
*statp = proc->pc_func(rqstp);
|
||||||
if (test_bit(RQ_DROPME, &rqstp->rq_flags))
|
if (test_bit(RQ_DROPME, &rqstp->rq_flags))
|
||||||
goto out_update_drop;
|
goto out_update_drop;
|
||||||
|
|
|
@ -474,6 +474,27 @@ xdr_stream_encode_u32(struct xdr_stream *xdr, __u32 n)
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xdr_stream_encode_be32 - Encode a big-endian 32-bit integer
|
||||||
|
* @xdr: pointer to xdr_stream
|
||||||
|
* @n: integer to encode
|
||||||
|
*
|
||||||
|
* Return values:
|
||||||
|
* On success, returns length in bytes of XDR buffer consumed
|
||||||
|
* %-EMSGSIZE on XDR buffer overflow
|
||||||
|
*/
|
||||||
|
static inline ssize_t
|
||||||
|
xdr_stream_encode_be32(struct xdr_stream *xdr, __be32 n)
|
||||||
|
{
|
||||||
|
const size_t len = sizeof(n);
|
||||||
|
__be32 *p = xdr_reserve_space(xdr, len);
|
||||||
|
|
||||||
|
if (unlikely(!p))
|
||||||
|
return -EMSGSIZE;
|
||||||
|
*p = n;
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xdr_stream_encode_u64 - Encode a 64-bit integer
|
* xdr_stream_encode_u64 - Encode a 64-bit integer
|
||||||
* @xdr: pointer to xdr_stream
|
* @xdr: pointer to xdr_stream
|
||||||
|
|
|
@ -1321,6 +1321,7 @@ svc_process_common(struct svc_rqst *rqstp, struct kvec *resv)
|
||||||
*/
|
*/
|
||||||
if (procp->pc_xdrressize)
|
if (procp->pc_xdrressize)
|
||||||
svc_reserve_auth(rqstp, procp->pc_xdrressize<<2);
|
svc_reserve_auth(rqstp, procp->pc_xdrressize<<2);
|
||||||
|
svcxdr_init_encode(rqstp);
|
||||||
|
|
||||||
/* Call the function that processes the request. */
|
/* Call the function that processes the request. */
|
||||||
rc = process.dispatch(rqstp, statp);
|
rc = process.dispatch(rqstp, statp);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue