summaryrefslogtreecommitdiffstats
path: root/net/sunrpc/xdr.c
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2012-06-26 12:34:05 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2012-06-28 17:20:46 -0400
commit3994ee6fbf5185b3183f4585432226e786bfe86c (patch)
treeafa20b81b7cddd6fce09da05f7df7edca5e411a4 /net/sunrpc/xdr.c
parentbd00f84bc57f42df32c728e86329a5c30f221657 (diff)
downloadlinux-3994ee6fbf5185b3183f4585432226e786bfe86c.tar.bz2
SUNRPC: Clean up xdr_read_pages
Move the page alignment code into a separate helper. Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'net/sunrpc/xdr.c')
-rw-r--r--net/sunrpc/xdr.c40
1 files changed, 26 insertions, 14 deletions
diff --git a/net/sunrpc/xdr.c b/net/sunrpc/xdr.c
index 834d4da9cdb0..03603f332fe6 100644
--- a/net/sunrpc/xdr.c
+++ b/net/sunrpc/xdr.c
@@ -747,25 +747,12 @@ __be32 * xdr_inline_decode(struct xdr_stream *xdr, size_t nbytes)
}
EXPORT_SYMBOL_GPL(xdr_inline_decode);
-/**
- * xdr_read_pages - Ensure page-based XDR data to decode is aligned at current pointer position
- * @xdr: pointer to xdr_stream struct
- * @len: number of bytes of page data
- *
- * Moves data beyond the current pointer position from the XDR head[] buffer
- * into the page list. Any data that lies beyond current position + "len"
- * bytes is moved into the XDR tail[].
- *
- * Returns the number of XDR encoded bytes now contained in the pages
- */
-unsigned int xdr_read_pages(struct xdr_stream *xdr, unsigned int len)
+static unsigned int xdr_align_pages(struct xdr_stream *xdr, unsigned int len)
{
struct xdr_buf *buf = xdr->buf;
struct kvec *iov;
unsigned int nwords = XDR_QUADLEN(len);
unsigned int cur = xdr_stream_pos(xdr);
- unsigned int end;
- unsigned int padding;
if (xdr->nwords == 0)
return 0;
@@ -782,7 +769,32 @@ unsigned int xdr_read_pages(struct xdr_stream *xdr, unsigned int len)
if (buf->page_len > len)
xdr_shrink_pagelen(buf, buf->page_len - len);
xdr->nwords = XDR_QUADLEN(buf->len - cur);
+ return len;
+}
+
+/**
+ * xdr_read_pages - Ensure page-based XDR data to decode is aligned at current pointer position
+ * @xdr: pointer to xdr_stream struct
+ * @len: number of bytes of page data
+ *
+ * Moves data beyond the current pointer position from the XDR head[] buffer
+ * into the page list. Any data that lies beyond current position + "len"
+ * bytes is moved into the XDR tail[].
+ *
+ * Returns the number of XDR encoded bytes now contained in the pages
+ */
+unsigned int xdr_read_pages(struct xdr_stream *xdr, unsigned int len)
+{
+ struct xdr_buf *buf = xdr->buf;
+ struct kvec *iov;
+ unsigned int nwords;
+ unsigned int end;
+ unsigned int padding;
+ len = xdr_align_pages(xdr, len);
+ if (len == 0)
+ return 0;
+ nwords = XDR_QUADLEN(len);
padding = (nwords << 2) - len;
xdr->iov = iov = buf->tail;
/* Compute remaining message length. */