diff options
author | J. Bruce Fields <bfields@redhat.com> | 2014-02-26 17:39:35 -0500 |
---|---|---|
committer | J. Bruce Fields <bfields@redhat.com> | 2014-05-28 14:52:38 -0400 |
commit | 6ac90391c6e36c536cfcedbe4801a77e304205b1 (patch) | |
tree | 0f6b49ec7ec6c84bd46c5646b3c3444c81ce230f /fs/nfsd/nfs4xdr.c | |
parent | dd97fddedc251eb423408d89f2947eff9c4ea3c1 (diff) |
nfsd4: keep xdr buf length updated
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'fs/nfsd/nfs4xdr.c')
-rw-r--r-- | fs/nfsd/nfs4xdr.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 79b8e1ef0f39..57f60810b745 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c | |||
@@ -3046,6 +3046,7 @@ nfsd4_encode_read(struct nfsd4_compoundres *resp, __be32 nfserr, | |||
3046 | if (nfserr) { | 3046 | if (nfserr) { |
3047 | xdr->p -= 2; | 3047 | xdr->p -= 2; |
3048 | xdr->iov->iov_len -= 8; | 3048 | xdr->iov->iov_len -= 8; |
3049 | xdr->buf->len -= 8; | ||
3049 | return nfserr; | 3050 | return nfserr; |
3050 | } | 3051 | } |
3051 | eof = (read->rd_offset + maxcount >= | 3052 | eof = (read->rd_offset + maxcount >= |
@@ -3053,9 +3054,10 @@ nfsd4_encode_read(struct nfsd4_compoundres *resp, __be32 nfserr, | |||
3053 | 3054 | ||
3054 | WRITE32(eof); | 3055 | WRITE32(eof); |
3055 | WRITE32(maxcount); | 3056 | WRITE32(maxcount); |
3056 | resp->xdr.buf->head[0].iov_len = (char *)p | 3057 | WARN_ON_ONCE(resp->xdr.buf->head[0].iov_len != (char *)p |
3057 | - (char *)resp->xdr.buf->head[0].iov_base; | 3058 | - (char *)resp->xdr.buf->head[0].iov_base); |
3058 | resp->xdr.buf->page_len = maxcount; | 3059 | resp->xdr.buf->page_len = maxcount; |
3060 | xdr->buf->len += maxcount; | ||
3059 | xdr->iov = xdr->buf->tail; | 3061 | xdr->iov = xdr->buf->tail; |
3060 | 3062 | ||
3061 | /* Use rest of head for padding and remaining ops: */ | 3063 | /* Use rest of head for padding and remaining ops: */ |
@@ -3066,6 +3068,7 @@ nfsd4_encode_read(struct nfsd4_compoundres *resp, __be32 nfserr, | |||
3066 | WRITE32(0); | 3068 | WRITE32(0); |
3067 | resp->xdr.buf->tail[0].iov_base += maxcount&3; | 3069 | resp->xdr.buf->tail[0].iov_base += maxcount&3; |
3068 | resp->xdr.buf->tail[0].iov_len = 4 - (maxcount&3); | 3070 | resp->xdr.buf->tail[0].iov_len = 4 - (maxcount&3); |
3071 | xdr->buf->len -= (maxcount&3); | ||
3069 | } | 3072 | } |
3070 | return 0; | 3073 | return 0; |
3071 | } | 3074 | } |
@@ -3102,6 +3105,7 @@ nfsd4_encode_readlink(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd | |||
3102 | if (nfserr) { | 3105 | if (nfserr) { |
3103 | xdr->p--; | 3106 | xdr->p--; |
3104 | xdr->iov->iov_len -= 4; | 3107 | xdr->iov->iov_len -= 4; |
3108 | xdr->buf->len -= 4; | ||
3105 | return nfserr; | 3109 | return nfserr; |
3106 | } | 3110 | } |
3107 | 3111 | ||
@@ -3109,6 +3113,7 @@ nfsd4_encode_readlink(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd | |||
3109 | resp->xdr.buf->head[0].iov_len = (char *)p | 3113 | resp->xdr.buf->head[0].iov_len = (char *)p |
3110 | - (char *)resp->xdr.buf->head[0].iov_base; | 3114 | - (char *)resp->xdr.buf->head[0].iov_base; |
3111 | resp->xdr.buf->page_len = maxcount; | 3115 | resp->xdr.buf->page_len = maxcount; |
3116 | xdr->buf->len += maxcount; | ||
3112 | xdr->iov = xdr->buf->tail; | 3117 | xdr->iov = xdr->buf->tail; |
3113 | 3118 | ||
3114 | /* Use rest of head for padding and remaining ops: */ | 3119 | /* Use rest of head for padding and remaining ops: */ |
@@ -3189,6 +3194,7 @@ nfsd4_encode_readdir(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4 | |||
3189 | *p++ = htonl(readdir->common.err == nfserr_eof); | 3194 | *p++ = htonl(readdir->common.err == nfserr_eof); |
3190 | resp->xdr.buf->page_len = ((char *)p) - | 3195 | resp->xdr.buf->page_len = ((char *)p) - |
3191 | (char*)page_address(*(resp->rqstp->rq_next_page-1)); | 3196 | (char*)page_address(*(resp->rqstp->rq_next_page-1)); |
3197 | xdr->buf->len += xdr->buf->page_len; | ||
3192 | 3198 | ||
3193 | xdr->iov = xdr->buf->tail; | 3199 | xdr->iov = xdr->buf->tail; |
3194 | 3200 | ||
@@ -3204,6 +3210,7 @@ err_no_verf: | |||
3204 | xdr->p = savep; | 3210 | xdr->p = savep; |
3205 | xdr->iov->iov_len = ((char *)resp->xdr.p) | 3211 | xdr->iov->iov_len = ((char *)resp->xdr.p) |
3206 | - (char *)resp->xdr.buf->head[0].iov_base; | 3212 | - (char *)resp->xdr.buf->head[0].iov_base; |
3213 | xdr->buf->len = xdr->iov->iov_len; | ||
3207 | return nfserr; | 3214 | return nfserr; |
3208 | } | 3215 | } |
3209 | 3216 | ||
@@ -3789,6 +3796,10 @@ nfs4svc_encode_compoundres(struct svc_rqst *rqstp, __be32 *p, struct nfsd4_compo | |||
3789 | * All that remains is to write the tag and operation count... | 3796 | * All that remains is to write the tag and operation count... |
3790 | */ | 3797 | */ |
3791 | struct nfsd4_compound_state *cs = &resp->cstate; | 3798 | struct nfsd4_compound_state *cs = &resp->cstate; |
3799 | struct xdr_buf *buf = resp->xdr.buf; | ||
3800 | |||
3801 | WARN_ON_ONCE(buf->len != buf->head[0].iov_len + buf->page_len + | ||
3802 | buf->tail[0].iov_len); | ||
3792 | 3803 | ||
3793 | p = resp->tagp; | 3804 | p = resp->tagp; |
3794 | *p++ = htonl(resp->taglen); | 3805 | *p++ = htonl(resp->taglen); |