NFSD: Refactor common code out of dirlist helpers
The dust has settled a bit and it's become obvious what code is totally common between nfsd_init_dirlist_pages() and nfsd3_init_dirlist_pages(). Move that common code to SUNRPC. The new helper brackets the existing xdr_init_decode_pages() API. Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
This commit is contained in:
Родитель
f18d8afbf2
Коммит
98124f5bd6
|
@ -574,15 +574,7 @@ static void nfsd3_init_dirlist_pages(struct svc_rqst *rqstp,
|
|||
buf->pages = rqstp->rq_next_page;
|
||||
rqstp->rq_next_page += (buf->buflen + PAGE_SIZE - 1) >> PAGE_SHIFT;
|
||||
|
||||
/* This is xdr_init_encode(), but it assumes that
|
||||
* the head kvec has already been consumed. */
|
||||
xdr_set_scratch_buffer(xdr, NULL, 0);
|
||||
xdr->buf = buf;
|
||||
xdr->page_ptr = buf->pages;
|
||||
xdr->iov = NULL;
|
||||
xdr->p = page_address(*buf->pages);
|
||||
xdr->end = (void *)xdr->p + min_t(u32, buf->buflen, PAGE_SIZE);
|
||||
xdr->rqst = NULL;
|
||||
xdr_init_encode_pages(xdr, buf, buf->pages, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -575,15 +575,7 @@ static void nfsd_init_dirlist_pages(struct svc_rqst *rqstp,
|
|||
buf->pages = rqstp->rq_next_page;
|
||||
rqstp->rq_next_page++;
|
||||
|
||||
/* This is xdr_init_encode(), but it assumes that
|
||||
* the head kvec has already been consumed. */
|
||||
xdr_set_scratch_buffer(xdr, NULL, 0);
|
||||
xdr->buf = buf;
|
||||
xdr->page_ptr = buf->pages;
|
||||
xdr->iov = NULL;
|
||||
xdr->p = page_address(*buf->pages);
|
||||
xdr->end = (void *)xdr->p + min_t(u32, buf->buflen, PAGE_SIZE);
|
||||
xdr->rqst = NULL;
|
||||
xdr_init_encode_pages(xdr, buf, buf->pages, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -240,6 +240,8 @@ typedef int (*kxdrdproc_t)(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
|
|||
|
||||
extern void xdr_init_encode(struct xdr_stream *xdr, struct xdr_buf *buf,
|
||||
__be32 *p, struct rpc_rqst *rqst);
|
||||
extern void xdr_init_encode_pages(struct xdr_stream *xdr, struct xdr_buf *buf,
|
||||
struct page **pages, struct rpc_rqst *rqst);
|
||||
extern __be32 *xdr_reserve_space(struct xdr_stream *xdr, size_t nbytes);
|
||||
extern int xdr_reserve_space_vec(struct xdr_stream *xdr, struct kvec *vec,
|
||||
size_t nbytes);
|
||||
|
|
|
@ -946,6 +946,28 @@ void xdr_init_encode(struct xdr_stream *xdr, struct xdr_buf *buf, __be32 *p,
|
|||
}
|
||||
EXPORT_SYMBOL_GPL(xdr_init_encode);
|
||||
|
||||
/**
|
||||
* xdr_init_encode_pages - Initialize an xdr_stream for encoding into pages
|
||||
* @xdr: pointer to xdr_stream struct
|
||||
* @buf: pointer to XDR buffer into which to encode data
|
||||
* @pages: list of pages to decode into
|
||||
* @rqst: pointer to controlling rpc_rqst, for debugging
|
||||
*
|
||||
*/
|
||||
void xdr_init_encode_pages(struct xdr_stream *xdr, struct xdr_buf *buf,
|
||||
struct page **pages, struct rpc_rqst *rqst)
|
||||
{
|
||||
xdr_reset_scratch_buffer(xdr);
|
||||
|
||||
xdr->buf = buf;
|
||||
xdr->page_ptr = pages;
|
||||
xdr->iov = NULL;
|
||||
xdr->p = page_address(*pages);
|
||||
xdr->end = (void *)xdr->p + min_t(u32, buf->buflen, PAGE_SIZE);
|
||||
xdr->rqst = rqst;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(xdr_init_encode_pages);
|
||||
|
||||
/**
|
||||
* __xdr_commit_encode - Ensure all data is written to buffer
|
||||
* @xdr: pointer to xdr_stream
|
||||
|
|
Загрузка…
Ссылка в новой задаче