Commit c337d365 authored by Trond Myklebust's avatar Trond Myklebust

SUNRPC: xdr_read_pages should return the amount of XDR encoded page data

Callers of xdr_read_pages() will want to know exactly how much XDR
data is encoded in the pages after the data realignment.
Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
parent bfeea1dc
...@@ -223,7 +223,7 @@ extern void xdr_init_decode_pages(struct xdr_stream *xdr, struct xdr_buf *buf, ...@@ -223,7 +223,7 @@ extern void xdr_init_decode_pages(struct xdr_stream *xdr, struct xdr_buf *buf,
struct page **pages, unsigned int len); struct page **pages, unsigned int len);
extern void xdr_set_scratch_buffer(struct xdr_stream *xdr, void *buf, size_t buflen); extern void xdr_set_scratch_buffer(struct xdr_stream *xdr, void *buf, size_t buflen);
extern __be32 *xdr_inline_decode(struct xdr_stream *xdr, size_t nbytes); extern __be32 *xdr_inline_decode(struct xdr_stream *xdr, size_t nbytes);
extern void xdr_read_pages(struct xdr_stream *xdr, unsigned int len); extern unsigned int xdr_read_pages(struct xdr_stream *xdr, unsigned int len);
extern void xdr_enter_page(struct xdr_stream *xdr, unsigned int len); extern void xdr_enter_page(struct xdr_stream *xdr, unsigned int len);
extern int xdr_process_buf(struct xdr_buf *buf, unsigned int offset, unsigned int len, int (*actor)(struct scatterlist *, void *), void *data); extern int xdr_process_buf(struct xdr_buf *buf, unsigned int offset, unsigned int len, int (*actor)(struct scatterlist *, void *), void *data);
......
...@@ -745,8 +745,10 @@ EXPORT_SYMBOL_GPL(xdr_inline_decode); ...@@ -745,8 +745,10 @@ EXPORT_SYMBOL_GPL(xdr_inline_decode);
* Moves data beyond the current pointer position from the XDR head[] buffer * Moves data beyond the current pointer position from the XDR head[] buffer
* into the page list. Any data that lies beyond current position + "len" * into the page list. Any data that lies beyond current position + "len"
* bytes is moved into the XDR tail[]. * bytes is moved into the XDR tail[].
*
* Returns the number of XDR encoded bytes now contained in the pages
*/ */
void xdr_read_pages(struct xdr_stream *xdr, unsigned int len) unsigned int xdr_read_pages(struct xdr_stream *xdr, unsigned int len)
{ {
struct xdr_buf *buf = xdr->buf; struct xdr_buf *buf = xdr->buf;
struct kvec *iov; struct kvec *iov;
...@@ -756,7 +758,7 @@ void xdr_read_pages(struct xdr_stream *xdr, unsigned int len) ...@@ -756,7 +758,7 @@ void xdr_read_pages(struct xdr_stream *xdr, unsigned int len)
int padding; int padding;
if (xdr->nwords == 0) if (xdr->nwords == 0)
return; return 0;
if (nwords > xdr->nwords) { if (nwords > xdr->nwords) {
nwords = xdr->nwords; nwords = xdr->nwords;
len = nwords << 2; len = nwords << 2;
...@@ -787,6 +789,7 @@ void xdr_read_pages(struct xdr_stream *xdr, unsigned int len) ...@@ -787,6 +789,7 @@ void xdr_read_pages(struct xdr_stream *xdr, unsigned int len)
xdr->end = (__be32 *)((char *)iov->iov_base + end); xdr->end = (__be32 *)((char *)iov->iov_base + end);
xdr->page_ptr = NULL; xdr->page_ptr = NULL;
xdr->nwords = XDR_QUADLEN(end - padding); xdr->nwords = XDR_QUADLEN(end - padding);
return len;
} }
EXPORT_SYMBOL_GPL(xdr_read_pages); EXPORT_SYMBOL_GPL(xdr_read_pages);
...@@ -802,7 +805,7 @@ EXPORT_SYMBOL_GPL(xdr_read_pages); ...@@ -802,7 +805,7 @@ EXPORT_SYMBOL_GPL(xdr_read_pages);
*/ */
void xdr_enter_page(struct xdr_stream *xdr, unsigned int len) void xdr_enter_page(struct xdr_stream *xdr, unsigned int len)
{ {
xdr_read_pages(xdr, len); len = xdr_read_pages(xdr, len);
/* /*
* Position current pointer at beginning of tail, and * Position current pointer at beginning of tail, and
* set remaining message length. * set remaining message length.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment