diff options
author | J. Bruce Fields <bfields@redhat.com> | 2014-02-26 17:00:38 -0500 |
---|---|---|
committer | J. Bruce Fields <bfields@redhat.com> | 2014-05-28 14:52:35 -0400 |
commit | d3f627c815b6eb5f6be388100617c36823d661c5 (patch) | |
tree | 55d53651423a044c1219f05b2515f6ae86605dd7 /fs | |
parent | ddd1ea56367202f6c99135cd59de7a97af4c4ffd (diff) |
nfsd4: use xdr_stream throughout compound encoding
Note this makes ADJUST_ARGS useless; we'll remove it in the following
patch.
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/nfsd/nfs4proc.c | 2 | ||||
-rw-r--r-- | fs/nfsd/nfs4xdr.c | 23 |
2 files changed, 16 insertions, 9 deletions
diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c index 41c7c0a3ddd0..109b5a84b548 100644 --- a/fs/nfsd/nfs4proc.c +++ b/fs/nfsd/nfs4proc.c | |||
@@ -1284,7 +1284,7 @@ nfsd4_proc_compound(struct svc_rqst *rqstp, | |||
1284 | svcxdr_init_encode(rqstp, resp); | 1284 | svcxdr_init_encode(rqstp, resp); |
1285 | resp->tagp = resp->xdr.p; | 1285 | resp->tagp = resp->xdr.p; |
1286 | /* reserve space for: taglen, tag, and opcnt */ | 1286 | /* reserve space for: taglen, tag, and opcnt */ |
1287 | resp->xdr.p += 2 + XDR_QUADLEN(args->taglen); | 1287 | xdr_reserve_space(&resp->xdr, 8 + args->taglen); |
1288 | resp->taglen = args->taglen; | 1288 | resp->taglen = args->taglen; |
1289 | resp->tag = args->tag; | 1289 | resp->tag = args->tag; |
1290 | resp->opcnt = 0; | 1290 | resp->opcnt = 0; |
diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 27d1e94f12fb..5064cb5a0b8e 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c | |||
@@ -1747,10 +1747,10 @@ static void write_cinfo(__be32 **p, struct nfsd4_change_info *c) | |||
1747 | } | 1747 | } |
1748 | 1748 | ||
1749 | #define RESERVE_SPACE(nbytes) do { \ | 1749 | #define RESERVE_SPACE(nbytes) do { \ |
1750 | p = resp->xdr.p; \ | 1750 | p = xdr_reserve_space(&resp->xdr, nbytes); \ |
1751 | BUG_ON(p + XDR_QUADLEN(nbytes) > resp->xdr.end); \ | 1751 | BUG_ON(!p); \ |
1752 | } while (0) | 1752 | } while (0) |
1753 | #define ADJUST_ARGS() resp->xdr.p = p | 1753 | #define ADJUST_ARGS() WARN_ON_ONCE(p != resp->xdr.p) \ |
1754 | 1754 | ||
1755 | /* Encode as an array of strings the string given with components | 1755 | /* Encode as an array of strings the string given with components |
1756 | * separated @sep, escaped with esc_enter and esc_exit. | 1756 | * separated @sep, escaped with esc_enter and esc_exit. |
@@ -3056,8 +3056,11 @@ nfsd4_encode_read(struct nfsd4_compoundres *resp, __be32 nfserr, | |||
3056 | read->rd_offset, resp->rqstp->rq_vec, read->rd_vlen, | 3056 | read->rd_offset, resp->rqstp->rq_vec, read->rd_vlen, |
3057 | &maxcount); | 3057 | &maxcount); |
3058 | 3058 | ||
3059 | if (nfserr) | 3059 | if (nfserr) { |
3060 | xdr->p -= 2; | ||
3061 | xdr->iov->iov_len -= 8; | ||
3060 | return nfserr; | 3062 | return nfserr; |
3063 | } | ||
3061 | eof = (read->rd_offset + maxcount >= | 3064 | eof = (read->rd_offset + maxcount >= |
3062 | read->rd_fhp->fh_dentry->d_inode->i_size); | 3065 | read->rd_fhp->fh_dentry->d_inode->i_size); |
3063 | 3066 | ||
@@ -3110,9 +3113,12 @@ nfsd4_encode_readlink(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd | |||
3110 | */ | 3113 | */ |
3111 | nfserr = nfsd_readlink(readlink->rl_rqstp, readlink->rl_fhp, page, &maxcount); | 3114 | nfserr = nfsd_readlink(readlink->rl_rqstp, readlink->rl_fhp, page, &maxcount); |
3112 | if (nfserr == nfserr_isdir) | 3115 | if (nfserr == nfserr_isdir) |
3113 | return nfserr_inval; | 3116 | nfserr = nfserr_inval; |
3114 | if (nfserr) | 3117 | if (nfserr) { |
3118 | xdr->p--; | ||
3119 | xdr->iov->iov_len -= 4; | ||
3115 | return nfserr; | 3120 | return nfserr; |
3121 | } | ||
3116 | 3122 | ||
3117 | WRITE32(maxcount); | 3123 | WRITE32(maxcount); |
3118 | ADJUST_ARGS(); | 3124 | ADJUST_ARGS(); |
@@ -3213,8 +3219,9 @@ nfsd4_encode_readdir(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4 | |||
3213 | 3219 | ||
3214 | return 0; | 3220 | return 0; |
3215 | err_no_verf: | 3221 | err_no_verf: |
3216 | p = savep; | 3222 | xdr->p = savep; |
3217 | ADJUST_ARGS(); | 3223 | xdr->iov->iov_len = ((char *)resp->xdr.p) |
3224 | - (char *)resp->xdr.buf->head[0].iov_base; | ||
3218 | return nfserr; | 3225 | return nfserr; |
3219 | } | 3226 | } |
3220 | 3227 | ||