Skip to content

Commit 502aa0a

Browse files
Josef BacikJ. Bruce Fields
authored andcommitted
nfsd: fix dentry refcounting on create
b44061d introduced a dentry ref counting bug. Previously we were grabbing one ref to dchild in nfsd_create(), but with the creation of nfsd_create_locked() we have a ref for dchild from the lookup in nfsd_create(), and then another ref in nfsd_create_locked(). The ref from the lookup in nfsd_create() is never dropped and results in dentries still in use at unmount. Signed-off-by: Josef Bacik <jbacik@fb.com> Fixes: b44061d "nfsd: reorganize nfsd_create" Reported-by: kernel test robot <xiaolong.ye@intel.com> Reviewed-by: Jeff Layton <jlayton@redhat.com> Acked-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
1 parent 29b4817 commit 502aa0a

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

fs/nfsd/vfs.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1252,10 +1252,13 @@ nfsd_create(struct svc_rqst *rqstp, struct svc_fh *fhp,
12521252
if (IS_ERR(dchild))
12531253
return nfserrno(host_err);
12541254
err = fh_compose(resfhp, fhp->fh_export, dchild, fhp);
1255-
if (err) {
1256-
dput(dchild);
1255+
/*
1256+
* We unconditionally drop our ref to dchild as fh_compose will have
1257+
* already grabbed its own ref for it.
1258+
*/
1259+
dput(dchild);
1260+
if (err)
12571261
return err;
1258-
}
12591262
return nfsd_create_locked(rqstp, fhp, fname, flen, iap, type,
12601263
rdev, resfhp);
12611264
}

0 commit comments

Comments
 (0)