From: NeilBrown nfs_add_or_obtain() is used, often via nfs_instantiate(), to attach a newly created inode to the appropriate dentry - or to provide an alternate dentry. It has to drop the dentry first, which is problematic for proposed locking changes. As d_splice_alias() now works with hashed dentries, the d_drop() is no longer needed. However we still d_drop() on error as the status of the name is uncertain. _nfs4_open_and_get_state() is only used for files so we should be able to use d_instantiate(). However as that depends on the server for correctness, it is safer to stay with the current code pattern and use d_splice_alias() there too. Signed-off-by: NeilBrown --- fs/nfs/dir.c | 3 +-- fs/nfs/nfs4proc.c | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index 1a238c66fd34..ee8a718b9695 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -2346,8 +2346,6 @@ nfs_add_or_obtain(struct dentry *dentry, struct nfs_fh *fhandle, struct dentry *d; int error; - d_drop(dentry); - if (fhandle->size == 0) { error = NFS_PROTO(dir)->lookup(dir, dentry, &dentry->d_name, fhandle, fattr); @@ -2368,6 +2366,7 @@ nfs_add_or_obtain(struct dentry *dentry, struct nfs_fh *fhandle, dput(parent); return d; out_error: + d_drop(dentry); d = ERR_PTR(error); goto out; } diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 04b1987115d5..8f07f34f899e 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -3113,7 +3113,6 @@ static int _nfs4_open_and_get_state(struct nfs4_opendata *opendata, nfs_set_verifier(dentry, dir_verifier); if (d_really_is_negative(dentry)) { struct dentry *alias; - d_drop(dentry); alias = d_splice_alias(igrab(state->inode), dentry); /* d_splice_alias() can't fail here - it's a non-directory */ if (alias) { -- 2.50.0.107.gf914562f5916.dirty