Merge tag 'nfs-for-4.6-1' of git://git.linux-nfs.org/projects/trondmy/linux-nfs
[sfrench/cifs-2.6.git] / fs / nfs / nfs4proc.c
index c70de30b80f103413a81e63062deae6a66dd81e0..327b8c34d3606e5d234f006fd26a3293f12b1d36 100644 (file)
@@ -2461,14 +2461,15 @@ static int _nfs4_open_and_get_state(struct nfs4_opendata *opendata,
 
        dentry = opendata->dentry;
        if (d_really_is_negative(dentry)) {
-               /* FIXME: Is this d_drop() ever needed? */
+               struct dentry *alias;
                d_drop(dentry);
-               dentry = d_add_unique(dentry, igrab(state->inode));
-               if (dentry == NULL) {
-                       dentry = opendata->dentry;
-               } else {
+               alias = d_exact_alias(dentry, state->inode);
+               if (!alias)
+                       alias = d_splice_alias(igrab(state->inode), dentry);
+               /* d_splice_alias() can't fail here - it's a non-directory */
+               if (alias) {
                        dput(ctx->dentry);
-                       ctx->dentry = dentry;
+                       ctx->dentry = dentry = alias;
                }
                nfs_set_verifier(dentry,
                                nfs_save_change_attribute(d_inode(opendata->dir)));