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. nfs_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 2c1315a02e52..e1d56400fc6a 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -2329,8 +2329,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); @@ -2351,6 +2349,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 a9b8d482d289..185c933fb54c 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -3099,7 +3099,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