Commit 84822d0b authored by J. Bruce Fields's avatar J. Bruce Fields

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: default avatarJ. Bruce Fields <bfields@redhat.com>
parent d1c3ed66
...@@ -993,14 +993,15 @@ _nfsd4_verify(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, ...@@ -993,14 +993,15 @@ _nfsd4_verify(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
if (!buf) if (!buf)
return nfserr_jukebox; return nfserr_jukebox;
p = buf;
status = nfsd4_encode_fattr(&cstate->current_fh, status = nfsd4_encode_fattr(&cstate->current_fh,
cstate->current_fh.fh_export, cstate->current_fh.fh_export,
cstate->current_fh.fh_dentry, buf, cstate->current_fh.fh_dentry, &p,
&count, verify->ve_bmval, count, verify->ve_bmval,
rqstp, 0); rqstp, 0);
/* this means that nfsd4_encode_fattr() ran out of space */ /* this means that nfsd4_encode_fattr() ran out of space */
if (status == nfserr_resource && count == 0) if (status == nfserr_resource)
status = nfserr_not_same; status = nfserr_not_same;
if (status) if (status)
goto out_kfree; goto out_kfree;
......
...@@ -2006,12 +2006,11 @@ static int get_parent_attributes(struct svc_export *exp, struct kstat *stat) ...@@ -2006,12 +2006,11 @@ static int get_parent_attributes(struct svc_export *exp, struct kstat *stat)
* Note: @fhp can be NULL; in this case, we might have to compose the filehandle * Note: @fhp can be NULL; in this case, we might have to compose the filehandle
* ourselves. * ourselves.
* *
* @countp is the buffer size in _words_; upon successful return this becomes * countp is the buffer size in _words_
* replaced with the number of words written.
*/ */
__be32 __be32
nfsd4_encode_fattr(struct svc_fh *fhp, struct svc_export *exp, nfsd4_encode_fattr(struct svc_fh *fhp, struct svc_export *exp,
struct dentry *dentry, __be32 *buffer, int *countp, u32 *bmval, struct dentry *dentry, __be32 **buffer, int count, u32 *bmval,
struct svc_rqst *rqstp, int ignore_crossmnt) struct svc_rqst *rqstp, int ignore_crossmnt)
{ {
u32 bmval0 = bmval[0]; u32 bmval0 = bmval[0];
...@@ -2020,12 +2019,12 @@ nfsd4_encode_fattr(struct svc_fh *fhp, struct svc_export *exp, ...@@ -2020,12 +2019,12 @@ nfsd4_encode_fattr(struct svc_fh *fhp, struct svc_export *exp,
struct kstat stat; struct kstat stat;
struct svc_fh tempfh; struct svc_fh tempfh;
struct kstatfs statfs; struct kstatfs statfs;
int buflen = *countp << 2; int buflen = count << 2;
__be32 *attrlenp; __be32 *attrlenp;
u32 dummy; u32 dummy;
u64 dummy64; u64 dummy64;
u32 rdattr_err = 0; u32 rdattr_err = 0;
__be32 *p = buffer; __be32 *p = *buffer;
__be32 status; __be32 status;
int err; int err;
int aclsupport = 0; int aclsupport = 0;
...@@ -2431,7 +2430,7 @@ nfsd4_encode_fattr(struct svc_fh *fhp, struct svc_export *exp, ...@@ -2431,7 +2430,7 @@ nfsd4_encode_fattr(struct svc_fh *fhp, struct svc_export *exp,
} }
*attrlenp = htonl((char *)p - (char *)attrlenp - 4); *attrlenp = htonl((char *)p - (char *)attrlenp - 4);
*countp = p - buffer; *buffer = p;
status = nfs_ok; status = nfs_ok;
out: out:
...@@ -2443,7 +2442,6 @@ nfsd4_encode_fattr(struct svc_fh *fhp, struct svc_export *exp, ...@@ -2443,7 +2442,6 @@ nfsd4_encode_fattr(struct svc_fh *fhp, struct svc_export *exp,
status = nfserrno(err); status = nfserrno(err);
goto out; goto out;
out_resource: out_resource:
*countp = 0;
status = nfserr_resource; status = nfserr_resource;
goto out; goto out;
out_serverfault: out_serverfault:
...@@ -2462,7 +2460,7 @@ static inline int attributes_need_mount(u32 *bmval) ...@@ -2462,7 +2460,7 @@ static inline int attributes_need_mount(u32 *bmval)
static __be32 static __be32
nfsd4_encode_dirent_fattr(struct nfsd4_readdir *cd, nfsd4_encode_dirent_fattr(struct nfsd4_readdir *cd,
const char *name, int namlen, __be32 *p, int *buflen) const char *name, int namlen, __be32 **p, int buflen)
{ {
struct svc_export *exp = cd->rd_fhp->fh_export; struct svc_export *exp = cd->rd_fhp->fh_export;
struct dentry *dentry; struct dentry *dentry;
...@@ -2568,10 +2566,9 @@ nfsd4_encode_dirent(void *ccdv, const char *name, int namlen, ...@@ -2568,10 +2566,9 @@ nfsd4_encode_dirent(void *ccdv, const char *name, int namlen,
p = xdr_encode_hyper(p, NFS_OFFSET_MAX); /* offset of next entry */ p = xdr_encode_hyper(p, NFS_OFFSET_MAX); /* offset of next entry */
p = xdr_encode_array(p, name, namlen); /* name length & name */ p = xdr_encode_array(p, name, namlen); /* name length & name */
nfserr = nfsd4_encode_dirent_fattr(cd, name, namlen, p, &buflen); nfserr = nfsd4_encode_dirent_fattr(cd, name, namlen, &p, buflen);
switch (nfserr) { switch (nfserr) {
case nfs_ok: case nfs_ok:
p += buflen;
break; break;
case nfserr_resource: case nfserr_resource:
nfserr = nfserr_toosmall; nfserr = nfserr_toosmall;
...@@ -2698,10 +2695,8 @@ nfsd4_encode_getattr(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4 ...@@ -2698,10 +2695,8 @@ nfsd4_encode_getattr(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4
buflen = resp->end - resp->p - (COMPOUND_ERR_SLACK_SPACE >> 2); buflen = resp->end - resp->p - (COMPOUND_ERR_SLACK_SPACE >> 2);
nfserr = nfsd4_encode_fattr(fhp, fhp->fh_export, fhp->fh_dentry, nfserr = nfsd4_encode_fattr(fhp, fhp->fh_export, fhp->fh_dentry,
resp->p, &buflen, getattr->ga_bmval, &resp->p, buflen, getattr->ga_bmval,
resp->rqstp, 0); resp->rqstp, 0);
if (!nfserr)
resp->p += buflen;
return nfserr; return nfserr;
} }
......
...@@ -563,7 +563,7 @@ __be32 nfsd4_check_resp_size(struct nfsd4_compoundres *, u32); ...@@ -563,7 +563,7 @@ __be32 nfsd4_check_resp_size(struct nfsd4_compoundres *, u32);
void nfsd4_encode_operation(struct nfsd4_compoundres *, struct nfsd4_op *); void nfsd4_encode_operation(struct nfsd4_compoundres *, struct nfsd4_op *);
void nfsd4_encode_replay(struct nfsd4_compoundres *resp, struct nfsd4_op *op); void nfsd4_encode_replay(struct nfsd4_compoundres *resp, struct nfsd4_op *op);
__be32 nfsd4_encode_fattr(struct svc_fh *fhp, struct svc_export *exp, __be32 nfsd4_encode_fattr(struct svc_fh *fhp, struct svc_export *exp,
struct dentry *dentry, __be32 *buffer, int *countp, struct dentry *dentry, __be32 **buffer, int countp,
u32 *bmval, struct svc_rqst *, int ignore_crossmnt); u32 *bmval, struct svc_rqst *, int ignore_crossmnt);
extern __be32 nfsd4_setclientid(struct svc_rqst *rqstp, extern __be32 nfsd4_setclientid(struct svc_rqst *rqstp,
struct nfsd4_compound_state *, struct nfsd4_compound_state *,
......
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