]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
ceph: switch to use of ->d_init()
authorAl Viro <viro@zeniv.linux.org.uk>
Sat, 29 Oct 2016 02:05:13 +0000 (22:05 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Sat, 29 Oct 2016 02:05:13 +0000 (22:05 -0400)
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/ceph/dir.c
fs/ceph/export.c
fs/ceph/file.c
fs/ceph/inode.c
fs/ceph/super.c
fs/ceph/super.h

index 80f5339d097bdaa5af28719534f5db172b179ded..c23eb0e9348c3ce571fadb27c3b0aba8e6345984 100644 (file)
@@ -32,33 +32,19 @@ const struct dentry_operations ceph_dentry_ops;
 /*
  * Initialize ceph dentry state.
  */
-int ceph_init_dentry(struct dentry *dentry)
+static int ceph_d_init(struct dentry *dentry)
 {
        struct ceph_dentry_info *di;
 
-       if (dentry->d_fsdata)
-               return 0;
-
        di = kmem_cache_zalloc(ceph_dentry_cachep, GFP_KERNEL);
        if (!di)
                return -ENOMEM;          /* oh well */
 
-       spin_lock(&dentry->d_lock);
-       if (dentry->d_fsdata) {
-               /* lost a race */
-               kmem_cache_free(ceph_dentry_cachep, di);
-               goto out_unlock;
-       }
-
        di->dentry = dentry;
        di->lease_session = NULL;
        di->time = jiffies;
-       /* avoid reordering d_fsdata setup so that the check above is safe */
-       smp_mb();
        dentry->d_fsdata = di;
        ceph_dentry_lru_add(dentry);
-out_unlock:
-       spin_unlock(&dentry->d_lock);
        return 0;
 }
 
@@ -730,10 +716,6 @@ static struct dentry *ceph_lookup(struct inode *dir, struct dentry *dentry,
        if (dentry->d_name.len > NAME_MAX)
                return ERR_PTR(-ENAMETOOLONG);
 
-       err = ceph_init_dentry(dentry);
-       if (err < 0)
-               return ERR_PTR(err);
-
        /* can we conclude ENOENT locally? */
        if (d_really_is_negative(dentry)) {
                struct ceph_inode_info *ci = ceph_inode(dir);
@@ -1503,4 +1485,5 @@ const struct dentry_operations ceph_dentry_ops = {
        .d_revalidate = ceph_d_revalidate,
        .d_release = ceph_d_release,
        .d_prune = ceph_d_prune,
+       .d_init = ceph_d_init,
 };
index 1780218a48f0843e2fa0777831d958cb4c4e9a37..180bbef760f2c8c12fd94d458c246014634233dd 100644 (file)
@@ -62,7 +62,6 @@ static struct dentry *__fh_to_dentry(struct super_block *sb, u64 ino)
 {
        struct ceph_mds_client *mdsc = ceph_sb_to_client(sb)->mdsc;
        struct inode *inode;
-       struct dentry *dentry;
        struct ceph_vino vino;
        int err;
 
@@ -94,16 +93,7 @@ static struct dentry *__fh_to_dentry(struct super_block *sb, u64 ino)
                        return ERR_PTR(-ESTALE);
        }
 
-       dentry = d_obtain_alias(inode);
-       if (IS_ERR(dentry))
-               return dentry;
-       err = ceph_init_dentry(dentry);
-       if (err < 0) {
-               dput(dentry);
-               return ERR_PTR(err);
-       }
-       dout("__fh_to_dentry %llx %p dentry %p\n", ino, inode, dentry);
-       return dentry;
+       return d_obtain_alias(inode);
 }
 
 /*
@@ -131,7 +121,6 @@ static struct dentry *__get_parent(struct super_block *sb,
        struct ceph_mds_client *mdsc = ceph_sb_to_client(sb)->mdsc;
        struct ceph_mds_request *req;
        struct inode *inode;
-       struct dentry *dentry;
        int mask;
        int err;
 
@@ -164,18 +153,7 @@ static struct dentry *__get_parent(struct super_block *sb,
        if (!inode)
                return ERR_PTR(-ENOENT);
 
-       dentry = d_obtain_alias(inode);
-       if (IS_ERR(dentry))
-               return dentry;
-       err = ceph_init_dentry(dentry);
-       if (err < 0) {
-               dput(dentry);
-               return ERR_PTR(err);
-       }
-       dout("__get_parent ino %llx parent %p ino %llx.%llx\n",
-            child ? ceph_ino(d_inode(child)) : ino,
-            dentry, ceph_vinop(inode));
-       return dentry;
+       return d_obtain_alias(inode);
 }
 
 static struct dentry *ceph_get_parent(struct dentry *child)
index 7bf08825cc1107a20842533fd93b4f2c2d128577..9d1554c7d036691d51157f01409d0c42f9fbf0df 100644 (file)
@@ -351,10 +351,6 @@ int ceph_atomic_open(struct inode *dir, struct dentry *dentry,
        if (dentry->d_name.len > NAME_MAX)
                return -ENAMETOOLONG;
 
-       err = ceph_init_dentry(dentry);
-       if (err < 0)
-               return err;
-
        if (flags & O_CREAT) {
                err = ceph_pre_init_acls(dir, &mode, &acls);
                if (err < 0)
index 29fcbee2d41608a2a3a12bdb0b75a7a67a98df55..9d0522ba069cd579795334282c8b0cc5edc67c2b 100644 (file)
@@ -1203,12 +1203,7 @@ retry_lookup:
                                        err = -ENOMEM;
                                        goto done;
                                }
-                               err = ceph_init_dentry(dn);
-                               if (err < 0) {
-                                       dput(dn);
-                                       dput(parent);
-                                       goto done;
-                               }
+                               err = 0;
                        } else if (d_really_is_positive(dn) &&
                                   (ceph_ino(d_inode(dn)) != vino.ino ||
                                    ceph_snap(d_inode(dn)) != vino.snap)) {
@@ -1561,12 +1556,6 @@ retry_lookup:
                                err = -ENOMEM;
                                goto out;
                        }
-                       ret = ceph_init_dentry(dn);
-                       if (ret < 0) {
-                               dput(dn);
-                               err = ret;
-                               goto out;
-                       }
                } else if (d_really_is_positive(dn) &&
                           (ceph_ino(d_inode(dn)) != vino.ino ||
                            ceph_snap(d_inode(dn)) != vino.snap)) {
index 0617580b2508a9bb99b28a996fe323a70a36fef0..fd2ea18a0ca32cca1decff5b705852638f521817 100644 (file)
@@ -795,7 +795,6 @@ static struct dentry *open_root_dentry(struct ceph_fs_client *fsc,
                        root = ERR_PTR(-ENOMEM);
                        goto out;
                }
-               ceph_init_dentry(root);
                dout("open_root_inode success, root dentry is %p\n", root);
        } else {
                root = ERR_PTR(err);
index 26a5a5d6bf362a270f2b190f68c04e2404aed789..931687f71a7cfab9e0e1618666e74821ffd704ac 100644 (file)
@@ -950,13 +950,6 @@ extern void ceph_invalidate_dentry_lease(struct dentry *dentry);
 extern unsigned ceph_dentry_hash(struct inode *dir, struct dentry *dn);
 extern void ceph_readdir_cache_release(struct ceph_readdir_cache_control *ctl);
 
-/*
- * our d_ops vary depending on whether the inode is live,
- * snapshotted (read-only), or a virtual ".snap" directory.
- */
-int ceph_init_dentry(struct dentry *dentry);
-
-
 /* ioctl.c */
 extern long ceph_ioctl(struct file *file, unsigned int cmd, unsigned long arg);