Commit 84822d0b3bc5a74a4290727dd1ab4fc7dcd6a348

Authored by J. Bruce Fields
1 parent d1c3ed669a

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>

Showing 3 changed files with 13 additions and 17 deletions Side-by-side Diff

... ... @@ -993,14 +993,15 @@
993 993 if (!buf)
994 994 return nfserr_jukebox;
995 995  
  996 + p = buf;
996 997 status = nfsd4_encode_fattr(&cstate->current_fh,
997 998 cstate->current_fh.fh_export,
998   - cstate->current_fh.fh_dentry, buf,
999   - &count, verify->ve_bmval,
  999 + cstate->current_fh.fh_dentry, &p,
  1000 + count, verify->ve_bmval,
1000 1001 rqstp, 0);
1001 1002  
1002 1003 /* this means that nfsd4_encode_fattr() ran out of space */
1003   - if (status == nfserr_resource && count == 0)
  1004 + if (status == nfserr_resource)
1004 1005 status = nfserr_not_same;
1005 1006 if (status)
1006 1007 goto out_kfree;
... ... @@ -2006,12 +2006,11 @@
2006 2006 * Note: @fhp can be NULL; in this case, we might have to compose the filehandle
2007 2007 * ourselves.
2008 2008 *
2009   - * @countp is the buffer size in _words_; upon successful return this becomes
2010   - * replaced with the number of words written.
  2009 + * countp is the buffer size in _words_
2011 2010 */
2012 2011 __be32
2013 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 2014 struct svc_rqst *rqstp, int ignore_crossmnt)
2016 2015 {
2017 2016 u32 bmval0 = bmval[0];
2018 2017  
... ... @@ -2020,12 +2019,12 @@
2020 2019 struct kstat stat;
2021 2020 struct svc_fh tempfh;
2022 2021 struct kstatfs statfs;
2023   - int buflen = *countp << 2;
  2022 + int buflen = count << 2;
2024 2023 __be32 *attrlenp;
2025 2024 u32 dummy;
2026 2025 u64 dummy64;
2027 2026 u32 rdattr_err = 0;
2028   - __be32 *p = buffer;
  2027 + __be32 *p = *buffer;
2029 2028 __be32 status;
2030 2029 int err;
2031 2030 int aclsupport = 0;
... ... @@ -2431,7 +2430,7 @@
2431 2430 }
2432 2431  
2433 2432 *attrlenp = htonl((char *)p - (char *)attrlenp - 4);
2434   - *countp = p - buffer;
  2433 + *buffer = p;
2435 2434 status = nfs_ok;
2436 2435  
2437 2436 out:
... ... @@ -2443,7 +2442,6 @@
2443 2442 status = nfserrno(err);
2444 2443 goto out;
2445 2444 out_resource:
2446   - *countp = 0;
2447 2445 status = nfserr_resource;
2448 2446 goto out;
2449 2447 out_serverfault:
... ... @@ -2462,7 +2460,7 @@
2462 2460  
2463 2461 static __be32
2464 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 2465 struct svc_export *exp = cd->rd_fhp->fh_export;
2468 2466 struct dentry *dentry;
2469 2467  
... ... @@ -2568,10 +2566,9 @@
2568 2566 p = xdr_encode_hyper(p, NFS_OFFSET_MAX); /* offset of next entry */
2569 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 2570 switch (nfserr) {
2573 2571 case nfs_ok:
2574   - p += buflen;
2575 2572 break;
2576 2573 case nfserr_resource:
2577 2574 nfserr = nfserr_toosmall;
2578 2575  
... ... @@ -2698,10 +2695,8 @@
2698 2695  
2699 2696 buflen = resp->end - resp->p - (COMPOUND_ERR_SLACK_SPACE >> 2);
2700 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 2699 resp->rqstp, 0);
2703   - if (!nfserr)
2704   - resp->p += buflen;
2705 2700 return nfserr;
2706 2701 }
2707 2702  
... ... @@ -563,7 +563,7 @@
563 563 void nfsd4_encode_operation(struct nfsd4_compoundres *, struct nfsd4_op *);
564 564 void nfsd4_encode_replay(struct nfsd4_compoundres *resp, struct nfsd4_op *op);
565 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 567 u32 *bmval, struct svc_rqst *, int ignore_crossmnt);
568 568 extern __be32 nfsd4_setclientid(struct svc_rqst *rqstp,
569 569 struct nfsd4_compound_state *,