Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull vfs updates from Al Viro: - more ->d_init() stuff (work.dcache) - pathname resolution cleanups (work.namei) - a few missing iov_iter primitives - copy_from_iter_full() and friends. Either copy the full requested amount, advance the iterator and return true, or fail, return false and do _not_ advance the iterator. Quite a few open-coded callers converted (and became more readable and harder to fuck up that way) (work.iov_iter) - several assorted patches, the big one being logfs removal * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: logfs: remove from tree vfs: fix put_compat_statfs64() does not handle errors namei: fold should_follow_link() with the step into not-followed link namei: pass both WALK_GET and WALK_MORE to should_follow_link() namei: invert WALK_PUT logics namei: shift interpretation of LOOKUP_FOLLOW inside should_follow_link() namei: saner calling conventions for mountpoint_last() namei.c: get rid of user_path_parent() switch getfrag callbacks to ..._full() primitives make skb_add_data,{_nocache}() and skb_copy_to_page_nocache() advance only on success [iov_iter] new primitives - copy_from_iter_full() and friends don't open-code file_inode() ceph: switch to use of ->d_init() ceph: unify dentry_operations instances lustre: switch to use of ->d_init()
This commit is contained in:
@@ -32,40 +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;
|
||||
}
|
||||
|
||||
if (ceph_snap(d_inode(dentry->d_parent)) == CEPH_NOSNAP)
|
||||
d_set_d_op(dentry, &ceph_dentry_ops);
|
||||
else if (ceph_snap(d_inode(dentry->d_parent)) == CEPH_SNAPDIR)
|
||||
d_set_d_op(dentry, &ceph_snapdir_dentry_ops);
|
||||
else
|
||||
d_set_d_op(dentry, &ceph_snap_dentry_ops);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -737,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);
|
||||
@@ -1323,16 +1298,6 @@ static void ceph_d_release(struct dentry *dentry)
|
||||
kmem_cache_free(ceph_dentry_cachep, di);
|
||||
}
|
||||
|
||||
static int ceph_snapdir_d_revalidate(struct dentry *dentry,
|
||||
unsigned int flags)
|
||||
{
|
||||
/*
|
||||
* Eventually, we'll want to revalidate snapped metadata
|
||||
* too... probably...
|
||||
*/
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* When the VFS prunes a dentry from the cache, we need to clear the
|
||||
* complete flag on the parent directory.
|
||||
@@ -1351,6 +1316,9 @@ static void ceph_d_prune(struct dentry *dentry)
|
||||
if (d_unhashed(dentry))
|
||||
return;
|
||||
|
||||
if (ceph_snap(d_inode(dentry->d_parent)) == CEPH_SNAPDIR)
|
||||
return;
|
||||
|
||||
/*
|
||||
* we hold d_lock, so d_parent is stable, and d_fsdata is never
|
||||
* cleared until d_release
|
||||
@@ -1521,14 +1489,5 @@ const struct dentry_operations ceph_dentry_ops = {
|
||||
.d_revalidate = ceph_d_revalidate,
|
||||
.d_release = ceph_d_release,
|
||||
.d_prune = ceph_d_prune,
|
||||
};
|
||||
|
||||
const struct dentry_operations ceph_snapdir_dentry_ops = {
|
||||
.d_revalidate = ceph_snapdir_d_revalidate,
|
||||
.d_release = ceph_d_release,
|
||||
};
|
||||
|
||||
const struct dentry_operations ceph_snap_dentry_ops = {
|
||||
.d_release = ceph_d_release,
|
||||
.d_prune = ceph_d_prune,
|
||||
.d_init = ceph_d_init,
|
||||
};
|
||||
|
@@ -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)
|
||||
|
@@ -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)
|
||||
|
@@ -1023,16 +1023,17 @@ static void update_dentry_lease(struct dentry *dentry,
|
||||
long unsigned half_ttl = from_time + (duration * HZ / 2) / 1000;
|
||||
struct inode *dir;
|
||||
|
||||
/* only track leases on regular dentries */
|
||||
if (dentry->d_op != &ceph_dentry_ops)
|
||||
return;
|
||||
|
||||
spin_lock(&dentry->d_lock);
|
||||
dout("update_dentry_lease %p duration %lu ms ttl %lu\n",
|
||||
dentry, duration, ttl);
|
||||
|
||||
/* make lease_rdcache_gen match directory */
|
||||
dir = d_inode(dentry->d_parent);
|
||||
|
||||
/* only track leases on regular dentries */
|
||||
if (ceph_snap(dir) != CEPH_NOSNAP)
|
||||
goto out_unlock;
|
||||
|
||||
di->lease_shared_gen = ceph_inode(dir)->i_shared_gen;
|
||||
|
||||
if (duration == 0)
|
||||
@@ -1202,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 +1557,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)) {
|
||||
|
@@ -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);
|
||||
@@ -879,6 +878,7 @@ static int ceph_set_super(struct super_block *s, void *data)
|
||||
fsc->sb = s;
|
||||
|
||||
s->s_op = &ceph_super_ops;
|
||||
s->s_d_op = &ceph_dentry_ops;
|
||||
s->s_export_op = &ceph_export_ops;
|
||||
|
||||
s->s_time_gran = 1000; /* 1000 ns == 1 us */
|
||||
|
@@ -934,8 +934,7 @@ extern const struct file_operations ceph_dir_fops;
|
||||
extern const struct file_operations ceph_snapdir_fops;
|
||||
extern const struct inode_operations ceph_dir_iops;
|
||||
extern const struct inode_operations ceph_snapdir_iops;
|
||||
extern const struct dentry_operations ceph_dentry_ops, ceph_snap_dentry_ops,
|
||||
ceph_snapdir_dentry_ops;
|
||||
extern const struct dentry_operations ceph_dentry_ops;
|
||||
|
||||
extern loff_t ceph_make_fpos(unsigned high, unsigned off, bool hash_order);
|
||||
extern int ceph_handle_notrace_create(struct inode *dir, struct dentry *dentry);
|
||||
@@ -951,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);
|
||||
|
||||
|
Reference in New Issue
Block a user