[PATCH 02/16] nfsd: simplify exp_find_key return value
Neil Brown
neilb at suse.de
Tue May 22 02:55:33 EDT 2007
On Friday May 18, trond.myklebust at fys.uio.no 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?
Only... doesn't "NULL" really mean -ENOMEM ? And that can be subtly
different from -ENOENT.
For example, in rqst_exp_get_by_name (patch 9)
if exp_get_by_name(rq_client) returns NULL we assume -ENOENT and try
exp_get_by_name(rq_gssclient).
However if the NULL really meant -ENOMEM, we should probably return
-ENOMEM which becomes nfserr_dropit so the client will retry later
when hopefully we have found some memory.
I definitely like the idea of using a single convention for returning
errors. I don't think I like merging -ENOENT and -ENOMEM into one.
NeilBrown
More information about the NFSv4
mailing list