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

J. Bruce Fields bfields at fieldses.org
Sun May 20 22:53:25 EDT 2007


On Fri, May 18, 2007 at 06:32:18PM -0400, J. Bruce Fields wrote:
> On Fri, May 18, 2007 at 06:00:05PM -0400, Trond Myklebust wrote:
> > On Fri, 2007-05-18 at 17:27 -0400, J. Bruce Fields wrote:
> > > 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).
> > 
> > It is poor practice to mix the ERR_PTR() and NULL return value
> > conventions: you force callers to deal with 3 types of return value
> > (ERR_PTR(), NULL, and valid pointer) instead of just 2.
> > 
> > How about just simplifying the other way: always return -ENOENT if the
> > lookup failed?
> > 
> > You can still simplify fh_verify():
> > 
> > 	error = nfserr_stale;
> > 	if (PTR_ERR(exp) == -ENOENT)
> > 		goto out;
> > 
> > 	error = nfserrno(PTR_ERR(exp));
> > 	if (IS_ERR(exp))
> > 		goto out;
> 
> Hm, yes, could be; that requires some more changes.  I'll take a look.

The current situation is a little confusing.  The export-finding
functions should probably be returning -ENOMEM (not -ENOENT) everwhere
they're currently returning NULL, but the callers need checking to make
sure that works.  I'll try to make a patch in the next couple days.
(I'm travelling so may be a little slow.)

--b.


More information about the NFSv4 mailing list