aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfsd/nfs4xdr.c
diff options
context:
space:
mode:
authorJ. Bruce Fields <bfields@redhat.com>2014-05-19 16:18:23 -0400
committerJ. Bruce Fields <bfields@redhat.com>2014-05-30 17:32:00 -0400
commit30596768b31069a3ae08fc305f394efb8c42b473 (patch)
tree0cd29bfdb5396b795345c45d048707e70affd2f8 /fs/nfsd/nfs4xdr.c
parent89ff884ebbd0a667253dd61ade8a0e70b787c84a (diff)
nfsd4: fix buflen calculation after read encoding
We don't necessarily want to assume that the buflen is the same as the number of bytes available in the pages. We may have some reason to set it to something less (for example, later patches will use a smaller buflen to enforce session limits). So, calculate the buflen relative to the previous buflen instead of recalculating it from scratch. Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'fs/nfsd/nfs4xdr.c')
-rw-r--r--fs/nfsd/nfs4xdr.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
index 0eeba2199c8c..1278d98a923c 100644
--- a/fs/nfsd/nfs4xdr.c
+++ b/fs/nfsd/nfs4xdr.c
@@ -3053,6 +3053,7 @@ nfsd4_encode_read(struct nfsd4_compoundres *resp, __be32 nfserr,
3053 unsigned long maxcount; 3053 unsigned long maxcount;
3054 struct xdr_stream *xdr = &resp->xdr; 3054 struct xdr_stream *xdr = &resp->xdr;
3055 int starting_len = xdr->buf->len; 3055 int starting_len = xdr->buf->len;
3056 int space_left;
3056 long len; 3057 long len;
3057 __be32 *p; 3058 __be32 *p;
3058 3059
@@ -3117,7 +3118,6 @@ nfsd4_encode_read(struct nfsd4_compoundres *resp, __be32 nfserr,
3117 resp->xdr.buf->page_len = maxcount; 3118 resp->xdr.buf->page_len = maxcount;
3118 xdr->buf->len += maxcount; 3119 xdr->buf->len += maxcount;
3119 xdr->page_ptr += v; 3120 xdr->page_ptr += v;
3120 xdr->buf->buflen = maxcount + PAGE_SIZE - 2 * RPC_MAX_AUTH_SIZE;
3121 xdr->iov = xdr->buf->tail; 3121 xdr->iov = xdr->buf->tail;
3122 3122
3123 /* Use rest of head for padding and remaining ops: */ 3123 /* Use rest of head for padding and remaining ops: */
@@ -3130,6 +3130,12 @@ nfsd4_encode_read(struct nfsd4_compoundres *resp, __be32 nfserr,
3130 resp->xdr.buf->tail[0].iov_len = 4 - (maxcount&3); 3130 resp->xdr.buf->tail[0].iov_len = 4 - (maxcount&3);
3131 xdr->buf->len -= (maxcount&3); 3131 xdr->buf->len -= (maxcount&3);
3132 } 3132 }
3133
3134 space_left = min_t(int, (void *)xdr->end - (void *)xdr->p,
3135 xdr->buf->buflen - xdr->buf->len);
3136 xdr->buf->buflen = xdr->buf->len + space_left;
3137 xdr->end = (__be32 *)((void *)xdr->end + space_left);
3138
3133 return 0; 3139 return 0;
3134} 3140}
3135 3141