ceph: switch to use of ->d_init()

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
Al Viro 2016-10-28 22:05:13 -04:00
parent 18fc8abdb7
commit ad5cb123fd
6 changed files with 5 additions and 67 deletions

View file

@ -32,33 +32,19 @@ const struct dentry_operations ceph_dentry_ops;
/* /*
* Initialize ceph dentry state. * Initialize ceph dentry state.
*/ */
int ceph_init_dentry(struct dentry *dentry) static int ceph_d_init(struct dentry *dentry)
{ {
struct ceph_dentry_info *di; struct ceph_dentry_info *di;
if (dentry->d_fsdata)
return 0;
di = kmem_cache_zalloc(ceph_dentry_cachep, GFP_KERNEL); di = kmem_cache_zalloc(ceph_dentry_cachep, GFP_KERNEL);
if (!di) if (!di)
return -ENOMEM; /* oh well */ 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->dentry = dentry;
di->lease_session = NULL; di->lease_session = NULL;
di->time = jiffies; di->time = jiffies;
/* avoid reordering d_fsdata setup so that the check above is safe */
smp_mb();
dentry->d_fsdata = di; dentry->d_fsdata = di;
ceph_dentry_lru_add(dentry); ceph_dentry_lru_add(dentry);
out_unlock:
spin_unlock(&dentry->d_lock);
return 0; return 0;
} }
@ -730,10 +716,6 @@ static struct dentry *ceph_lookup(struct inode *dir, struct dentry *dentry,
if (dentry->d_name.len > NAME_MAX) if (dentry->d_name.len > NAME_MAX)
return ERR_PTR(-ENAMETOOLONG); return ERR_PTR(-ENAMETOOLONG);
err = ceph_init_dentry(dentry);
if (err < 0)
return ERR_PTR(err);
/* can we conclude ENOENT locally? */ /* can we conclude ENOENT locally? */
if (d_really_is_negative(dentry)) { if (d_really_is_negative(dentry)) {
struct ceph_inode_info *ci = ceph_inode(dir); 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_revalidate = ceph_d_revalidate,
.d_release = ceph_d_release, .d_release = ceph_d_release,
.d_prune = ceph_d_prune, .d_prune = ceph_d_prune,
.d_init = ceph_d_init,
}; };

View 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 ceph_mds_client *mdsc = ceph_sb_to_client(sb)->mdsc;
struct inode *inode; struct inode *inode;
struct dentry *dentry;
struct ceph_vino vino; struct ceph_vino vino;
int err; int err;
@ -94,16 +93,7 @@ static struct dentry *__fh_to_dentry(struct super_block *sb, u64 ino)
return ERR_PTR(-ESTALE); return ERR_PTR(-ESTALE);
} }
dentry = d_obtain_alias(inode); return 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;
} }
/* /*
@ -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_client *mdsc = ceph_sb_to_client(sb)->mdsc;
struct ceph_mds_request *req; struct ceph_mds_request *req;
struct inode *inode; struct inode *inode;
struct dentry *dentry;
int mask; int mask;
int err; int err;
@ -164,18 +153,7 @@ static struct dentry *__get_parent(struct super_block *sb,
if (!inode) if (!inode)
return ERR_PTR(-ENOENT); return ERR_PTR(-ENOENT);
dentry = d_obtain_alias(inode); return 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;
} }
static struct dentry *ceph_get_parent(struct dentry *child) static struct dentry *ceph_get_parent(struct dentry *child)

View file

@ -351,10 +351,6 @@ int ceph_atomic_open(struct inode *dir, struct dentry *dentry,
if (dentry->d_name.len > NAME_MAX) if (dentry->d_name.len > NAME_MAX)
return -ENAMETOOLONG; return -ENAMETOOLONG;
err = ceph_init_dentry(dentry);
if (err < 0)
return err;
if (flags & O_CREAT) { if (flags & O_CREAT) {
err = ceph_pre_init_acls(dir, &mode, &acls); err = ceph_pre_init_acls(dir, &mode, &acls);
if (err < 0) if (err < 0)

View file

@ -1203,12 +1203,7 @@ retry_lookup:
err = -ENOMEM; err = -ENOMEM;
goto done; goto done;
} }
err = ceph_init_dentry(dn); err = 0;
if (err < 0) {
dput(dn);
dput(parent);
goto done;
}
} else if (d_really_is_positive(dn) && } else if (d_really_is_positive(dn) &&
(ceph_ino(d_inode(dn)) != vino.ino || (ceph_ino(d_inode(dn)) != vino.ino ||
ceph_snap(d_inode(dn)) != vino.snap)) { ceph_snap(d_inode(dn)) != vino.snap)) {
@ -1561,12 +1556,6 @@ retry_lookup:
err = -ENOMEM; err = -ENOMEM;
goto out; goto out;
} }
ret = ceph_init_dentry(dn);
if (ret < 0) {
dput(dn);
err = ret;
goto out;
}
} else if (d_really_is_positive(dn) && } else if (d_really_is_positive(dn) &&
(ceph_ino(d_inode(dn)) != vino.ino || (ceph_ino(d_inode(dn)) != vino.ino ||
ceph_snap(d_inode(dn)) != vino.snap)) { ceph_snap(d_inode(dn)) != vino.snap)) {

View file

@ -795,7 +795,6 @@ static struct dentry *open_root_dentry(struct ceph_fs_client *fsc,
root = ERR_PTR(-ENOMEM); root = ERR_PTR(-ENOMEM);
goto out; goto out;
} }
ceph_init_dentry(root);
dout("open_root_inode success, root dentry is %p\n", root); dout("open_root_inode success, root dentry is %p\n", root);
} else { } else {
root = ERR_PTR(err); root = ERR_PTR(err);

View 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 unsigned ceph_dentry_hash(struct inode *dir, struct dentry *dn);
extern void ceph_readdir_cache_release(struct ceph_readdir_cache_control *ctl); 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 */ /* ioctl.c */
extern long ceph_ioctl(struct file *file, unsigned int cmd, unsigned long arg); extern long ceph_ioctl(struct file *file, unsigned int cmd, unsigned long arg);