Skip to content

Commit

Permalink
nfsd: fix compose_entry_fh() failure exits
Browse files Browse the repository at this point in the history
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: Al Viro <[email protected]>
  • Loading branch information
Al Viro committed Apr 13, 2012
1 parent afcf679 commit efe3965
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions fs/nfsd/nfs3xdr.c
Original file line number Diff line number Diff line change
Expand Up @@ -803,40 +803,34 @@ encode_entry_baggage(struct nfsd3_readdirres *cd, __be32 *p, const char *name,
return p;
}

static int
static __be32
compose_entry_fh(struct nfsd3_readdirres *cd, struct svc_fh *fhp,
const char *name, int namlen)
{
struct svc_export *exp;
struct dentry *dparent, *dchild;
int rv = 0;
__be32 rv = nfserr_noent;

dparent = cd->fh.fh_dentry;
exp = cd->fh.fh_export;

if (isdotent(name, namlen)) {
if (namlen == 2) {
dchild = dget_parent(dparent);
if (dchild == dparent) {
/* filesystem root - cannot return filehandle for ".." */
dput(dchild);
return -ENOENT;
}
/* filesystem root - cannot return filehandle for ".." */
if (dchild == dparent)
goto out;
} else
dchild = dget(dparent);
} else
dchild = lookup_one_len(name, dparent, namlen);
if (IS_ERR(dchild))
return -ENOENT;
rv = -ENOENT;
return rv;
if (d_mountpoint(dchild))
goto out;
rv = fh_compose(fhp, exp, dchild, &cd->fh);
if (rv)
goto out;
if (!dchild->d_inode)
goto out;
rv = 0;
rv = fh_compose(fhp, exp, dchild, &cd->fh);
out:
dput(dchild);
return rv;
Expand All @@ -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)
{
struct svc_fh fh;
int err;
__be32 err;

fh_init(&fh, NFS3_FHSIZE);
err = compose_entry_fh(cd, &fh, name, namlen);
Expand Down

0 comments on commit efe3965

Please sign in to comment.