Commit bdc337cc authored by Neil Brown's avatar Neil Brown Committed by Linus Torvalds

[PATCH] knfsd: nfsd4: encode_dirent: simplify error handling

Minor simplification of error handling in encode_dirent.
Signed-off-by: default avatarJ. Bruce Fields <bfields@citi.umich.edu>
Signed-off-by: default avatarNeil Brown <neilb@cse.unsw.edu.au>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 48a8a48e
...@@ -1830,7 +1830,7 @@ nfsd4_encode_dirent(struct readdir_cd *ccd, const char *name, int namlen, ...@@ -1830,7 +1830,7 @@ nfsd4_encode_dirent(struct readdir_cd *ccd, const char *name, int namlen,
struct nfsd4_readdir *cd = container_of(ccd, struct nfsd4_readdir, common); struct nfsd4_readdir *cd = container_of(ccd, struct nfsd4_readdir, common);
int buflen; int buflen;
u32 *p = cd->buffer; u32 *p = cd->buffer;
int nfserr = 0; int nfserr = nfserr_toosmall;
/* In nfsv4, "." and ".." never make it onto the wire.. */ /* In nfsv4, "." and ".." never make it onto the wire.. */
if (name && isdotent(name, namlen)) { if (name && isdotent(name, namlen)) {
...@@ -1843,7 +1843,7 @@ nfsd4_encode_dirent(struct readdir_cd *ccd, const char *name, int namlen, ...@@ -1843,7 +1843,7 @@ nfsd4_encode_dirent(struct readdir_cd *ccd, const char *name, int namlen,
buflen = cd->buflen - 4 - XDR_QUADLEN(namlen); buflen = cd->buflen - 4 - XDR_QUADLEN(namlen);
if (buflen < 0) if (buflen < 0)
goto nospc; goto fail;
*p++ = xdr_one; /* mark entry present */ *p++ = xdr_one; /* mark entry present */
cd->offset = p; /* remember pointer */ cd->offset = p; /* remember pointer */
...@@ -1858,8 +1858,10 @@ nfsd4_encode_dirent(struct readdir_cd *ccd, const char *name, int namlen, ...@@ -1858,8 +1858,10 @@ nfsd4_encode_dirent(struct readdir_cd *ccd, const char *name, int namlen,
p += buflen; p += buflen;
goto out; goto out;
} }
if (nfserr == nfserr_resource) if (nfserr == nfserr_resource) {
goto nospc; nfserr = nfserr_toosmall;
goto fail;
}
/* /*
* If we get here, we experienced a miscellaneous * If we get here, we experienced a miscellaneous
...@@ -1870,13 +1872,12 @@ nfsd4_encode_dirent(struct readdir_cd *ccd, const char *name, int namlen, ...@@ -1870,13 +1872,12 @@ nfsd4_encode_dirent(struct readdir_cd *ccd, const char *name, int namlen,
* then in accordance with the spec, we fail the * then in accordance with the spec, we fail the
* entire READDIR operation(!) * entire READDIR operation(!)
*/ */
if (!(cd->rd_bmval[0] & FATTR4_WORD0_RDATTR_ERROR)) { if (!(cd->rd_bmval[0] & FATTR4_WORD0_RDATTR_ERROR))
cd->common.err = nfserr; goto fail;
return -EINVAL; nfserr = nfserr_toosmall;
}
p = nfsd4_encode_rdattr_error(p, buflen, nfserr); p = nfsd4_encode_rdattr_error(p, buflen, nfserr);
if (p == NULL) if (p == NULL)
goto out_nospc; goto fail;
out: out:
cd->buflen -= (p - cd->buffer); cd->buflen -= (p - cd->buffer);
...@@ -1884,8 +1885,8 @@ nfsd4_encode_dirent(struct readdir_cd *ccd, const char *name, int namlen, ...@@ -1884,8 +1885,8 @@ nfsd4_encode_dirent(struct readdir_cd *ccd, const char *name, int namlen,
cd->common.err = nfs_ok; cd->common.err = nfs_ok;
return 0; return 0;
nospc: fail:
cd->common.err = nfserr_toosmall; cd->common.err = nfserr;
return -EINVAL; return -EINVAL;
} }
......
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