[PATCH 02/16] nfsd: simplify exp_find_key return value

J. Bruce Fields bfields at fieldses.org
Fri May 18 17:27:55 EDT 2007


From: J. Bruce Fields <bfields at citi.umich.edu>

exp_find_key can return either NULL or -ENOENT on a lookup failure, but
there's no reason to distinguish the two cases.  Returning NULL in both
cases (as exp_get_by_name does) makes life a little simpler for callers
(such as fh_verify).

Signed-off-by: "J. Bruce Fields" <bfields at citi.umich.edu>
---
 fs/nfsd/export.c |   14 ++++++++++++--
 fs/nfsd/nfsfh.c  |    5 ++---
 2 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/fs/nfsd/export.c b/fs/nfsd/export.c
index 79bd03b..2f503c7 100644
--- a/fs/nfsd/export.c
+++ b/fs/nfsd/export.c
@@ -745,9 +745,19 @@ exp_find_key(svc_client *clp, int fsid_type, u32 *fsidv, struct cache_req *reqp)
 	memcpy(key.ek_fsid, fsidv, key_len(fsid_type));
 
 	ek = svc_expkey_lookup(&key);
-	if (ek != NULL)
-		if ((err = cache_check(&svc_expkey_cache, &ek->h, reqp)))
+	if (ek != NULL) {
+		err = cache_check(&svc_expkey_cache, &ek->h, reqp);
+		switch (err) {
+		case 0:
+			break;
+		case -EAGAIN:
+		case -ETIMEDOUT:
 			ek = ERR_PTR(err);
+			break;
+		default:
+			ek = NULL;
+		}
+	}
 	return ek;
 }
 
diff --git a/fs/nfsd/nfsfh.c b/fs/nfsd/nfsfh.c
index 6ca2d24..8e4b675 100644
--- a/fs/nfsd/nfsfh.c
+++ b/fs/nfsd/nfsfh.c
@@ -163,14 +163,13 @@ fh_verify(struct svc_rqst *rqstp, struct svc_fh *fhp, int type, int access)
 				       &rqstp->rq_chandle);
 		}
 
-		if (IS_ERR(exp) && (PTR_ERR(exp) == -EAGAIN
-				|| PTR_ERR(exp) == -ETIMEDOUT)) {
+		if (IS_ERR(exp)) {
 			error = nfserrno(PTR_ERR(exp));
 			goto out;
 		}
 
 		error = nfserr_stale; 
-		if (!exp || IS_ERR(exp))
+		if (!exp)
 			goto out;
 
 		/* Check if the request originated from a secure port. */
-- 
1.5.2.rc3



More information about the NFSv4 mailing list