Skip to content

Commit

Permalink
Merge branches 'work.namei', 'work.dcache' and 'work.iov_iter' into f…
Browse files Browse the repository at this point in the history
…or-linus
  • Loading branch information
Al Viro committed Dec 15, 2016
4 parents 1d0fd57 + 8f64fb1 + ad5cb12 + 0b62fca commit c4364f8
Show file tree
Hide file tree
Showing 34 changed files with 221 additions and 316 deletions.
2 changes: 1 addition & 1 deletion drivers/bluetooth/hci_vhci.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ static inline ssize_t vhci_get_user(struct vhci_data *data,
if (!skb)
return -ENOMEM;

if (copy_from_iter(skb_put(skb, len), len, from) != len) {
if (!copy_from_iter_full(skb_put(skb, len), len, from)) {
kfree_skb(skb);
return -EFAULT;
}
Expand Down
4 changes: 1 addition & 3 deletions drivers/net/macvtap.c
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,6 @@ static ssize_t macvtap_get_user(struct macvtap_queue *q, struct msghdr *m,
int depth;
bool zerocopy = false;
size_t linear;
ssize_t n;

if (q->flags & IFF_VNET_HDR) {
vnet_hdr_len = q->vnet_hdr_sz;
Expand All @@ -684,8 +683,7 @@ static ssize_t macvtap_get_user(struct macvtap_queue *q, struct msghdr *m,
len -= vnet_hdr_len;

err = -EFAULT;
n = copy_from_iter(&vnet_hdr, sizeof(vnet_hdr), from);
if (n != sizeof(vnet_hdr))
if (!copy_from_iter_full(&vnet_hdr, sizeof(vnet_hdr), from))
goto err;
iov_iter_advance(from, vnet_hdr_len - sizeof(vnet_hdr));
if ((vnet_hdr.flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) &&
Expand Down
7 changes: 2 additions & 5 deletions drivers/net/tun.c
Original file line number Diff line number Diff line change
Expand Up @@ -1171,7 +1171,6 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
bool zerocopy = false;
int err;
u32 rxhash;
ssize_t n;

if (!(tun->dev->flags & IFF_UP))
return -EIO;
Expand All @@ -1181,8 +1180,7 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
return -EINVAL;
len -= sizeof(pi);

n = copy_from_iter(&pi, sizeof(pi), from);
if (n != sizeof(pi))
if (!copy_from_iter_full(&pi, sizeof(pi), from))
return -EFAULT;
}

Expand All @@ -1191,8 +1189,7 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
return -EINVAL;
len -= tun->vnet_hdr_sz;

n = copy_from_iter(&gso, sizeof(gso), from);
if (n != sizeof(gso))
if (!copy_from_iter_full(&gso, sizeof(gso), from))
return -EFAULT;

if ((gso.flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) &&
Expand Down
33 changes: 7 additions & 26 deletions drivers/staging/lustre/lustre/llite/dcache.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,6 @@ static void ll_release(struct dentry *de)

LASSERT(de);
lld = ll_d2d(de);
if (!lld) /* NFS copies the de->d_op methods (bug 4655) */
return;

if (lld->lld_it) {
ll_intent_release(lld->lld_it);
kfree(lld->lld_it);
Expand Down Expand Up @@ -126,30 +123,13 @@ static int ll_ddelete(const struct dentry *de)
return 0;
}

int ll_d_init(struct dentry *de)
static int ll_d_init(struct dentry *de)
{
CDEBUG(D_DENTRY, "ldd on dentry %pd (%p) parent %p inode %p refc %d\n",
de, de, de->d_parent, d_inode(de), d_count(de));

if (!de->d_fsdata) {
struct ll_dentry_data *lld;

lld = kzalloc(sizeof(*lld), GFP_NOFS);
if (likely(lld)) {
spin_lock(&de->d_lock);
if (likely(!de->d_fsdata)) {
de->d_fsdata = lld;
__d_lustre_invalidate(de);
} else {
kfree(lld);
}
spin_unlock(&de->d_lock);
} else {
return -ENOMEM;
}
}
LASSERT(de->d_op == &ll_d_ops);

struct ll_dentry_data *lld = kzalloc(sizeof(*lld), GFP_KERNEL);
if (unlikely(!lld))
return -ENOMEM;
lld->lld_invalid = 1;
de->d_fsdata = lld;
return 0;
}

Expand Down Expand Up @@ -300,6 +280,7 @@ static int ll_revalidate_nd(struct dentry *dentry, unsigned int flags)
}

const struct dentry_operations ll_d_ops = {
.d_init = ll_d_init,
.d_revalidate = ll_revalidate_nd,
.d_release = ll_release,
.d_delete = ll_ddelete,
Expand Down
17 changes: 3 additions & 14 deletions drivers/staging/lustre/lustre/llite/llite_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,6 @@ int ll_hsm_release(struct inode *inode);

/* llite/dcache.c */

int ll_d_init(struct dentry *de);
extern const struct dentry_operations ll_d_ops;
void ll_intent_drop_lock(struct lookup_intent *);
void ll_intent_release(struct lookup_intent *);
Expand Down Expand Up @@ -1189,7 +1188,7 @@ dentry_may_statahead(struct inode *dir, struct dentry *dentry)
* 'lld_sa_generation == lli->lli_sa_generation'.
*/
ldd = ll_d2d(dentry);
if (ldd && ldd->lld_sa_generation == lli->lli_sa_generation)
if (ldd->lld_sa_generation == lli->lli_sa_generation)
return false;

return true;
Expand Down Expand Up @@ -1317,17 +1316,7 @@ static inline void ll_set_lock_data(struct obd_export *exp, struct inode *inode,

static inline int d_lustre_invalid(const struct dentry *dentry)
{
struct ll_dentry_data *lld = ll_d2d(dentry);

return !lld || lld->lld_invalid;
}

static inline void __d_lustre_invalidate(struct dentry *dentry)
{
struct ll_dentry_data *lld = ll_d2d(dentry);

if (lld)
lld->lld_invalid = 1;
return ll_d2d(dentry)->lld_invalid;
}

/*
Expand All @@ -1343,7 +1332,7 @@ static inline void d_lustre_invalidate(struct dentry *dentry, int nested)

spin_lock_nested(&dentry->d_lock,
nested ? DENTRY_D_LOCK_NESTED : DENTRY_D_LOCK_NORMAL);
__d_lustre_invalidate(dentry);
ll_d2d(dentry)->lld_invalid = 1;
/*
* We should be careful about dentries created by d_obtain_alias().
* These dentries are not put in the dentry tree, instead they are
Expand Down
22 changes: 6 additions & 16 deletions drivers/staging/lustre/lustre/llite/llite_nfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,22 +169,12 @@ ll_iget_for_nfs(struct super_block *sb, struct lu_fid *fid, struct lu_fid *paren
/* N.B. d_obtain_alias() drops inode ref on error */
result = d_obtain_alias(inode);
if (!IS_ERR(result)) {
int rc;

rc = ll_d_init(result);
if (rc < 0) {
dput(result);
result = ERR_PTR(rc);
} else {
struct ll_dentry_data *ldd = ll_d2d(result);

/*
* Need to signal to the ll_intent_file_open that
* we came from NFS and so opencache needs to be
* enabled for this one
*/
ldd->lld_nfs_dentry = 1;
}
/*
* Need to signal to the ll_intent_file_open that
* we came from NFS and so opencache needs to be
* enabled for this one
*/
ll_d2d(result)->lld_nfs_dentry = 1;
}

return result;
Expand Down
13 changes: 1 addition & 12 deletions drivers/staging/lustre/lustre/llite/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -395,17 +395,9 @@ static struct dentry *ll_find_alias(struct inode *inode, struct dentry *dentry)
*/
struct dentry *ll_splice_alias(struct inode *inode, struct dentry *de)
{
struct dentry *new;
int rc;

if (inode) {
new = ll_find_alias(inode, de);
struct dentry *new = ll_find_alias(inode, de);
if (new) {
rc = ll_d_init(new);
if (rc < 0) {
dput(new);
return ERR_PTR(rc);
}
d_move(new, de);
iput(inode);
CDEBUG(D_DENTRY,
Expand All @@ -414,9 +406,6 @@ struct dentry *ll_splice_alias(struct inode *inode, struct dentry *de)
return new;
}
}
rc = ll_d_init(de);
if (rc < 0)
return ERR_PTR(rc);
d_add(de, inode);
CDEBUG(D_DENTRY, "Add dentry %p inode %p refc %d flags %#x\n",
de, d_inode(de), d_count(de), de->d_flags);
Expand Down
4 changes: 1 addition & 3 deletions drivers/staging/lustre/lustre/llite/statahead.c
Original file line number Diff line number Diff line change
Expand Up @@ -1513,9 +1513,7 @@ static int revalidate_statahead_dentry(struct inode *dir,
*/
ldd = ll_d2d(*dentryp);
lli = ll_i2info(dir);
/* ldd can be NULL if llite lookup failed. */
if (ldd)
ldd->lld_sa_generation = lli->lli_sa_generation;
ldd->lld_sa_generation = lli->lli_sa_generation;
sa_put(sai, entry);
return rc;
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/usb/gadget/function/f_fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -949,7 +949,7 @@ static ssize_t ffs_epfile_io(struct file *file, struct ffs_io_data *io_data)
goto error_mutex;
}
if (!io_data->read &&
copy_from_iter(data, data_len, &io_data->data) != data_len) {
!copy_from_iter_full(data, data_len, &io_data->data)) {
ret = -EFAULT;
goto error_mutex;
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/usb/gadget/legacy/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ ep_write_iter(struct kiocb *iocb, struct iov_iter *from)
return -ENOMEM;
}

if (unlikely(copy_from_iter(buf, len, from) != len)) {
if (unlikely(!copy_from_iter_full(buf, len, from))) {
value = -EFAULT;
goto out;
}
Expand Down
3 changes: 1 addition & 2 deletions drivers/vhost/scsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -922,8 +922,7 @@ vhost_scsi_handle_vq(struct vhost_scsi *vs, struct vhost_virtqueue *vq)
*/
iov_iter_init(&out_iter, WRITE, vq->iov, out, out_size);

ret = copy_from_iter(req, req_size, &out_iter);
if (unlikely(ret != req_size)) {
if (unlikely(!copy_from_iter_full(req, req_size, &out_iter))) {
vq_err(vq, "Faulted on copy_from_iter\n");
vhost_scsi_send_bad_target(vs, vq, head, out);
continue;
Expand Down
3 changes: 1 addition & 2 deletions drivers/vhost/vhost.c
Original file line number Diff line number Diff line change
Expand Up @@ -1862,8 +1862,7 @@ static int get_indirect(struct vhost_virtqueue *vq,
i, count);
return -EINVAL;
}
if (unlikely(copy_from_iter(&desc, sizeof(desc), &from) !=
sizeof(desc))) {
if (unlikely(!copy_from_iter_full(&desc, sizeof(desc), &from))) {
vq_err(vq, "Failed indirect descriptor: idx %d, %zx\n",
i, (size_t)vhost64_to_cpu(vq, indirect->addr) + i * sizeof desc);
return -EINVAL;
Expand Down
51 changes: 5 additions & 46 deletions fs/ceph/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -1319,16 +1294,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.
Expand All @@ -1347,6 +1312,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
Expand Down Expand Up @@ -1517,14 +1485,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,
};
Loading

0 comments on commit c4364f8

Please sign in to comment.