aboutsummaryrefslogtreecommitdiffstats
path: root/net
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
parentbd00f84bc57f42df32c728e86329a5c30f221657 (diff)
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')
-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)
747} 747}
748EXPORT_SYMBOL_GPL(xdr_inline_decode); 748EXPORT_SYMBOL_GPL(xdr_inline_decode);
749 749
750/** 750static unsigned int xdr_align_pages(struct xdr_stream *xdr, unsigned int len)
751 * xdr_read_pages - Ensure page-based XDR data to decode is aligned at current pointer position
752 * @xdr: pointer to xdr_stream struct
753 * @len: number of bytes of page data
754 *
755 * Moves data beyond the current pointer position from the XDR head[] buffer
756 * into the page list. Any data that lies beyond current position + "len"
757 * bytes is moved into the XDR tail[].
758 *
759 * Returns the number of XDR encoded bytes now contained in the pages
760 */
761unsigned int xdr_read_pages(struct xdr_stream *xdr, unsigned int len)
762{ 751{
763 struct xdr_buf *buf = xdr->buf; 752 struct xdr_buf *buf = xdr->buf;
764 struct kvec *iov; 753 struct kvec *iov;
765 unsigned int nwords = XDR_QUADLEN(len); 754 unsigned int nwords = XDR_QUADLEN(len);
766 unsigned int cur = xdr_stream_pos(xdr); 755 unsigned int cur = xdr_stream_pos(xdr);
767 unsigned int end;
768 unsigned int padding;
769 756
770 if (xdr->nwords == 0) 757 if (xdr->nwords == 0)
771 return 0; 758 return 0;
@@ -782,7 +769,32 @@ unsigned int xdr_read_pages(struct xdr_stream *xdr, unsigned int len)
782 if (buf->page_len > len) 769 if (buf->page_len > len)
783 xdr_shrink_pagelen(buf, buf->page_len - len); 770 xdr_shrink_pagelen(buf, buf->page_len - len);
784 xdr->nwords = XDR_QUADLEN(buf->len - cur); 771 xdr->nwords = XDR_QUADLEN(buf->len - cur);
772 return len;
773}
774
775/**
776 * xdr_read_pages - Ensure page-based XDR data to decode is aligned at current pointer position
777 * @xdr: pointer to xdr_stream struct
778 * @len: number of bytes of page data
779 *
780 * Moves data beyond the current pointer position from the XDR head[] buffer
781 * into the page list. Any data that lies beyond current position + "len"
782 * bytes is moved into the XDR tail[].
783 *
784 * Returns the number of XDR encoded bytes now contained in the pages
785 */
786unsigned int xdr_read_pages(struct xdr_stream *xdr, unsigned int len)
787{
788 struct xdr_buf *buf = xdr->buf;
789 struct kvec *iov;
790 unsigned int nwords;
791 unsigned int end;
792 unsigned int padding;
785 793
794 len = xdr_align_pages(xdr, len);
795 if (len == 0)
796 return 0;
797 nwords = XDR_QUADLEN(len);
786 padding = (nwords << 2) - len; 798 padding = (nwords << 2) - len;
787 xdr->iov = iov = buf->tail; 799 xdr->iov = iov = buf->tail;
788 /* Compute remaining message length. */ 800 /* Compute remaining message length. */