NFSD: Extract the svcxdr_init_encode() helper
[ Upstream commit bddfdbcddbe267519cd36aeb115fdf8620980111 ] NFSD initializes an encode xdr_stream only after the RPC layer has already inserted the RPC Reply header. Thus it behaves differently than xdr_init_encode does, which assumes the passed-in xdr_buf is entirely devoid of content. nfs4proc.c has this server-side stream initialization helper, but it is visible only to the NFSv4 code. Move this helper to a place that can be accessed by NFSv2 and NFSv3 server XDR functions. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:

committed by
Greg Kroah-Hartman

parent
e864d4d834
commit
48aadfa75b
@@ -248,6 +248,7 @@ struct svc_rqst {
|
||||
size_t rq_xprt_hlen; /* xprt header len */
|
||||
struct xdr_buf rq_arg;
|
||||
struct xdr_stream rq_arg_stream;
|
||||
struct xdr_stream rq_res_stream;
|
||||
struct page *rq_scratch_page;
|
||||
struct xdr_buf rq_res;
|
||||
struct page *rq_pages[RPCSVC_MAXPAGES + 1];
|
||||
@@ -574,4 +575,28 @@ static inline void svcxdr_init_decode(struct svc_rqst *rqstp)
|
||||
xdr_set_scratch_page(xdr, rqstp->rq_scratch_page);
|
||||
}
|
||||
|
||||
/**
|
||||
* svcxdr_init_encode - Prepare an xdr_stream for svc Reply encoding
|
||||
* @rqstp: controlling server RPC transaction context
|
||||
*
|
||||
*/
|
||||
static inline void svcxdr_init_encode(struct svc_rqst *rqstp)
|
||||
{
|
||||
struct xdr_stream *xdr = &rqstp->rq_res_stream;
|
||||
struct xdr_buf *buf = &rqstp->rq_res;
|
||||
struct kvec *resv = buf->head;
|
||||
|
||||
xdr_reset_scratch_buffer(xdr);
|
||||
|
||||
xdr->buf = buf;
|
||||
xdr->iov = resv;
|
||||
xdr->p = resv->iov_base + resv->iov_len;
|
||||
xdr->end = resv->iov_base + PAGE_SIZE - rqstp->rq_auth_slack;
|
||||
buf->len = resv->iov_len;
|
||||
xdr->page_ptr = buf->pages - 1;
|
||||
buf->buflen = PAGE_SIZE * (1 + rqstp->rq_page_end - buf->pages);
|
||||
buf->buflen -= rqstp->rq_auth_slack;
|
||||
xdr->rqst = NULL;
|
||||
}
|
||||
|
||||
#endif /* SUNRPC_SVC_H */
|
||||
|
Reference in New Issue
Block a user