diff options
author | J. Bruce Fields <bfields@redhat.com> | 2012-12-14 17:57:50 -0500 |
---|---|---|
committer | J. Bruce Fields <bfields@redhat.com> | 2013-01-23 18:17:35 -0500 |
commit | 84822d0b3bc5a74a4290727dd1ab4fc7dcd6a348 (patch) | |
tree | 4d63b1766e3eb7944395073506e0454eed2e22dd | |
parent | d1c3ed669a2d452cacfb48c2d171a1f364dae2ed (diff) |
nfsd4: simplify nfsd4_encode_fattr interface slightly
It seems slightly simpler to make nfsd4_encode_fattr rather than its
callers responsible for advancing the write pointer on success.
(Also: the count == 0 check in the verify case looks superfluous.
Running out of buffer space is really the only reason fattr encoding
should fail with eresource.)
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
-rw-r--r-- | fs/nfsd/nfs4proc.c | 7 | ||||
-rw-r--r-- | fs/nfsd/nfs4xdr.c | 21 | ||||
-rw-r--r-- | fs/nfsd/xdr4.h | 2 |
3 files changed, 13 insertions, 17 deletions
diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c index 9d1c5dba2bbb..ae73175e6e68 100644 --- a/fs/nfsd/nfs4proc.c +++ b/fs/nfsd/nfs4proc.c | |||
@@ -993,14 +993,15 @@ _nfsd4_verify(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, | |||
993 | if (!buf) | 993 | if (!buf) |
994 | return nfserr_jukebox; | 994 | return nfserr_jukebox; |
995 | 995 | ||
996 | p = buf; | ||
996 | status = nfsd4_encode_fattr(&cstate->current_fh, | 997 | status = nfsd4_encode_fattr(&cstate->current_fh, |
997 | cstate->current_fh.fh_export, | 998 | cstate->current_fh.fh_export, |
998 | cstate->current_fh.fh_dentry, buf, | 999 | cstate->current_fh.fh_dentry, &p, |
999 | &count, verify->ve_bmval, | 1000 | count, verify->ve_bmval, |
1000 | rqstp, 0); | 1001 | rqstp, 0); |
1001 | 1002 | ||
1002 | /* this means that nfsd4_encode_fattr() ran out of space */ | 1003 | /* this means that nfsd4_encode_fattr() ran out of space */ |
1003 | if (status == nfserr_resource && count == 0) | 1004 | if (status == nfserr_resource) |
1004 | status = nfserr_not_same; | 1005 | status = nfserr_not_same; |
1005 | if (status) | 1006 | if (status) |
1006 | goto out_kfree; | 1007 | goto out_kfree; |
diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 0dc11586682f..fcb5bed99c33 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c | |||
@@ -2006,12 +2006,11 @@ static int get_parent_attributes(struct svc_export *exp, struct kstat *stat) | |||
2006 | * Note: @fhp can be NULL; in this case, we might have to compose the filehandle | 2006 | * Note: @fhp can be NULL; in this case, we might have to compose the filehandle |
2007 | * ourselves. | 2007 | * ourselves. |
2008 | * | 2008 | * |
2009 | * @countp is the buffer size in _words_; upon successful return this becomes | 2009 | * countp is the buffer size in _words_ |
2010 | * replaced with the number of words written. | ||
2011 | */ | 2010 | */ |
2012 | __be32 | 2011 | __be32 |
2013 | nfsd4_encode_fattr(struct svc_fh *fhp, struct svc_export *exp, | 2012 | nfsd4_encode_fattr(struct svc_fh *fhp, struct svc_export *exp, |
2014 | struct dentry *dentry, __be32 *buffer, int *countp, u32 *bmval, | 2013 | struct dentry *dentry, __be32 **buffer, int count, u32 *bmval, |
2015 | struct svc_rqst *rqstp, int ignore_crossmnt) | 2014 | struct svc_rqst *rqstp, int ignore_crossmnt) |
2016 | { | 2015 | { |
2017 | u32 bmval0 = bmval[0]; | 2016 | u32 bmval0 = bmval[0]; |
@@ -2020,12 +2019,12 @@ nfsd4_encode_fattr(struct svc_fh *fhp, struct svc_export *exp, | |||
2020 | struct kstat stat; | 2019 | struct kstat stat; |
2021 | struct svc_fh tempfh; | 2020 | struct svc_fh tempfh; |
2022 | struct kstatfs statfs; | 2021 | struct kstatfs statfs; |
2023 | int buflen = *countp << 2; | 2022 | int buflen = count << 2; |
2024 | __be32 *attrlenp; | 2023 | __be32 *attrlenp; |
2025 | u32 dummy; | 2024 | u32 dummy; |
2026 | u64 dummy64; | 2025 | u64 dummy64; |
2027 | u32 rdattr_err = 0; | 2026 | u32 rdattr_err = 0; |
2028 | __be32 *p = buffer; | 2027 | __be32 *p = *buffer; |
2029 | __be32 status; | 2028 | __be32 status; |
2030 | int err; | 2029 | int err; |
2031 | int aclsupport = 0; | 2030 | int aclsupport = 0; |
@@ -2431,7 +2430,7 @@ out_acl: | |||
2431 | } | 2430 | } |
2432 | 2431 | ||
2433 | *attrlenp = htonl((char *)p - (char *)attrlenp - 4); | 2432 | *attrlenp = htonl((char *)p - (char *)attrlenp - 4); |
2434 | *countp = p - buffer; | 2433 | *buffer = p; |
2435 | status = nfs_ok; | 2434 | status = nfs_ok; |
2436 | 2435 | ||
2437 | out: | 2436 | out: |
@@ -2443,7 +2442,6 @@ out_nfserr: | |||
2443 | status = nfserrno(err); | 2442 | status = nfserrno(err); |
2444 | goto out; | 2443 | goto out; |
2445 | out_resource: | 2444 | out_resource: |
2446 | *countp = 0; | ||
2447 | status = nfserr_resource; | 2445 | status = nfserr_resource; |
2448 | goto out; | 2446 | goto out; |
2449 | out_serverfault: | 2447 | out_serverfault: |
@@ -2462,7 +2460,7 @@ static inline int attributes_need_mount(u32 *bmval) | |||
2462 | 2460 | ||
2463 | static __be32 | 2461 | static __be32 |
2464 | nfsd4_encode_dirent_fattr(struct nfsd4_readdir *cd, | 2462 | nfsd4_encode_dirent_fattr(struct nfsd4_readdir *cd, |
2465 | const char *name, int namlen, __be32 *p, int *buflen) | 2463 | const char *name, int namlen, __be32 **p, int buflen) |
2466 | { | 2464 | { |
2467 | struct svc_export *exp = cd->rd_fhp->fh_export; | 2465 | struct svc_export *exp = cd->rd_fhp->fh_export; |
2468 | struct dentry *dentry; | 2466 | struct dentry *dentry; |
@@ -2568,10 +2566,9 @@ nfsd4_encode_dirent(void *ccdv, const char *name, int namlen, | |||
2568 | p = xdr_encode_hyper(p, NFS_OFFSET_MAX); /* offset of next entry */ | 2566 | p = xdr_encode_hyper(p, NFS_OFFSET_MAX); /* offset of next entry */ |
2569 | p = xdr_encode_array(p, name, namlen); /* name length & name */ | 2567 | p = xdr_encode_array(p, name, namlen); /* name length & name */ |
2570 | 2568 | ||
2571 | nfserr = nfsd4_encode_dirent_fattr(cd, name, namlen, p, &buflen); | 2569 | nfserr = nfsd4_encode_dirent_fattr(cd, name, namlen, &p, buflen); |
2572 | switch (nfserr) { | 2570 | switch (nfserr) { |
2573 | case nfs_ok: | 2571 | case nfs_ok: |
2574 | p += buflen; | ||
2575 | break; | 2572 | break; |
2576 | case nfserr_resource: | 2573 | case nfserr_resource: |
2577 | nfserr = nfserr_toosmall; | 2574 | nfserr = nfserr_toosmall; |
@@ -2698,10 +2695,8 @@ nfsd4_encode_getattr(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4 | |||
2698 | 2695 | ||
2699 | buflen = resp->end - resp->p - (COMPOUND_ERR_SLACK_SPACE >> 2); | 2696 | buflen = resp->end - resp->p - (COMPOUND_ERR_SLACK_SPACE >> 2); |
2700 | nfserr = nfsd4_encode_fattr(fhp, fhp->fh_export, fhp->fh_dentry, | 2697 | nfserr = nfsd4_encode_fattr(fhp, fhp->fh_export, fhp->fh_dentry, |
2701 | resp->p, &buflen, getattr->ga_bmval, | 2698 | &resp->p, buflen, getattr->ga_bmval, |
2702 | resp->rqstp, 0); | 2699 | resp->rqstp, 0); |
2703 | if (!nfserr) | ||
2704 | resp->p += buflen; | ||
2705 | return nfserr; | 2700 | return nfserr; |
2706 | } | 2701 | } |
2707 | 2702 | ||
diff --git a/fs/nfsd/xdr4.h b/fs/nfsd/xdr4.h index 0889bfb43dc9..546f8983ecf1 100644 --- a/fs/nfsd/xdr4.h +++ b/fs/nfsd/xdr4.h | |||
@@ -563,7 +563,7 @@ __be32 nfsd4_check_resp_size(struct nfsd4_compoundres *, u32); | |||
563 | void nfsd4_encode_operation(struct nfsd4_compoundres *, struct nfsd4_op *); | 563 | void nfsd4_encode_operation(struct nfsd4_compoundres *, struct nfsd4_op *); |
564 | void nfsd4_encode_replay(struct nfsd4_compoundres *resp, struct nfsd4_op *op); | 564 | void nfsd4_encode_replay(struct nfsd4_compoundres *resp, struct nfsd4_op *op); |
565 | __be32 nfsd4_encode_fattr(struct svc_fh *fhp, struct svc_export *exp, | 565 | __be32 nfsd4_encode_fattr(struct svc_fh *fhp, struct svc_export *exp, |
566 | struct dentry *dentry, __be32 *buffer, int *countp, | 566 | struct dentry *dentry, __be32 **buffer, int countp, |
567 | u32 *bmval, struct svc_rqst *, int ignore_crossmnt); | 567 | u32 *bmval, struct svc_rqst *, int ignore_crossmnt); |
568 | extern __be32 nfsd4_setclientid(struct svc_rqst *rqstp, | 568 | extern __be32 nfsd4_setclientid(struct svc_rqst *rqstp, |
569 | struct nfsd4_compound_state *, | 569 | struct nfsd4_compound_state *, |