]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blobdiff - drivers/staging/lustre/lustre/llite/namei.c
fs: make remaining filesystems use .rename2
[mirror_ubuntu-bionic-kernel.git] / drivers / staging / lustre / lustre / llite / namei.c
index 3664bfd0178b34b09c1791cfd1190f6b9c035ea2..ec824db2ad33a4eb9478bbe9e386a9b7f2cb51c6 100644 (file)
@@ -388,6 +388,7 @@ static int ll_lookup_it_finish(struct ptlrpc_request *request,
        struct inode *inode = NULL;
        __u64 bits = 0;
        int rc = 0;
+       struct dentry *alias;
 
        /* NB 1 request reference will be taken away by ll_intent_lock()
         * when I return
@@ -412,26 +413,12 @@ static int ll_lookup_it_finish(struct ptlrpc_request *request,
                 */
        }
 
-       /* Only hash *de if it is unhashed (new dentry).
-        * Atoimc_open may passing hashed dentries for open.
-        */
-       if (d_unhashed(*de)) {
-               struct dentry *alias;
-
-               alias = ll_splice_alias(inode, *de);
-               if (IS_ERR(alias)) {
-                       rc = PTR_ERR(alias);
-                       goto out;
-               }
-               *de = alias;
-       } else if (!it_disposition(it, DISP_LOOKUP_NEG)  &&
-                  !it_disposition(it, DISP_OPEN_CREATE)) {
-               /* With DISP_OPEN_CREATE dentry will be
-                * instantiated in ll_create_it.
-                */
-               LASSERT(!d_inode(*de));
-               d_instantiate(*de, inode);
+       alias = ll_splice_alias(inode, *de);
+       if (IS_ERR(alias)) {
+               rc = PTR_ERR(alias);
+               goto out;
        }
+       *de = alias;
 
        if (!it_disposition(it, DISP_LOOKUP_NEG)) {
                /* we have lookup look - unhide dentry */
@@ -587,6 +574,24 @@ static int ll_atomic_open(struct inode *dir, struct dentry *dentry,
               dentry, PFID(ll_inode2fid(dir)), dir, file, open_flags, mode,
               *opened);
 
+       /* Only negative dentries enter here */
+       LASSERT(!d_inode(dentry));
+
+       if (!d_in_lookup(dentry)) {
+               /* A valid negative dentry that just passed revalidation,
+                * there's little point to try and open it server-side,
+                * even though there's a minuscle chance it might succeed.
+                * Either way it's a valid race to just return -ENOENT here.
+                */
+               if (!(open_flags & O_CREAT))
+                       return -ENOENT;
+
+               /* Otherwise we just unhash it to be rehashed afresh via
+                * lookup if necessary
+                */
+               d_drop(dentry);
+       }
+
        it = kzalloc(sizeof(*it), GFP_NOFS);
        if (!it)
                return -ENOMEM;
@@ -1045,13 +1050,17 @@ out:
 }
 
 static int ll_rename(struct inode *src, struct dentry *src_dchild,
-                    struct inode *tgt, struct dentry *tgt_dchild)
+                    struct inode *tgt, struct dentry *tgt_dchild,
+                    unsigned int flags)
 {
        struct ptlrpc_request *request = NULL;
        struct ll_sb_info *sbi = ll_i2sbi(src);
        struct md_op_data *op_data;
        int err;
 
+       if (flags)
+               return -EINVAL;
+
        CDEBUG(D_VFSTRACE,
               "VFS Op:oldname=%pd, src_dir="DFID"(%p), newname=%pd, tgt_dir="DFID"(%p)\n",
               src_dchild, PFID(ll_inode2fid(src)), src,
@@ -1097,7 +1106,7 @@ const struct inode_operations ll_dir_inode_operations = {
        .rmdir        = ll_rmdir,
        .symlink            = ll_symlink,
        .link          = ll_link,
-       .rename      = ll_rename,
+       .rename2        = ll_rename,
        .setattr            = ll_setattr,
        .getattr            = ll_getattr,
        .permission      = ll_inode_permission,