aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2010-10-19 19:58:49 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2010-10-23 15:27:32 -0400
commitba8e452a4fe64a51b74d43761e14d99f0666cc45 (patch)
tree7237e9bf9f2415eda15fec5e517da3340342e9f1
parent0715dc632a271fc0fedf3ef4779fe28ac1e53ef4 (diff)
SUNRPC: Add a helper function xdr_inline_peek
We sometimes need to be able to read ahead in an xdr_stream without incrementing the current pointer position. Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
-rw-r--r--include/linux/sunrpc/xdr.h1
-rw-r--r--net/sunrpc/xdr.c21
2 files changed, 22 insertions, 0 deletions
diff --git a/include/linux/sunrpc/xdr.h b/include/linux/sunrpc/xdr.h
index 8c1dcbb54d89..ab91d86565fd 100644
--- a/include/linux/sunrpc/xdr.h
+++ b/include/linux/sunrpc/xdr.h
@@ -201,6 +201,7 @@ extern __be32 *xdr_reserve_space(struct xdr_stream *xdr, size_t nbytes);
201extern void xdr_write_pages(struct xdr_stream *xdr, struct page **pages, 201extern void xdr_write_pages(struct xdr_stream *xdr, struct page **pages,
202 unsigned int base, unsigned int len); 202 unsigned int base, unsigned int len);
203extern void xdr_init_decode(struct xdr_stream *xdr, struct xdr_buf *buf, __be32 *p); 203extern void xdr_init_decode(struct xdr_stream *xdr, struct xdr_buf *buf, __be32 *p);
204extern __be32 *xdr_inline_peek(struct xdr_stream *xdr, size_t nbytes);
204extern __be32 *xdr_inline_decode(struct xdr_stream *xdr, size_t nbytes); 205extern __be32 *xdr_inline_decode(struct xdr_stream *xdr, size_t nbytes);
205extern void xdr_read_pages(struct xdr_stream *xdr, unsigned int len); 206extern void xdr_read_pages(struct xdr_stream *xdr, unsigned int len);
206extern void xdr_enter_page(struct xdr_stream *xdr, unsigned int len); 207extern void xdr_enter_page(struct xdr_stream *xdr, unsigned int len);
diff --git a/net/sunrpc/xdr.c b/net/sunrpc/xdr.c
index e0725d9d8107..cd9e841e7492 100644
--- a/net/sunrpc/xdr.c
+++ b/net/sunrpc/xdr.c
@@ -573,6 +573,27 @@ void xdr_init_decode(struct xdr_stream *xdr, struct xdr_buf *buf, __be32 *p)
573EXPORT_SYMBOL_GPL(xdr_init_decode); 573EXPORT_SYMBOL_GPL(xdr_init_decode);
574 574
575/** 575/**
576 * xdr_inline_peek - Allow read-ahead in the XDR data stream
577 * @xdr: pointer to xdr_stream struct
578 * @nbytes: number of bytes of data to decode
579 *
580 * Check if the input buffer is long enough to enable us to decode
581 * 'nbytes' more bytes of data starting at the current position.
582 * If so return the current pointer without updating the current
583 * pointer position.
584 */
585__be32 * xdr_inline_peek(struct xdr_stream *xdr, size_t nbytes)
586{
587 __be32 *p = xdr->p;
588 __be32 *q = p + XDR_QUADLEN(nbytes);
589
590 if (unlikely(q > xdr->end || q < p))
591 return NULL;
592 return p;
593}
594EXPORT_SYMBOL_GPL(xdr_inline_peek);
595
596/**
576 * xdr_inline_decode - Retrieve non-page XDR data to decode 597 * xdr_inline_decode - Retrieve non-page XDR data to decode
577 * @xdr: pointer to xdr_stream struct 598 * @xdr: pointer to xdr_stream struct
578 * @nbytes: number of bytes of data to decode 599 * @nbytes: number of bytes of data to decode