Commit efe39651 authored by Al Viro's avatar Al Viro

nfsd: fix compose_entry_fh() failure exits

Restore the original logics ("fail on mountpoints, negatives and in
case of fh_compose() failures").  Since commit 8177e (nfsd: clean up
readdirplus encoding) that got broken -
	rv = fh_compose(fhp, exp, dchild, &cd->fh);
	if (rv)
	       goto out;
	if (!dchild->d_inode)
		goto out;
	rv = 0;
out:
is equivalent to
	rv = fh_compose(fhp, exp, dchild, &cd->fh);
out:
and the second check has no effect whatsoever...
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent afcf6792
...@@ -803,13 +803,13 @@ encode_entry_baggage(struct nfsd3_readdirres *cd, __be32 *p, const char *name, ...@@ -803,13 +803,13 @@ encode_entry_baggage(struct nfsd3_readdirres *cd, __be32 *p, const char *name,
return p; return p;
} }
static int static __be32
compose_entry_fh(struct nfsd3_readdirres *cd, struct svc_fh *fhp, compose_entry_fh(struct nfsd3_readdirres *cd, struct svc_fh *fhp,
const char *name, int namlen) const char *name, int namlen)
{ {
struct svc_export *exp; struct svc_export *exp;
struct dentry *dparent, *dchild; struct dentry *dparent, *dchild;
int rv = 0; __be32 rv = nfserr_noent;
dparent = cd->fh.fh_dentry; dparent = cd->fh.fh_dentry;
exp = cd->fh.fh_export; exp = cd->fh.fh_export;
...@@ -817,26 +817,20 @@ compose_entry_fh(struct nfsd3_readdirres *cd, struct svc_fh *fhp, ...@@ -817,26 +817,20 @@ compose_entry_fh(struct nfsd3_readdirres *cd, struct svc_fh *fhp,
if (isdotent(name, namlen)) { if (isdotent(name, namlen)) {
if (namlen == 2) { if (namlen == 2) {
dchild = dget_parent(dparent); dchild = dget_parent(dparent);
if (dchild == dparent) { /* filesystem root - cannot return filehandle for ".." */
/* filesystem root - cannot return filehandle for ".." */ if (dchild == dparent)
dput(dchild); goto out;
return -ENOENT;
}
} else } else
dchild = dget(dparent); dchild = dget(dparent);
} else } else
dchild = lookup_one_len(name, dparent, namlen); dchild = lookup_one_len(name, dparent, namlen);
if (IS_ERR(dchild)) if (IS_ERR(dchild))
return -ENOENT; return rv;
rv = -ENOENT;
if (d_mountpoint(dchild)) if (d_mountpoint(dchild))
goto out; goto out;
rv = fh_compose(fhp, exp, dchild, &cd->fh);
if (rv)
goto out;
if (!dchild->d_inode) if (!dchild->d_inode)
goto out; goto out;
rv = 0; rv = fh_compose(fhp, exp, dchild, &cd->fh);
out: out:
dput(dchild); dput(dchild);
return rv; return rv;
...@@ -845,7 +839,7 @@ compose_entry_fh(struct nfsd3_readdirres *cd, struct svc_fh *fhp, ...@@ -845,7 +839,7 @@ compose_entry_fh(struct nfsd3_readdirres *cd, struct svc_fh *fhp,
static __be32 *encode_entryplus_baggage(struct nfsd3_readdirres *cd, __be32 *p, const char *name, int namlen) static __be32 *encode_entryplus_baggage(struct nfsd3_readdirres *cd, __be32 *p, const char *name, int namlen)
{ {
struct svc_fh fh; struct svc_fh fh;
int err; __be32 err;
fh_init(&fh, NFS3_FHSIZE); fh_init(&fh, NFS3_FHSIZE);
err = compose_entry_fh(cd, &fh, name, namlen); err = compose_entry_fh(cd, &fh, name, namlen);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment