diff options
author | J. Bruce Fields <bfields@puzzle.fieldses.org> | 2007-07-17 07:04:40 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-07-17 13:23:07 -0400 |
commit | 2d3bb25209c1f9a27ea9535c7fd2f6729a5e7db1 (patch) | |
tree | 487ccec9aaf60298d4cb7b2fc5f4d76072bcc60b /fs/nfsd/vfs.c | |
parent | 47f9940c55c0bdc65188749cae4e841601f513bb (diff) |
knfsd: nfsd: make all exp_finding functions return -errno's on err
Currently exp_find(), exp_get_by_name(), and friends, return an export on
success, and on failure return:
errors -EAGAIN (drop this request pending an upcall) or
-ETIMEDOUT (an upcall has timed out), or
return NULL, which can mean either that there was a memory allocation
failure, or that an export was not found, or that a passed-in
export lacks an auth_domain.
Many callers seem to assume that NULL means that an export was not found,
which may lead to bugs in the case of a memory allocation failure.
Modify these functions to distinguish between the two NULL cases by returning
either -ENOENT or -ENOMEM. They now never return NULL. We get to simplify
some code in the process.
We return -ENOENT in the case of a missing auth_domain. This case should
probably be removed (or converted to a bug) after confirming that it can never
happen.
Signed-off-by: "J. Bruce Fields" <bfields@citi.umich.edu>
Signed-off-by: Neil Brown <neilb@suse.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/nfsd/vfs.c')
-rw-r--r-- | fs/nfsd/vfs.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c index 8d6b5c483ae1..0a18149ce963 100644 --- a/fs/nfsd/vfs.c +++ b/fs/nfsd/vfs.c | |||
@@ -192,15 +192,14 @@ nfsd_lookup(struct svc_rqst *rqstp, struct svc_fh *fhp, const char *name, | |||
192 | 192 | ||
193 | exp2 = exp_parent(exp->ex_client, mnt, dentry, | 193 | exp2 = exp_parent(exp->ex_client, mnt, dentry, |
194 | &rqstp->rq_chandle); | 194 | &rqstp->rq_chandle); |
195 | if (IS_ERR(exp2)) { | 195 | if (PTR_ERR(exp2) == -ENOENT) { |
196 | dput(dentry); | ||
197 | dentry = dget(dparent); | ||
198 | } else if (IS_ERR(exp2)) { | ||
196 | host_err = PTR_ERR(exp2); | 199 | host_err = PTR_ERR(exp2); |
197 | dput(dentry); | 200 | dput(dentry); |
198 | mntput(mnt); | 201 | mntput(mnt); |
199 | goto out_nfserr; | 202 | goto out_nfserr; |
200 | } | ||
201 | if (!exp2) { | ||
202 | dput(dentry); | ||
203 | dentry = dget(dparent); | ||
204 | } else { | 203 | } else { |
205 | exp_put(exp); | 204 | exp_put(exp); |
206 | exp = exp2; | 205 | exp = exp2; |