Commit 05638dc7 authored by J. Bruce Fields's avatar J. Bruce Fields

nfsd4: simplify server xdr->next_page use

The rpc code makes available to the NFS server an array of pages to
encod into.  The server represents its reply as an xdr buf, with the
head pointing into the first page in that array, the pages ** array
starting just after that, and the tail (if any) sharing any leftover
space in the page used by the head.

While encoding, we use xdr_stream->page_ptr to keep track of which page
we're currently using.

Currently we set xdr_stream->page_ptr to buf->pages, which makes the
head a weird exception to the rule that page_ptr always points to the
page we're currently encoding into.  So, instead set it to buf->pages -
1 (the page actually containing the head), and remove the need for a
little unintuitive logic in xdr_get_next_encode_buffer() and
xdr_truncate_encode.
Signed-off-by: default avatarJ. Bruce Fields <bfields@redhat.com>
parent 3fb87d13
...@@ -1264,7 +1264,7 @@ static void svcxdr_init_encode(struct svc_rqst *rqstp, ...@@ -1264,7 +1264,7 @@ static void svcxdr_init_encode(struct svc_rqst *rqstp,
/* Tail and page_len should be zero at this point: */ /* Tail and page_len should be zero at this point: */
buf->len = buf->head[0].iov_len; buf->len = buf->head[0].iov_len;
xdr->scratch.iov_len = 0; xdr->scratch.iov_len = 0;
xdr->page_ptr = buf->pages; xdr->page_ptr = buf->pages - 1;
buf->buflen = PAGE_SIZE * (1 + rqstp->rq_page_end - buf->pages) buf->buflen = PAGE_SIZE * (1 + rqstp->rq_page_end - buf->pages)
- rqstp->rq_auth_slack; - rqstp->rq_auth_slack;
} }
......
...@@ -523,10 +523,9 @@ __be32 *xdr_get_next_encode_buffer(struct xdr_stream *xdr, size_t nbytes) ...@@ -523,10 +523,9 @@ __be32 *xdr_get_next_encode_buffer(struct xdr_stream *xdr, size_t nbytes)
frag2bytes = nbytes - frag1bytes; frag2bytes = nbytes - frag1bytes;
if (xdr->iov) if (xdr->iov)
xdr->iov->iov_len += frag1bytes; xdr->iov->iov_len += frag1bytes;
else { else
xdr->buf->page_len += frag1bytes; xdr->buf->page_len += frag1bytes;
xdr->page_ptr++; xdr->page_ptr++;
}
xdr->iov = NULL; xdr->iov = NULL;
/* /*
* If the last encode didn't end exactly on a page boundary, the * If the last encode didn't end exactly on a page boundary, the
...@@ -638,8 +637,10 @@ void xdr_truncate_encode(struct xdr_stream *xdr, size_t len) ...@@ -638,8 +637,10 @@ void xdr_truncate_encode(struct xdr_stream *xdr, size_t len)
/* xdr->iov should already be NULL */ /* xdr->iov should already be NULL */
return; return;
} }
if (fraglen) if (fraglen) {
xdr->end = head->iov_base + head->iov_len; xdr->end = head->iov_base + head->iov_len;
xdr->page_ptr--;
}
/* (otherwise assume xdr->end is already set) */ /* (otherwise assume xdr->end is already set) */
head->iov_len = len; head->iov_len = len;
buf->len = len; buf->len = len;
......
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