Skip to content

Commit

Permalink
SUNRPC: Split out a function for setting current page
Browse files Browse the repository at this point in the history
I'm going to need this bit of code in a few places for READ_PLUS
decoding, so let's make it a helper function.

Signed-off-by: Anna Schumaker <[email protected]>
  • Loading branch information
amschuma-ntap committed Oct 7, 2020
1 parent 247db73 commit f7d61ee
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions net/sunrpc/xdr.c
Original file line number Diff line number Diff line change
Expand Up @@ -825,24 +825,29 @@ static int xdr_set_page_base(struct xdr_stream *xdr,
return 0;
}

static void xdr_set_page(struct xdr_stream *xdr, unsigned int base,
unsigned int len)
{
if (xdr_set_page_base(xdr, base, len) < 0)
xdr_set_iov(xdr, xdr->buf->tail, xdr->nwords << 2);
}

static void xdr_set_next_page(struct xdr_stream *xdr)
{
unsigned int newbase;

newbase = (1 + xdr->page_ptr - xdr->buf->pages) << PAGE_SHIFT;
newbase -= xdr->buf->page_base;

if (xdr_set_page_base(xdr, newbase, PAGE_SIZE) < 0)
xdr_set_iov(xdr, xdr->buf->tail, xdr->nwords << 2);
xdr_set_page(xdr, newbase, PAGE_SIZE);
}

static bool xdr_set_next_buffer(struct xdr_stream *xdr)
{
if (xdr->page_ptr != NULL)
xdr_set_next_page(xdr);
else if (xdr->iov == xdr->buf->head) {
if (xdr_set_page_base(xdr, 0, PAGE_SIZE) < 0)
xdr_set_iov(xdr, xdr->buf->tail, xdr->nwords << 2);
xdr_set_page(xdr, 0, PAGE_SIZE);
}
return xdr->p != xdr->end;
}
Expand Down

0 comments on commit f7d61ee

Please sign in to comment.