[PATCH 1/2] nfsd: return NFS4ERR_SERVERFAULT from PUTROOTFH when path in /etc/exports not found
Benny Halevy
bhalevy at panasas.com
Mon Jan 21 05:09:14 EST 2008
On Jan. 20, 2008, 22:30 +0200, "J. Bruce Fields" <bfields at fieldses.org> wrote:
> On Sun, Jan 20, 2008 at 06:23:52PM +0200, Benny Halevy wrote:
>> Currently, when /etc/exports refers to a non-existing path, e.g.:
>> /foo *(fsid=0,rw,sync,no_subtree_check,no_root_squash,insecure)
>>
>> nfsd4_putrootfh returns NFS4ERR_PERM which is not a valid nfsv4 error return
>> for PUTROOTFH (nor in nfsv4.1).
>>
>> NFSv4 allows the following errors for PUTROOTFH:
>> NFS4ERR_RESOURCE
>> NFS4ERR_SERVERFAULT
>> NFS4ERR_WRONGSEC
>> amongst which, NFS4ERR_SERVERFAULT seems to make the most sense in this case.
>
> If the most helpful error to return on the client side is actually
> ENOENT, then returning NFS4ERR_SERVERFAULT and depending on the client
> to map that to ENOENT seems a roundabout way to do it. Just returning
> NFS4ERR_ENOENT would seem more in the spirit of interoperability even if
> it violates the letter of the spec.
The problem I see with that is that indeed the server went mad :-)
Since there's no path in PUTROOTFH the server is supposed to always
be able to return the filehandle for the pseudo-root fs.
the translation later on to ENOENT is just to make the application
(mount in this case) feel warm and fuzzy.
>
> But perhaps there's also more we should do in mountd or exportfs to
> avoid this situation in the first place.
Good point, maybe deny any access, even before PUTROOTFH, if the
exported root is inaccessible.
At any rate, returning nfserr_perm as we do today is both violating
the spec and not really identifying the root problem.
Benny
>
> --b.
>
>> Signed-off-by: Benny Halevy <bhalevy at panasas.com>
>> ---
>> fs/nfsd/export.c | 4 +---
>> 1 files changed, 1 insertions(+), 3 deletions(-)
>>
>> diff --git a/fs/nfsd/export.c b/fs/nfsd/export.c
>> index 66d0aeb..b8b8818 100644
>> --- a/fs/nfsd/export.c
>> +++ b/fs/nfsd/export.c
>> @@ -1357,10 +1357,8 @@ exp_pseudoroot(struct svc_rqst *rqstp, struct svc_fh *fhp)
>> mk_fsid(FSID_NUM, fsidv, 0, 0, 0, NULL);
>>
>> exp = rqst_exp_find(rqstp, FSID_NUM, fsidv);
>> - if (PTR_ERR(exp) == -ENOENT)
>> - return nfserr_perm;
>> if (IS_ERR(exp))
>> - return nfserrno(PTR_ERR(exp));
>> + return nfserr_serverfault;
>> rv = fh_compose(fhp, exp, exp->ex_dentry, NULL);
>> if (rv)
>> goto out;
>> --
>> 1.5.3.3
>>
--
Benny Halevy
Software Architect
Tel/Fax: +972-3-647-8340
Mobile: +972-54-802-8340
US: +1-412-203-3187
bhalevy at panasas.com
Panasas, Inc.
The Leader in Parallel Storage
www.panasas.com
More information about the NFSv4
mailing list