Unified · Split
| @@ -181,7 +181,7 @@ static inline ssize_t vhci_get_user(struct vhci_data *data, · 180 unmodified lines | ||
| 181 | 181 | if (!skb) |
| 182 | 182 | return -ENOMEM; |
| 183 | 183 | |
| 184 | − if (copy_from_iter(skb_put(skb, len), len, from) != len) { | |
| 184 | + if (!copy_from_iter_full(skb_put(skb, len), len, from)) { | |
| 185 | 185 | kfree_skb(skb); |
| 186 | 186 | return -EFAULT; |
| 187 | 187 | } |
| @@ -673,7 +673,6 @@ static ssize_t macvtap_get_user(struct macvtap_queue *q, struct msghdr *m, · 672 unmodified lines | ||
| 673 | 673 | int depth; |
| 674 | 674 | bool zerocopy = false; |
| 675 | 675 | size_t linear; |
| 676 | − ssize_t n; | |
| 677 | 676 | |
| 678 | 677 | if (q->flags & IFF_VNET_HDR) { |
| 679 | 678 | vnet_hdr_len = q->vnet_hdr_sz; |
| @@ -684,8 +683,7 @@ static ssize_t macvtap_get_user(struct macvtap_queue *q, struct msghdr *m, · 4 unmodified lines | ||
| 684 | 683 | len -= vnet_hdr_len; |
| 685 | 684 | |
| 686 | 685 | err = -EFAULT; |
| 687 | − n = copy_from_iter(&vnet_hdr, sizeof(vnet_hdr), from); | |
| 688 | − if (n != sizeof(vnet_hdr)) | |
| 686 | + if (!copy_from_iter_full(&vnet_hdr, sizeof(vnet_hdr), from)) | |
| 689 | 687 | goto err; |
| 690 | 688 | iov_iter_advance(from, vnet_hdr_len - sizeof(vnet_hdr)); |
| 691 | 689 | if ((vnet_hdr.flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) && |
| @@ -1171,7 +1171,6 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile, · 1170 unmodified lines | ||
| 1171 | 1171 | bool zerocopy = false; |
| 1172 | 1172 | int err; |
| 1173 | 1173 | u32 rxhash; |
| 1174 | − ssize_t n; | |
| 1175 | 1174 | |
| 1176 | 1175 | if (!(tun->dev->flags & IFF_UP)) |
| 1177 | 1176 | return -EIO; |
| @@ -1181,8 +1180,7 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile, · 3 unmodified lines | ||
| 1181 | 1180 | return -EINVAL; |
| 1182 | 1181 | len -= sizeof(pi); |
| 1183 | 1182 | |
| 1184 | − n = copy_from_iter(&pi, sizeof(pi), from); | |
| 1185 | − if (n != sizeof(pi)) | |
| 1183 | + if (!copy_from_iter_full(&pi, sizeof(pi), from)) | |
| 1186 | 1184 | return -EFAULT; |
| 1187 | 1185 | } |
| 1188 | 1186 | |
| @@ -1191,8 +1189,7 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile, · 2 unmodified lines | ||
| 1191 | 1189 | return -EINVAL; |
| 1192 | 1190 | len -= tun->vnet_hdr_sz; |
| 1193 | 1191 | |
| 1194 | − n = copy_from_iter(&gso, sizeof(gso), from); | |
| 1195 | − if (n != sizeof(gso)) | |
| 1192 | + if (!copy_from_iter_full(&gso, sizeof(gso), from)) | |
| 1196 | 1193 | return -EFAULT; |
| 1197 | 1194 | |
| 1198 | 1195 | if ((gso.flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) && |
| @@ -57,9 +57,6 @@ static void ll_release(struct dentry *de) · 56 unmodified lines | ||
| 57 | 57 | |
| 58 | 58 | LASSERT(de); |
| 59 | 59 | lld = ll_d2d(de); |
| 60 | − if (!lld) /* NFS copies the de->d_op methods (bug 4655) */ | |
| 61 | − return; | |
| 62 | − | |
| 63 | 60 | if (lld->lld_it) { |
| 64 | 61 | ll_intent_release(lld->lld_it); |
| 65 | 62 | kfree(lld->lld_it); |
| @@ -126,30 +123,13 @@ static int ll_ddelete(const struct dentry *de) · 60 unmodified lines | ||
| 126 | 123 | return 0; |
| 127 | 124 | } |
| 128 | 125 | |
| 129 | −int ll_d_init(struct dentry *de) | |
| 126 | +static int ll_d_init(struct dentry *de) | |
| 130 | 127 | { |
| 131 | − CDEBUG(D_DENTRY, "ldd on dentry %pd (%p) parent %p inode %p refc %d\n", | |
| 132 | − de, de, de->d_parent, d_inode(de), d_count(de)); | |
| 133 | − | |
| 134 | − if (!de->d_fsdata) { | |
| 135 | − struct ll_dentry_data *lld; | |
| 136 | − | |
| 137 | − lld = kzalloc(sizeof(*lld), GFP_NOFS); | |
| 138 | − if (likely(lld)) { | |
| 139 | − spin_lock(&de->d_lock); | |
| 140 | − if (likely(!de->d_fsdata)) { | |
| 141 | − de->d_fsdata = lld; | |
| 142 | − __d_lustre_invalidate(de); | |
| 143 | − } else { | |
| 144 | − kfree(lld); | |
| 145 | − } | |
| 146 | − spin_unlock(&de->d_lock); | |
| 147 | − } else { | |
| 148 | − return -ENOMEM; | |
| 149 | − } | |
| 150 | − } | |
| 151 | − LASSERT(de->d_op == &ll_d_ops); | |
| 152 | − | |
| 128 | + struct ll_dentry_data *lld = kzalloc(sizeof(*lld), GFP_KERNEL); | |
| 129 | + if (unlikely(!lld)) | |
| 130 | + return -ENOMEM; | |
| 131 | + lld->lld_invalid = 1; | |
| 132 | + de->d_fsdata = lld; | |
| 153 | 133 | return 0; |
| 154 | 134 | } |
| 155 | 135 | |
| @@ -300,6 +280,7 @@ static int ll_revalidate_nd(struct dentry *dentry, unsigned int flags) · 144 unmodified lines | ||
| 300 | 280 | } |
| 301 | 281 | |
| 302 | 282 | const struct dentry_operations ll_d_ops = { |
| 283 | + .d_init = ll_d_init, | |
| 303 | 284 | .d_revalidate = ll_revalidate_nd, |
| 304 | 285 | .d_release = ll_release, |
| 305 | 286 | .d_delete = ll_ddelete, |
| @@ -801,7 +801,6 @@ int ll_hsm_release(struct inode *inode); · 800 unmodified lines | ||
| 801 | 801 | |
| 802 | 802 | /* llite/dcache.c */ |
| 803 | 803 | |
| 804 | −int ll_d_init(struct dentry *de); | |
| 805 | 804 | extern const struct dentry_operations ll_d_ops; |
| 806 | 805 | void ll_intent_drop_lock(struct lookup_intent *); |
| 807 | 806 | void ll_intent_release(struct lookup_intent *); |
| @@ -1189,7 +1188,7 @@ dentry_may_statahead(struct inode *dir, struct dentry *dentry) · 381 unmodified lines | ||
| 1189 | 1188 | * 'lld_sa_generation == lli->lli_sa_generation'. |
| 1190 | 1189 | */ |
| 1191 | 1190 | ldd = ll_d2d(dentry); |
| 1192 | − if (ldd && ldd->lld_sa_generation == lli->lli_sa_generation) | |
| 1191 | + if (ldd->lld_sa_generation == lli->lli_sa_generation) | |
| 1193 | 1192 | return false; |
| 1194 | 1193 | |
| 1195 | 1194 | return true; |
| @@ -1317,17 +1316,7 @@ static inline void ll_set_lock_data(struct obd_export *exp, struct inode *inode, · 121 unmodified lines | ||
| 1317 | 1316 | |
| 1318 | 1317 | static inline int d_lustre_invalid(const struct dentry *dentry) |
| 1319 | 1318 | { |
| 1320 | − struct ll_dentry_data *lld = ll_d2d(dentry); | |
| 1321 | − | |
| 1322 | − return !lld || lld->lld_invalid; | |
| 1323 | −} | |
| 1324 | − | |
| 1325 | −static inline void __d_lustre_invalidate(struct dentry *dentry) | |
| 1326 | −{ | |
| 1327 | − struct ll_dentry_data *lld = ll_d2d(dentry); | |
| 1328 | − | |
| 1329 | − if (lld) | |
| 1330 | − lld->lld_invalid = 1; | |
| 1319 | + return ll_d2d(dentry)->lld_invalid; | |
| 1331 | 1320 | } |
| 1332 | 1321 | |
| 1333 | 1322 | /* |
| @@ -1343,7 +1332,7 @@ static inline void d_lustre_invalidate(struct dentry *dentry, int nested) · 9 unmodified lines | ||
| 1343 | 1332 | |
| 1344 | 1333 | spin_lock_nested(&dentry->d_lock, |
| 1345 | 1334 | nested ? DENTRY_D_LOCK_NESTED : DENTRY_D_LOCK_NORMAL); |
| 1346 | − __d_lustre_invalidate(dentry); | |
| 1335 | + ll_d2d(dentry)->lld_invalid = 1; | |
| 1347 | 1336 | /* |
| 1348 | 1337 | * We should be careful about dentries created by d_obtain_alias(). |
| 1349 | 1338 | * These dentries are not put in the dentry tree, instead they are |
| @@ -169,22 +169,12 @@ ll_iget_for_nfs(struct super_block *sb, struct lu_fid *fid, struct lu_fid *paren · 168 unmodified lines | ||
| 169 | 169 | /* N.B. d_obtain_alias() drops inode ref on error */ |
| 170 | 170 | result = d_obtain_alias(inode); |
| 171 | 171 | if (!IS_ERR(result)) { |
| 172 | − int rc; | |
| 173 | − | |
| 174 | − rc = ll_d_init(result); | |
| 175 | − if (rc < 0) { | |
| 176 | − dput(result); | |
| 177 | − result = ERR_PTR(rc); | |
| 178 | − } else { | |
| 179 | − struct ll_dentry_data *ldd = ll_d2d(result); | |
| 180 | − | |
| 181 | − /* | |
| 182 | − * Need to signal to the ll_intent_file_open that | |
| 183 | − * we came from NFS and so opencache needs to be | |
| 184 | − * enabled for this one | |
| 185 | − */ | |
| 186 | − ldd->lld_nfs_dentry = 1; | |
| 187 | − } | |
| 172 | + /* | |
| 173 | + * Need to signal to the ll_intent_file_open that | |
| 174 | + * we came from NFS and so opencache needs to be | |
| 175 | + * enabled for this one | |
| 176 | + */ | |
| 177 | + ll_d2d(result)->lld_nfs_dentry = 1; | |
| 188 | 178 | } |
| 189 | 179 | |
| 190 | 180 | return result; |
| @@ -395,17 +395,9 @@ static struct dentry *ll_find_alias(struct inode *inode, struct dentry *dentry) · 394 unmodified lines | ||
| 395 | 395 | */ |
| 396 | 396 | struct dentry *ll_splice_alias(struct inode *inode, struct dentry *de) |
| 397 | 397 | { |
| 398 | − struct dentry *new; | |
| 399 | − int rc; | |
| 400 | − | |
| 401 | 398 | if (inode) { |
| 402 | − new = ll_find_alias(inode, de); | |
| 399 | + struct dentry *new = ll_find_alias(inode, de); | |
| 403 | 400 | if (new) { |
| 404 | − rc = ll_d_init(new); | |
| 405 | − if (rc < 0) { | |
| 406 | − dput(new); | |
| 407 | − return ERR_PTR(rc); | |
| 408 | − } | |
| 409 | 401 | d_move(new, de); |
| 410 | 402 | iput(inode); |
| 411 | 403 | CDEBUG(D_DENTRY, |
| @@ -414,9 +406,6 @@ struct dentry *ll_splice_alias(struct inode *inode, struct dentry *de) · 2 unmodified lines | ||
| 414 | 406 | return new; |
| 415 | 407 | } |
| 416 | 408 | } |
| 417 | − rc = ll_d_init(de); | |
| 418 | − if (rc < 0) | |
| 419 | − return ERR_PTR(rc); | |
| 420 | 409 | d_add(de, inode); |
| 421 | 410 | CDEBUG(D_DENTRY, "Add dentry %p inode %p refc %d flags %#x\n", |
| 422 | 411 | de, d_inode(de), d_count(de), de->d_flags); |
| @@ -1513,9 +1513,7 @@ out_unplug: · 1512 unmodified lines | ||
| 1513 | 1513 | */ |
| 1514 | 1514 | ldd = ll_d2d(*dentryp); |
| 1515 | 1515 | lli = ll_i2info(dir); |
| 1516 | − /* ldd can be NULL if llite lookup failed. */ | |
| 1517 | − if (ldd) | |
| 1518 | − ldd->lld_sa_generation = lli->lli_sa_generation; | |
| 1516 | + ldd->lld_sa_generation = lli->lli_sa_generation; | |
| 1519 | 1517 | sa_put(sai, entry); |
| 1520 | 1518 | return rc; |
| 1521 | 1519 | } |
| @@ -949,7 +949,7 @@ static ssize_t ffs_epfile_io(struct file *file, struct ffs_io_data *io_data) · 948 unmodified lines | ||
| 949 | 949 | goto error_mutex; |
| 950 | 950 | } |
| 951 | 951 | if (!io_data->read && |
| 952 | − copy_from_iter(data, data_len, &io_data->data) != data_len) { | |
| 952 | + !copy_from_iter_full(data, data_len, &io_data->data)) { | |
| 953 | 953 | ret = -EFAULT; |
| 954 | 954 | goto error_mutex; |
| 955 | 955 | } |
| @@ -667,7 +667,7 @@ ep_write_iter(struct kiocb *iocb, struct iov_iter *from) · 666 unmodified lines | ||
| 667 | 667 | return -ENOMEM; |
| 668 | 668 | } |
| 669 | 669 | |
| 670 | − if (unlikely(copy_from_iter(buf, len, from) != len)) { | |
| 670 | + if (unlikely(!copy_from_iter_full(buf, len, from))) { | |
| 671 | 671 | value = -EFAULT; |
| 672 | 672 | goto out; |
| 673 | 673 | } |
| @@ -922,8 +922,7 @@ vhost_scsi_handle_vq(struct vhost_scsi *vs, struct vhost_virtqueue *vq) · 921 unmodified lines | ||
| 922 | 922 | */ |
| 923 | 923 | iov_iter_init(&out_iter, WRITE, vq->iov, out, out_size); |
| 924 | 924 | |
| 925 | − ret = copy_from_iter(req, req_size, &out_iter); | |
| 926 | − if (unlikely(ret != req_size)) { | |
| 925 | + if (unlikely(!copy_from_iter_full(req, req_size, &out_iter))) { | |
| 927 | 926 | vq_err(vq, "Faulted on copy_from_iter\n"); |
| 928 | 927 | vhost_scsi_send_bad_target(vs, vq, head, out); |
| 929 | 928 | continue; |
| @@ -1862,8 +1862,7 @@ static int get_indirect(struct vhost_virtqueue *vq, · 1861 unmodified lines | ||
| 1862 | 1862 | i, count); |
| 1863 | 1863 | return -EINVAL; |
| 1864 | 1864 | } |
| 1865 | − if (unlikely(copy_from_iter(&desc, sizeof(desc), &from) != | |
| 1866 | − sizeof(desc))) { | |
| 1865 | + if (unlikely(!copy_from_iter_full(&desc, sizeof(desc), &from))) { | |
| 1867 | 1866 | vq_err(vq, "Failed indirect descriptor: idx %d, %zx\n", |
| 1868 | 1867 | i, (size_t)vhost64_to_cpu(vq, indirect->addr) + i * sizeof desc); |
| 1869 | 1868 | return -EINVAL; |
| @@ -32,40 +32,19 @@ const struct dentry_operations ceph_dentry_ops; · 31 unmodified lines | ||
| 32 | 32 | /* |
| 33 | 33 | * Initialize ceph dentry state. |
| 34 | 34 | */ |
| 35 | −int ceph_init_dentry(struct dentry *dentry) | |
| 35 | +static int ceph_d_init(struct dentry *dentry) | |
| 36 | 36 | { |
| 37 | 37 | struct ceph_dentry_info *di; |
| 38 | 38 | |
| 39 | − if (dentry->d_fsdata) | |
| 40 | − return 0; | |
| 41 | − | |
| 42 | 39 | di = kmem_cache_zalloc(ceph_dentry_cachep, GFP_KERNEL); |
| 43 | 40 | if (!di) |
| 44 | 41 | return -ENOMEM; /* oh well */ |
| 45 | 42 | |
| 46 | − spin_lock(&dentry->d_lock); | |
| 47 | − if (dentry->d_fsdata) { | |
| 48 | − /* lost a race */ | |
| 49 | − kmem_cache_free(ceph_dentry_cachep, di); | |
| 50 | − goto out_unlock; | |
| 51 | − } | |
| 52 | − | |
| 53 | − if (ceph_snap(d_inode(dentry->d_parent)) == CEPH_NOSNAP) | |
| 54 | − d_set_d_op(dentry, &ceph_dentry_ops); | |
| 55 | − else if (ceph_snap(d_inode(dentry->d_parent)) == CEPH_SNAPDIR) | |
| 56 | − d_set_d_op(dentry, &ceph_snapdir_dentry_ops); | |
| 57 | − else | |
| 58 | − d_set_d_op(dentry, &ceph_snap_dentry_ops); | |
| 59 | − | |
| 60 | 43 | di->dentry = dentry; |
| 61 | 44 | di->lease_session = NULL; |
| 62 | 45 | di->time = jiffies; |
| 63 | − /* avoid reordering d_fsdata setup so that the check above is safe */ | |
| 64 | − smp_mb(); | |
| 65 | 46 | dentry->d_fsdata = di; |
| 66 | 47 | ceph_dentry_lru_add(dentry); |
| 67 | −out_unlock: | |
| 68 | − spin_unlock(&dentry->d_lock); | |
| 69 | 48 | return 0; |
| 70 | 49 | } |
| 71 | 50 | |
| @@ -737,10 +716,6 @@ static struct dentry *ceph_lookup(struct inode *dir, struct dentry *dentry, · 665 unmodified lines | ||
| 737 | 716 | if (dentry->d_name.len > NAME_MAX) |
| 738 | 717 | return ERR_PTR(-ENAMETOOLONG); |
| 739 | 718 | |
| 740 | − err = ceph_init_dentry(dentry); | |
| 741 | − if (err < 0) | |
| 742 | − return ERR_PTR(err); | |
| 743 | − | |
| 744 | 719 | /* can we conclude ENOENT locally? */ |
| 745 | 720 | if (d_really_is_negative(dentry)) { |
| 746 | 721 | struct ceph_inode_info *ci = ceph_inode(dir); |
| @@ -1319,16 +1294,6 @@ static void ceph_d_release(struct dentry *dentry) · 572 unmodified lines | ||
| 1319 | 1294 | kmem_cache_free(ceph_dentry_cachep, di); |
| 1320 | 1295 | } |
| 1321 | 1296 | |
| 1322 | −static int ceph_snapdir_d_revalidate(struct dentry *dentry, | |
| 1323 | − unsigned int flags) | |
| 1324 | −{ | |
| 1325 | − /* | |
| 1326 | − * Eventually, we'll want to revalidate snapped metadata | |
| 1327 | − * too... probably... | |
| 1328 | − */ | |
| 1329 | − return 1; | |
| 1330 | −} | |
| 1331 | − | |
| 1332 | 1297 | /* |
| 1333 | 1298 | * When the VFS prunes a dentry from the cache, we need to clear the |
| 1334 | 1299 | * complete flag on the parent directory. |
| @@ -1347,6 +1312,9 @@ static void ceph_d_prune(struct dentry *dentry) · 12 unmodified lines | ||
| 1347 | 1312 | if (d_unhashed(dentry)) |
| 1348 | 1313 | return; |
| 1349 | 1314 | |
| 1315 | + if (ceph_snap(d_inode(dentry->d_parent)) == CEPH_SNAPDIR) | |
| 1316 | + return; | |
| 1317 | + | |
| 1350 | 1318 | /* |
| 1351 | 1319 | * we hold d_lock, so d_parent is stable, and d_fsdata is never |
| 1352 | 1320 | * cleared until d_release |
| @@ -1517,14 +1485,5 @@ const struct dentry_operations ceph_dentry_ops = { · 164 unmodified lines | ||
| 1517 | 1485 | .d_revalidate = ceph_d_revalidate, |
| 1518 | 1486 | .d_release = ceph_d_release, |
| 1519 | 1487 | .d_prune = ceph_d_prune, |
| 1520 | −}; | |
| 1521 | − | |
| 1522 | −const struct dentry_operations ceph_snapdir_dentry_ops = { | |
| 1523 | − .d_revalidate = ceph_snapdir_d_revalidate, | |
| 1524 | − .d_release = ceph_d_release, | |
| 1525 | −}; | |
| 1526 | − | |
| 1527 | −const struct dentry_operations ceph_snap_dentry_ops = { | |
| 1528 | − .d_release = ceph_d_release, | |
| 1529 | − .d_prune = ceph_d_prune, | |
| 1488 | + .d_init = ceph_d_init, | |
| 1530 | 1489 | }; |
| @@ -62,7 +62,6 @@ static struct dentry *__fh_to_dentry(struct super_block *sb, u64 ino) · 61 unmodified lines | ||
| 62 | 62 | { |
| 63 | 63 | struct ceph_mds_client *mdsc = ceph_sb_to_client(sb)->mdsc; |
| 64 | 64 | struct inode *inode; |
| 65 | − struct dentry *dentry; | |
| 66 | 65 | struct ceph_vino vino; |
| 67 | 66 | int err; |
| 68 | 67 | |
| @@ -94,16 +93,7 @@ static struct dentry *__fh_to_dentry(struct super_block *sb, u64 ino) · 25 unmodified lines | ||
| 94 | 93 | return ERR_PTR(-ESTALE); |
| 95 | 94 | } |
| 96 | 95 | |
| 97 | − dentry = d_obtain_alias(inode); | |
| 98 | − if (IS_ERR(dentry)) | |
| 99 | − return dentry; | |
| 100 | − err = ceph_init_dentry(dentry); | |
| 101 | − if (err < 0) { | |
| 102 | − dput(dentry); | |
| 103 | − return ERR_PTR(err); | |
| 104 | − } | |
| 105 | − dout("__fh_to_dentry %llx %p dentry %p\n", ino, inode, dentry); | |
| 106 | − return dentry; | |
| 96 | + return d_obtain_alias(inode); | |
| 107 | 97 | } |
| 108 | 98 | |
| 109 | 99 | /* |
| @@ -131,7 +121,6 @@ static struct dentry *__get_parent(struct super_block *sb, · 21 unmodified lines | ||
| 131 | 121 | struct ceph_mds_client *mdsc = ceph_sb_to_client(sb)->mdsc; |
| 132 | 122 | struct ceph_mds_request *req; |
| 133 | 123 | struct inode *inode; |
| 134 | − struct dentry *dentry; | |
| 135 | 124 | int mask; |
| 136 | 125 | int err; |
| 137 | 126 | |
| @@ -164,18 +153,7 @@ static struct dentry *__get_parent(struct super_block *sb, · 26 unmodified lines | ||
| 164 | 153 | if (!inode) |
| 165 | 154 | return ERR_PTR(-ENOENT); |
| 166 | 155 | |
| 167 | − dentry = d_obtain_alias(inode); | |
| 168 | − if (IS_ERR(dentry)) | |
| 169 | − return dentry; | |
| 170 | − err = ceph_init_dentry(dentry); | |
| 171 | − if (err < 0) { | |
| 172 | − dput(dentry); | |
| 173 | − return ERR_PTR(err); | |
| 174 | − } | |
| 175 | − dout("__get_parent ino %llx parent %p ino %llx.%llx\n", | |
| 176 | − child ? ceph_ino(d_inode(child)) : ino, | |
| 177 | − dentry, ceph_vinop(inode)); | |
| 178 | − return dentry; | |
| 156 | + return d_obtain_alias(inode); | |
| 179 | 157 | } |
| 180 | 158 | |
| 181 | 159 | static struct dentry *ceph_get_parent(struct dentry *child) |
| @@ -351,10 +351,6 @@ int ceph_atomic_open(struct inode *dir, struct dentry *dentry, · 350 unmodified lines | ||
| 351 | 351 | if (dentry->d_name.len > NAME_MAX) |
| 352 | 352 | return -ENAMETOOLONG; |
| 353 | 353 | |
| 354 | − err = ceph_init_dentry(dentry); | |
| 355 | − if (err < 0) | |
| 356 | − return err; | |
| 357 | − | |
| 358 | 354 | if (flags & O_CREAT) { |
| 359 | 355 | err = ceph_pre_init_acls(dir, &mode, &acls); |
| 360 | 356 | if (err < 0) |
| @@ -1023,16 +1023,17 @@ static void update_dentry_lease(struct dentry *dentry, · 1022 unmodified lines | ||
| 1023 | 1023 | long unsigned half_ttl = from_time + (duration * HZ / 2) / 1000; |
| 1024 | 1024 | struct inode *dir; |
| 1025 | 1025 | |
| 1026 | − /* only track leases on regular dentries */ | |
| 1027 | − if (dentry->d_op != &ceph_dentry_ops) | |
| 1028 | − return; | |
| 1029 | − | |
| 1030 | 1026 | spin_lock(&dentry->d_lock); |
| 1031 | 1027 | dout("update_dentry_lease %p duration %lu ms ttl %lu\n", |
| 1032 | 1028 | dentry, duration, ttl); |
| 1033 | 1029 | |
| 1034 | 1030 | /* make lease_rdcache_gen match directory */ |
| 1035 | 1031 | dir = d_inode(dentry->d_parent); |
| 1032 | + | |
| 1033 | + /* only track leases on regular dentries */ | |
| 1034 | + if (ceph_snap(dir) != CEPH_NOSNAP) | |
| 1035 | + goto out_unlock; | |
| 1036 | + | |
| 1036 | 1037 | di->lease_shared_gen = ceph_inode(dir)->i_shared_gen; |
| 1037 | 1038 | |
| 1038 | 1039 | if (duration == 0) |
| @@ -1202,12 +1203,7 @@ retry_lookup: · 163 unmodified lines | ||
| 1202 | 1203 | err = -ENOMEM; |
| 1203 | 1204 | goto done; |
| 1204 | 1205 | } |
| 1205 | − err = ceph_init_dentry(dn); | |
| 1206 | − if (err < 0) { | |
| 1207 | − dput(dn); | |
| 1208 | − dput(parent); | |
| 1209 | − goto done; | |
| 1210 | − } | |
| 1206 | + err = 0; | |
| 1211 | 1207 | } else if (d_really_is_positive(dn) && |
| 1212 | 1208 | (ceph_ino(d_inode(dn)) != vino.ino || |
| 1213 | 1209 | ceph_snap(d_inode(dn)) != vino.snap)) { |
| @@ -1561,12 +1557,6 @@ retry_lookup: · 347 unmodified lines | ||
| 1561 | 1557 | err = -ENOMEM; |
| 1562 | 1558 | goto out; |
| 1563 | 1559 | } |
| 1564 | − ret = ceph_init_dentry(dn); | |
| 1565 | − if (ret < 0) { | |
| 1566 | − dput(dn); | |
| 1567 | − err = ret; | |
| 1568 | − goto out; | |
| 1569 | − } | |
| 1570 | 1560 | } else if (d_really_is_positive(dn) && |
| 1571 | 1561 | (ceph_ino(d_inode(dn)) != vino.ino || |
| 1572 | 1562 | ceph_snap(d_inode(dn)) != vino.snap)) { |
| @@ -795,7 +795,6 @@ static struct dentry *open_root_dentry(struct ceph_fs_client *fsc, · 794 unmodified lines | ||
| 795 | 795 | root = ERR_PTR(-ENOMEM); |
| 796 | 796 | goto out; |
| 797 | 797 | } |
| 798 | − ceph_init_dentry(root); | |
| 799 | 798 | dout("open_root_inode success, root dentry is %p\n", root); |
| 800 | 799 | } else { |
| 801 | 800 | root = ERR_PTR(err); |
| @@ -879,6 +878,7 @@ static int ceph_set_super(struct super_block *s, void *data) · 77 unmodified lines | ||
| 879 | 878 | fsc->sb = s; |
| 880 | 879 | |
| 881 | 880 | s->s_op = &ceph_super_ops; |
| 881 | + s->s_d_op = &ceph_dentry_ops; | |
| 882 | 882 | s->s_export_op = &ceph_export_ops; |
| 883 | 883 | |
| 884 | 884 | s->s_time_gran = 1000; /* 1000 ns == 1 us */ |
| @@ -934,8 +934,7 @@ extern const struct file_operations ceph_dir_fops; · 933 unmodified lines | ||
| 934 | 934 | extern const struct file_operations ceph_snapdir_fops; |
| 935 | 935 | extern const struct inode_operations ceph_dir_iops; |
| 936 | 936 | extern const struct inode_operations ceph_snapdir_iops; |
| 937 | −extern const struct dentry_operations ceph_dentry_ops, ceph_snap_dentry_ops, | |
| 938 | − ceph_snapdir_dentry_ops; | |
| 937 | +extern const struct dentry_operations ceph_dentry_ops; | |
| 939 | 938 | |
| 940 | 939 | extern loff_t ceph_make_fpos(unsigned high, unsigned off, bool hash_order); |
| 941 | 940 | 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); · 9 unmodified lines | ||
| 951 | 950 | extern unsigned ceph_dentry_hash(struct inode *dir, struct dentry *dn); |
| 952 | 951 | extern void ceph_readdir_cache_release(struct ceph_readdir_cache_control *ctl); |
| 953 | 952 | |
| 954 | −/* | |
| 955 | − * our d_ops vary depending on whether the inode is live, | |
| 956 | − * snapshotted (read-only), or a virtual ".snap" directory. | |
| 957 | − */ | |
| 958 | −int ceph_init_dentry(struct dentry *dentry); | |
| 959 | − | |
| 960 | − | |
| 961 | 953 | /* ioctl.c */ |
| 962 | 954 | extern long ceph_ioctl(struct file *file, unsigned int cmd, unsigned long arg); |
| 963 | 955 | |
| @@ -1725,30 +1725,35 @@ static int pick_link(struct nameidata *nd, struct path *link, · 1724 unmodified lines | ||
| 1725 | 1725 | return 1; |
| 1726 | 1726 | } |
| 1727 | 1727 | |
| 1728 | +enum {WALK_FOLLOW = 1, WALK_MORE = 2}; | |
| 1729 | + | |
| 1728 | 1730 | /* |
| 1729 | 1731 | * Do we need to follow links? We _really_ want to be able |
| 1730 | 1732 | * to do this check without having to look at inode->i_op, |
| 1731 | 1733 | * so we keep a cache of "no, this doesn't need follow_link" |
| 1732 | 1734 | * for the common case. |
| 1733 | 1735 | */ |
| 1734 | −static inline int should_follow_link(struct nameidata *nd, struct path *link, | |
| 1735 | − int follow, | |
| 1736 | − struct inode *inode, unsigned seq) | |
| 1736 | +static inline int step_into(struct nameidata *nd, struct path *path, | |
| 1737 | + int flags, struct inode *inode, unsigned seq) | |
| 1737 | 1738 | { |
| 1738 | − if (likely(!d_is_symlink(link->dentry))) | |
| 1739 | − return 0; | |
| 1740 | − if (!follow) | |
| 1739 | + if (!(flags & WALK_MORE) && nd->depth) | |
| 1740 | + put_link(nd); | |
| 1741 | + if (likely(!d_is_symlink(path->dentry)) || | |
| 1742 | + !(flags & WALK_FOLLOW || nd->flags & LOOKUP_FOLLOW)) { | |
| 1743 | + /* not a symlink or should not follow */ | |
| 1744 | + path_to_nameidata(path, nd); | |
| 1745 | + nd->inode = inode; | |
| 1746 | + nd->seq = seq; | |
| 1741 | 1747 | return 0; |
| 1748 | + } | |
| 1742 | 1749 | /* make sure that d_is_symlink above matches inode */ |
| 1743 | 1750 | if (nd->flags & LOOKUP_RCU) { |
| 1744 | − if (read_seqcount_retry(&link->dentry->d_seq, seq)) | |
| 1751 | + if (read_seqcount_retry(&path->dentry->d_seq, seq)) | |
| 1745 | 1752 | return -ECHILD; |
| 1746 | 1753 | } |
| 1747 | − return pick_link(nd, link, inode, seq); | |
| 1754 | + return pick_link(nd, path, inode, seq); | |
| 1748 | 1755 | } |
| 1749 | 1756 | |
| 1750 | −enum {WALK_GET = 1, WALK_PUT = 2}; | |
| 1751 | − | |
| 1752 | 1757 | static int walk_component(struct nameidata *nd, int flags) |
| 1753 | 1758 | { |
| 1754 | 1759 | struct path path; |
| @@ -1762,7 +1767,7 @@ static int walk_component(struct nameidata *nd, int flags) · 7 unmodified lines | ||
| 1762 | 1767 | */ |
| 1763 | 1768 | if (unlikely(nd->last_type != LAST_NORM)) { |
| 1764 | 1769 | err = handle_dots(nd, nd->last_type); |
| 1765 | − if (flags & WALK_PUT) | |
| 1770 | + if (!(flags & WALK_MORE) && nd->depth) | |
| 1766 | 1771 | put_link(nd); |
| 1767 | 1772 | return err; |
| 1768 | 1773 | } |
| @@ -1789,15 +1794,7 @@ static int walk_component(struct nameidata *nd, int flags) · 20 unmodified lines | ||
| 1789 | 1794 | inode = d_backing_inode(path.dentry); |
| 1790 | 1795 | } |
| 1791 | 1796 | |
| 1792 | − if (flags & WALK_PUT) | |
| 1793 | − put_link(nd); | |
| 1794 | − err = should_follow_link(nd, &path, flags & WALK_GET, inode, seq); | |
| 1795 | − if (unlikely(err)) | |
| 1796 | − return err; | |
| 1797 | − path_to_nameidata(&path, nd); | |
| 1798 | − nd->inode = inode; | |
| 1799 | − nd->seq = seq; | |
| 1800 | − return 0; | |
| 1797 | + return step_into(nd, &path, flags, inode, seq); | |
| 1801 | 1798 | } |
| 1802 | 1799 | |
| 1803 | 1800 | /* |
| @@ -2104,9 +2101,10 @@ OK: · 300 unmodified lines | ||
| 2104 | 2101 | if (!name) |
| 2105 | 2102 | return 0; |
| 2106 | 2103 | /* last component of nested symlink */ |
| 2107 | − err = walk_component(nd, WALK_GET | WALK_PUT); | |
| 2104 | + err = walk_component(nd, WALK_FOLLOW); | |
| 2108 | 2105 | } else { |
| 2109 | − err = walk_component(nd, WALK_GET); | |
| 2106 | + /* not the last component */ | |
| 2107 | + err = walk_component(nd, WALK_FOLLOW | WALK_MORE); | |
| 2110 | 2108 | } |
| 2111 | 2109 | if (err < 0) |
| 2112 | 2110 | return err; |
| @@ -2248,12 +2246,7 @@ static inline int lookup_last(struct nameidata *nd) · 135 unmodified lines | ||
| 2248 | 2246 | nd->flags |= LOOKUP_FOLLOW | LOOKUP_DIRECTORY; |
| 2249 | 2247 | |
| 2250 | 2248 | nd->flags &= ~LOOKUP_PARENT; |
| 2251 | − return walk_component(nd, | |
| 2252 | − nd->flags & LOOKUP_FOLLOW | |
| 2253 | − ? nd->depth | |
| 2254 | − ? WALK_PUT | WALK_GET | |
| 2255 | − : WALK_GET | |
| 2256 | − : 0); | |
| 2249 | + return walk_component(nd, 0); | |
| 2257 | 2250 | } |
| 2258 | 2251 | |
| 2259 | 2252 | /* Returns 0 and nd will be valid on success; Retuns error, otherwise. */ |
| @@ -2558,28 +2551,9 @@ int user_path_at_empty(int dfd, const char __user *name, unsigned flags, · 298 unmodified lines | ||
| 2558 | 2551 | } |
| 2559 | 2552 | EXPORT_SYMBOL(user_path_at_empty); |
| 2560 | 2553 | |
| 2561 | −/* | |
| 2562 | − * NB: most callers don't do anything directly with the reference to the | |
| 2563 | − * to struct filename, but the nd->last pointer points into the name string | |
| 2564 | − * allocated by getname. So we must hold the reference to it until all | |
| 2565 | − * path-walking is complete. | |
| 2566 | − */ | |
| 2567 | −static inline struct filename * | |
| 2568 | −user_path_parent(int dfd, const char __user *path, | |
| 2569 | − struct path *parent, | |
| 2570 | − struct qstr *last, | |
| 2571 | − int *type, | |
| 2572 | − unsigned int flags) | |
| 2573 | −{ | |
| 2574 | − /* only LOOKUP_REVAL is allowed in extra flags */ | |
| 2575 | − return filename_parentat(dfd, getname(path), flags & LOOKUP_REVAL, | |
| 2576 | − parent, last, type); | |
| 2577 | −} | |
| 2578 | − | |
| 2579 | 2554 | /** |
| 2580 | 2555 | * mountpoint_last - look up last component for umount |
| 2581 | 2556 | * @nd: pathwalk nameidata - currently pointing at parent directory of "last" |
| 2582 | − * @path: pointer to container for result | |
| 2583 | 2557 | * |
| 2584 | 2558 | * This is a special lookup_last function just for umount. In this case, we |
| 2585 | 2559 | * need to resolve the path without doing any revalidation. |
| @@ -2592,23 +2566,20 @@ user_path_parent(int dfd, const char __user *path, · 6 unmodified lines | ||
| 2592 | 2566 | * |
| 2593 | 2567 | * Returns: |
| 2594 | 2568 | * -error: if there was an error during lookup. This includes -ENOENT if the |
| 2595 | − * lookup found a negative dentry. The nd->path reference will also be | |
| 2596 | − * put in this case. | |
| 2569 | + * lookup found a negative dentry. | |
| 2597 | 2570 | * |
| 2598 | − * 0: if we successfully resolved nd->path and found it to not to be a | |
| 2599 | − * symlink that needs to be followed. "path" will also be populated. | |
| 2600 | − * The nd->path reference will also be put. | |
| 2571 | + * 0: if we successfully resolved nd->last and found it to not to be a | |
| 2572 | + * symlink that needs to be followed. | |
| 2601 | 2573 | * |
| 2602 | 2574 | * 1: if we successfully resolved nd->last and found it to be a symlink |
| 2603 | − * that needs to be followed. "path" will be populated with the path | |
| 2604 | − * to the link, and nd->path will *not* be put. | |
| 2575 | + * that needs to be followed. | |
| 2605 | 2576 | */ |
| 2606 | 2577 | static int |
| 2607 | −mountpoint_last(struct nameidata *nd, struct path *path) | |
| 2578 | +mountpoint_last(struct nameidata *nd) | |
| 2608 | 2579 | { |
| 2609 | 2580 | int error = 0; |
| 2610 | − struct dentry *dentry; | |
| 2611 | 2581 | struct dentry *dir = nd->path.dentry; |
| 2582 | + struct path path; | |
| 2612 | 2583 | |
| 2613 | 2584 | /* If we're in rcuwalk, drop out of it to handle last component */ |
| 2614 | 2585 | if (nd->flags & LOOKUP_RCU) { |
| @@ -2622,37 +2593,28 @@ mountpoint_last(struct nameidata *nd, struct path *path) · 7 unmodified lines | ||
| 2622 | 2593 | error = handle_dots(nd, nd->last_type); |
| 2623 | 2594 | if (error) |
| 2624 | 2595 | return error; |
| 2625 | − dentry = dget(nd->path.dentry); | |
| 2596 | + path.dentry = dget(nd->path.dentry); | |
| 2626 | 2597 | } else { |
| 2627 | − dentry = d_lookup(dir, &nd->last); | |
| 2628 | − if (!dentry) { | |
| 2598 | + path.dentry = d_lookup(dir, &nd->last); | |
| 2599 | + if (!path.dentry) { | |
| 2629 | 2600 | /* |
| 2630 | 2601 | * No cached dentry. Mounted dentries are pinned in the |
| 2631 | 2602 | * cache, so that means that this dentry is probably |
| 2632 | 2603 | * a symlink or the path doesn't actually point |
| 2633 | 2604 | * to a mounted dentry. |
| 2634 | 2605 | */ |
| 2635 | − dentry = lookup_slow(&nd->last, dir, | |
| 2606 | + path.dentry = lookup_slow(&nd->last, dir, | |
| 2636 | 2607 | nd->flags | LOOKUP_NO_REVAL); |
| 2637 | − if (IS_ERR(dentry)) | |
| 2638 | − return PTR_ERR(dentry); | |
| 2608 | + if (IS_ERR(path.dentry)) | |
| 2609 | + return PTR_ERR(path.dentry); | |
| 2639 | 2610 | } |
| 2640 | 2611 | } |
| 2641 | − if (d_is_negative(dentry)) { | |
| 2642 | − dput(dentry); | |
| 2612 | + if (d_is_negative(path.dentry)) { | |
| 2613 | + dput(path.dentry); | |
| 2643 | 2614 | return -ENOENT; |
| 2644 | 2615 | } |
| 2645 | − if (nd->depth) | |
| 2646 | − put_link(nd); | |
| 2647 | − path->dentry = dentry; | |
| 2648 | − path->mnt = nd->path.mnt; | |
| 2649 | − error = should_follow_link(nd, path, nd->flags & LOOKUP_FOLLOW, | |
| 2650 | − d_backing_inode(dentry), 0); | |
| 2651 | − if (unlikely(error)) | |
| 2652 | − return error; | |
| 2653 | − mntget(path->mnt); | |
| 2654 | − follow_mount(path); | |
| 2655 | − return 0; | |
| 2616 | + path.mnt = nd->path.mnt; | |
| 2617 | + return step_into(nd, &path, 0, d_backing_inode(path.dentry), 0); | |
| 2656 | 2618 | } |
| 2657 | 2619 | |
| 2658 | 2620 | /** |
| @@ -2672,13 +2634,19 @@ path_mountpoint(struct nameidata *nd, unsigned flags, struct path *path) · 13 unmodified lines | ||
| 2672 | 2634 | if (IS_ERR(s)) |
| 2673 | 2635 | return PTR_ERR(s); |
| 2674 | 2636 | while (!(err = link_path_walk(s, nd)) && |
| 2675 | − (err = mountpoint_last(nd, path)) > 0) { | |
| 2637 | + (err = mountpoint_last(nd)) > 0) { | |
| 2676 | 2638 | s = trailing_symlink(nd); |
| 2677 | 2639 | if (IS_ERR(s)) { |
| 2678 | 2640 | err = PTR_ERR(s); |
| 2679 | 2641 | break; |
| 2680 | 2642 | } |
| 2681 | 2643 | } |
| 2644 | + if (!err) { | |
| 2645 | + *path = nd->path; | |
| 2646 | + nd->path.mnt = NULL; | |
| 2647 | + nd->path.dentry = NULL; | |
| 2648 | + follow_mount(path); | |
| 2649 | + } | |
| 2682 | 2650 | terminate_walk(nd); |
| 2683 | 2651 | return err; |
| 2684 | 2652 | } |
| @@ -3335,18 +3303,11 @@ static int do_last(struct nameidata *nd, · 650 unmodified lines | ||
| 3335 | 3303 | seq = 0; /* out of RCU mode, so the value doesn't matter */ |
| 3336 | 3304 | inode = d_backing_inode(path.dentry); |
| 3337 | 3305 | finish_lookup: |
| 3338 | − if (nd->depth) | |
| 3339 | − put_link(nd); | |
| 3340 | − error = should_follow_link(nd, &path, nd->flags & LOOKUP_FOLLOW, | |
| 3341 | − inode, seq); | |
| 3306 | + error = step_into(nd, &path, 0, inode, seq); | |
| 3342 | 3307 | if (unlikely(error)) |
| 3343 | 3308 | return error; |
| 3344 | − | |
| 3345 | − path_to_nameidata(&path, nd); | |
| 3346 | − nd->inode = inode; | |
| 3347 | − nd->seq = seq; | |
| 3348 | − /* Why this, you ask? _Now_ we might have grown LOOKUP_JUMPED... */ | |
| 3349 | 3309 | finish_open: |
| 3310 | + /* Why this, you ask? _Now_ we might have grown LOOKUP_JUMPED... */ | |
| 3350 | 3311 | error = complete_walk(nd); |
| 3351 | 3312 | if (error) |
| 3352 | 3313 | return error; |
| @@ -3861,8 +3822,8 @@ static long do_rmdir(int dfd, const char __user *pathname) · 508 unmodified lines | ||
| 3861 | 3822 | int type; |
| 3862 | 3823 | unsigned int lookup_flags = 0; |
| 3863 | 3824 | retry: |
| 3864 | − name = user_path_parent(dfd, pathname, | |
| 3865 | − &path, &last, &type, lookup_flags); | |
| 3825 | + name = filename_parentat(dfd, getname(pathname), lookup_flags, | |
| 3826 | + &path, &last, &type); | |
| 3866 | 3827 | if (IS_ERR(name)) |
| 3867 | 3828 | return PTR_ERR(name); |
| 3868 | 3829 | |
| @@ -3991,8 +3952,8 @@ static long do_unlinkat(int dfd, const char __user *pathname) · 122 unmodified lines | ||
| 3991 | 3952 | struct inode *delegated_inode = NULL; |
| 3992 | 3953 | unsigned int lookup_flags = 0; |
| 3993 | 3954 | retry: |
| 3994 | − name = user_path_parent(dfd, pathname, | |
| 3995 | − &path, &last, &type, lookup_flags); | |
| 3955 | + name = filename_parentat(dfd, getname(pathname), lookup_flags, | |
| 3956 | + &path, &last, &type); | |
| 3996 | 3957 | if (IS_ERR(name)) |
| 3997 | 3958 | return PTR_ERR(name); |
| 3998 | 3959 | |
| @@ -4491,15 +4452,15 @@ SYSCALL_DEFINE5(renameat2, int, olddfd, const char __user *, oldname, · 492 unmodified lines | ||
| 4491 | 4452 | target_flags = 0; |
| 4492 | 4453 | |
| 4493 | 4454 | retry: |
| 4494 | − from = user_path_parent(olddfd, oldname, | |
| 4495 | − &old_path, &old_last, &old_type, lookup_flags); | |
| 4455 | + from = filename_parentat(olddfd, getname(oldname), lookup_flags, | |
| 4456 | + &old_path, &old_last, &old_type); | |
| 4496 | 4457 | if (IS_ERR(from)) { |
| 4497 | 4458 | error = PTR_ERR(from); |
| 4498 | 4459 | goto exit; |
| 4499 | 4460 | } |
| 4500 | 4461 | |
| 4501 | − to = user_path_parent(newdfd, newname, | |
| 4502 | − &new_path, &new_last, &new_type, lookup_flags); | |
| 4462 | + to = filename_parentat(newdfd, getname(newname), lookup_flags, | |
| 4463 | + &new_path, &new_last, &new_type); | |
| 4503 | 4464 | if (IS_ERR(to)) { |
| 4504 | 4465 | error = PTR_ERR(to); |
| 4505 | 4466 | goto exit1; |
| @@ -203,7 +203,7 @@ ncp_file_write_iter(struct kiocb *iocb, struct iov_iter *from) · 202 unmodified lines | ||
| 203 | 203 | bufsize - (pos % bufsize), |
| 204 | 204 | iov_iter_count(from)); |
| 205 | 205 | |
| 206 | − if (copy_from_iter(bouncebuffer, to_write, from) != to_write) { | |
| 206 | + if (!copy_from_iter_full(bouncebuffer, to_write, from)) { | |
| 207 | 207 | errno = -EFAULT; |
| 208 | 208 | break; |
| 209 | 209 | } |
| @@ -355,7 +355,6 @@ static ssize_t orangefs_devreq_write_iter(struct kiocb *iocb, · 354 unmodified lines | ||
| 355 | 355 | __u64 tag; |
| 356 | 356 | } head; |
| 357 | 357 | int total = ret = iov_iter_count(iter); |
| 358 | − int n; | |
| 359 | 358 | int downcall_size = sizeof(struct orangefs_downcall_s); |
| 360 | 359 | int head_size = sizeof(head); |
| 361 | 360 | |
| @@ -372,8 +371,7 @@ static ssize_t orangefs_devreq_write_iter(struct kiocb *iocb, · 10 unmodified lines | ||
| 372 | 371 | return -EFAULT; |
| 373 | 372 | } |
| 374 | 373 | |
| 375 | − n = copy_from_iter(&head, head_size, iter); | |
| 376 | − if (n < head_size) { | |
| 374 | + if (!copy_from_iter_full(&head, head_size, iter)) { | |
| 377 | 375 | gossip_err("%s: failed to copy head.\n", __func__); |
| 378 | 376 | return -EFAULT; |
| 379 | 377 | } |
| @@ -407,8 +405,7 @@ static ssize_t orangefs_devreq_write_iter(struct kiocb *iocb, · 27 unmodified lines | ||
| 407 | 405 | return ret; |
| 408 | 406 | } |
| 409 | 407 | |
| 410 | − n = copy_from_iter(&op->downcall, downcall_size, iter); | |
| 411 | − if (n != downcall_size) { | |
| 408 | + if (!copy_from_iter_full(&op->downcall, downcall_size, iter)) { | |
| 412 | 409 | gossip_err("%s: failed to copy downcall.\n", __func__); |
| 413 | 410 | goto Efault; |
| 414 | 411 | } |
| @@ -462,10 +459,8 @@ static ssize_t orangefs_devreq_write_iter(struct kiocb *iocb, · 47 unmodified lines | ||
| 462 | 459 | goto Enomem; |
| 463 | 460 | } |
| 464 | 461 | memset(op->downcall.trailer_buf, 0, op->downcall.trailer_size); |
| 465 | − n = copy_from_iter(op->downcall.trailer_buf, | |
| 466 | − op->downcall.trailer_size, | |
| 467 | − iter); | |
| 468 | − if (n != op->downcall.trailer_size) { | |
| 462 | + if (!copy_from_iter_full(op->downcall.trailer_buf, | |
| 463 | + op->downcall.trailer_size, iter)) { | |
| 469 | 464 | gossip_err("%s: failed to copy trailer.\n", __func__); |
| 470 | 465 | vfree(op->downcall.trailer_buf); |
| 471 | 466 | goto Efault; |
| @@ -2809,12 +2809,12 @@ static inline int skb_add_data(struct sk_buff *skb, · 2808 unmodified lines | ||
| 2809 | 2809 | |
| 2810 | 2810 | if (skb->ip_summed == CHECKSUM_NONE) { |
| 2811 | 2811 | __wsum csum = 0; |
| 2812 | − if (csum_and_copy_from_iter(skb_put(skb, copy), copy, | |
| 2813 | − &csum, from) == copy) { | |
| 2812 | + if (csum_and_copy_from_iter_full(skb_put(skb, copy), copy, | |
| 2813 | + &csum, from)) { | |
| 2814 | 2814 | skb->csum = csum_block_add(skb->csum, csum, off); |
| 2815 | 2815 | return 0; |
| 2816 | 2816 | } |
| 2817 | − } else if (copy_from_iter(skb_put(skb, copy), copy, from) == copy) | |
| 2817 | + } else if (copy_from_iter_full(skb_put(skb, copy), copy, from)) | |
| 2818 | 2818 | return 0; |
| 2819 | 2819 | |
| 2820 | 2820 | __skb_trim(skb, off); |
| @@ -89,7 +89,9 @@ size_t copy_page_from_iter(struct page *page, size_t offset, size_t bytes, · 88 unmodified lines | ||
| 89 | 89 | struct iov_iter *i); |
| 90 | 90 | size_t copy_to_iter(const void *addr, size_t bytes, struct iov_iter *i); |
| 91 | 91 | size_t copy_from_iter(void *addr, size_t bytes, struct iov_iter *i); |
| 92 | +bool copy_from_iter_full(void *addr, size_t bytes, struct iov_iter *i); | |
| 92 | 93 | size_t copy_from_iter_nocache(void *addr, size_t bytes, struct iov_iter *i); |
| 94 | +bool copy_from_iter_full_nocache(void *addr, size_t bytes, struct iov_iter *i); | |
| 93 | 95 | size_t iov_iter_zero(size_t bytes, struct iov_iter *); |
| 94 | 96 | unsigned long iov_iter_alignment(const struct iov_iter *i); |
| 95 | 97 | unsigned long iov_iter_gap_alignment(const struct iov_iter *i); |
| @@ -155,6 +157,7 @@ static inline void iov_iter_reexpand(struct iov_iter *i, size_t count) · 59 unmodified lines | ||
| 155 | 157 | } |
| 156 | 158 | size_t csum_and_copy_to_iter(const void *addr, size_t bytes, __wsum *csum, struct iov_iter *i); |
| 157 | 159 | size_t csum_and_copy_from_iter(void *addr, size_t bytes, __wsum *csum, struct iov_iter *i); |
| 160 | +bool csum_and_copy_from_iter_full(void *addr, size_t bytes, __wsum *csum, struct iov_iter *i); | |
| 158 | 161 | |
| 159 | 162 | int import_iovec(int type, const struct iovec __user * uvector, |
| 160 | 163 | unsigned nr_segs, unsigned fast_segs, |
| @@ -1783,13 +1783,13 @@ static inline int skb_do_copy_data_nocache(struct sock *sk, struct sk_buff *skb, · 1782 unmodified lines | ||
| 1783 | 1783 | { |
| 1784 | 1784 | if (skb->ip_summed == CHECKSUM_NONE) { |
| 1785 | 1785 | __wsum csum = 0; |
| 1786 | − if (csum_and_copy_from_iter(to, copy, &csum, from) != copy) | |
| 1786 | + if (!csum_and_copy_from_iter_full(to, copy, &csum, from)) | |
| 1787 | 1787 | return -EFAULT; |
| 1788 | 1788 | skb->csum = csum_block_add(skb->csum, csum, offset); |
| 1789 | 1789 | } else if (sk->sk_route_caps & NETIF_F_NOCACHE_COPY) { |
| 1790 | − if (copy_from_iter_nocache(to, copy, from) != copy) | |
| 1790 | + if (!copy_from_iter_full_nocache(to, copy, from)) | |
| 1791 | 1791 | return -EFAULT; |
| 1792 | − } else if (copy_from_iter(to, copy, from) != copy) | |
| 1792 | + } else if (!copy_from_iter_full(to, copy, from)) | |
| 1793 | 1793 | return -EFAULT; |
| 1794 | 1794 | |
| 1795 | 1795 | return 0; |
| @@ -20,7 +20,7 @@ static __inline__ int udplite_getfrag(void *from, char *to, int offset, · 19 unmodified lines | ||
| 20 | 20 | int len, int odd, struct sk_buff *skb) |
| 21 | 21 | { |
| 22 | 22 | struct msghdr *msg = from; |
| 23 | − return copy_from_iter(to, len, &msg->msg_iter) != len ? -EFAULT : 0; | |
| 23 | + return copy_from_iter_full(to, len, &msg->msg_iter) ? 0 : -EFAULT; | |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | /* Designate sk as UDP-Lite socket */ |
| @@ -748,7 +748,7 @@ static ssize_t devkmsg_write(struct kiocb *iocb, struct iov_iter *from) · 747 unmodified lines | ||
| 748 | 748 | return -ENOMEM; |
| 749 | 749 | |
| 750 | 750 | buf[len] = '\0'; |
| 751 | − if (copy_from_iter(buf, len, from) != len) { | |
| 751 | + if (!copy_from_iter_full(buf, len, from)) { | |
| 752 | 752 | kfree(buf); |
| 753 | 753 | return -EFAULT; |
| 754 | 754 | } |
| @@ -568,6 +568,31 @@ size_t copy_from_iter(void *addr, size_t bytes, struct iov_iter *i) · 567 unmodified lines | ||
| 568 | 568 | } |
| 569 | 569 | EXPORT_SYMBOL(copy_from_iter); |
| 570 | 570 | |
| 571 | +bool copy_from_iter_full(void *addr, size_t bytes, struct iov_iter *i) | |
| 572 | +{ | |
| 573 | + char *to = addr; | |
| 574 | + if (unlikely(i->type & ITER_PIPE)) { | |
| 575 | + WARN_ON(1); | |
| 576 | + return false; | |
| 577 | + } | |
| 578 | + if (unlikely(i->count < bytes)) \ | |
| 579 | + return false; | |
| 580 | + | |
| 581 | + iterate_all_kinds(i, bytes, v, ({ | |
| 582 | + if (__copy_from_user((to += v.iov_len) - v.iov_len, | |
| 583 | + v.iov_base, v.iov_len)) | |
| 584 | + return false; | |
| 585 | + 0;}), | |
| 586 | + memcpy_from_page((to += v.bv_len) - v.bv_len, v.bv_page, | |
| 587 | + v.bv_offset, v.bv_len), | |
| 588 | + memcpy((to += v.iov_len) - v.iov_len, v.iov_base, v.iov_len) | |
| 589 | + ) | |
| 590 | + | |
| 591 | + iov_iter_advance(i, bytes); | |
| 592 | + return true; | |
| 593 | +} | |
| 594 | +EXPORT_SYMBOL(copy_from_iter_full); | |
| 595 | + | |
| 571 | 596 | size_t copy_from_iter_nocache(void *addr, size_t bytes, struct iov_iter *i) |
| 572 | 597 | { |
| 573 | 598 | char *to = addr; |
| @@ -587,6 +612,30 @@ size_t copy_from_iter_nocache(void *addr, size_t bytes, struct iov_iter *i) · 13 unmodified lines | ||
| 587 | 612 | } |
| 588 | 613 | EXPORT_SYMBOL(copy_from_iter_nocache); |
| 589 | 614 | |
| 615 | +bool copy_from_iter_full_nocache(void *addr, size_t bytes, struct iov_iter *i) | |
| 616 | +{ | |
| 617 | + char *to = addr; | |
| 618 | + if (unlikely(i->type & ITER_PIPE)) { | |
| 619 | + WARN_ON(1); | |
| 620 | + return false; | |
| 621 | + } | |
| 622 | + if (unlikely(i->count < bytes)) \ | |
| 623 | + return false; | |
| 624 | + iterate_all_kinds(i, bytes, v, ({ | |
| 625 | + if (__copy_from_user_nocache((to += v.iov_len) - v.iov_len, | |
| 626 | + v.iov_base, v.iov_len)) | |
| 627 | + return false; | |
| 628 | + 0;}), | |
| 629 | + memcpy_from_page((to += v.bv_len) - v.bv_len, v.bv_page, | |
| 630 | + v.bv_offset, v.bv_len), | |
| 631 | + memcpy((to += v.iov_len) - v.iov_len, v.iov_base, v.iov_len) | |
| 632 | + ) | |
| 633 | + | |
| 634 | + iov_iter_advance(i, bytes); | |
| 635 | + return true; | |
| 636 | +} | |
| 637 | +EXPORT_SYMBOL(copy_from_iter_full_nocache); | |
| 638 | + | |
| 590 | 639 | size_t copy_page_to_iter(struct page *page, size_t offset, size_t bytes, |
| 591 | 640 | struct iov_iter *i) |
| 592 | 641 | { |
| @@ -1008,7 +1057,7 @@ size_t csum_and_copy_from_iter(void *addr, size_t bytes, __wsum *csum, · 415 unmodified lines | ||
| 1008 | 1057 | } |
| 1009 | 1058 | iterate_and_advance(i, bytes, v, ({ |
| 1010 | 1059 | int err = 0; |
| 1011 | − next = csum_and_copy_from_user(v.iov_base, | |
| 1060 | + next = csum_and_copy_from_user(v.iov_base, | |
| 1012 | 1061 | (to += v.iov_len) - v.iov_len, |
| 1013 | 1062 | v.iov_len, 0, &err); |
| 1014 | 1063 | if (!err) { |
| @@ -1037,6 +1086,51 @@ size_t csum_and_copy_from_iter(void *addr, size_t bytes, __wsum *csum, · 22 unmodified lines | ||
| 1037 | 1086 | } |
| 1038 | 1087 | EXPORT_SYMBOL(csum_and_copy_from_iter); |
| 1039 | 1088 | |
| 1089 | +bool csum_and_copy_from_iter_full(void *addr, size_t bytes, __wsum *csum, | |
| 1090 | + struct iov_iter *i) | |
| 1091 | +{ | |
| 1092 | + char *to = addr; | |
| 1093 | + __wsum sum, next; | |
| 1094 | + size_t off = 0; | |
| 1095 | + sum = *csum; | |
| 1096 | + if (unlikely(i->type & ITER_PIPE)) { | |
| 1097 | + WARN_ON(1); | |
| 1098 | + return false; | |
| 1099 | + } | |
| 1100 | + if (unlikely(i->count < bytes)) | |
| 1101 | + return false; | |
| 1102 | + iterate_all_kinds(i, bytes, v, ({ | |
| 1103 | + int err = 0; | |
| 1104 | + next = csum_and_copy_from_user(v.iov_base, | |
| 1105 | + (to += v.iov_len) - v.iov_len, | |
| 1106 | + v.iov_len, 0, &err); | |
| 1107 | + if (err) | |
| 1108 | + return false; | |
| 1109 | + sum = csum_block_add(sum, next, off); | |
| 1110 | + off += v.iov_len; | |
| 1111 | + 0; | |
| 1112 | + }), ({ | |
| 1113 | + char *p = kmap_atomic(v.bv_page); | |
| 1114 | + next = csum_partial_copy_nocheck(p + v.bv_offset, | |
| 1115 | + (to += v.bv_len) - v.bv_len, | |
| 1116 | + v.bv_len, 0); | |
| 1117 | + kunmap_atomic(p); | |
| 1118 | + sum = csum_block_add(sum, next, off); | |
| 1119 | + off += v.bv_len; | |
| 1120 | + }),({ | |
| 1121 | + next = csum_partial_copy_nocheck(v.iov_base, | |
| 1122 | + (to += v.iov_len) - v.iov_len, | |
| 1123 | + v.iov_len, 0); | |
| 1124 | + sum = csum_block_add(sum, next, off); | |
| 1125 | + off += v.iov_len; | |
| 1126 | + }) | |
| 1127 | + ) | |
| 1128 | + *csum = sum; | |
| 1129 | + iov_iter_advance(i, bytes); | |
| 1130 | + return true; | |
| 1131 | +} | |
| 1132 | +EXPORT_SYMBOL(csum_and_copy_from_iter_full); | |
| 1133 | + | |
| 1040 | 1134 | size_t csum_and_copy_to_iter(const void *addr, size_t bytes, __wsum *csum, |
| 1041 | 1135 | struct iov_iter *i) |
| 1042 | 1136 | { |
| @@ -1051,7 +1145,7 @@ size_t csum_and_copy_to_iter(const void *addr, size_t bytes, __wsum *csum, · 8 unmodified lines | ||
| 1051 | 1145 | iterate_and_advance(i, bytes, v, ({ |
| 1052 | 1146 | int err = 0; |
| 1053 | 1147 | next = csum_and_copy_to_user((from += v.iov_len) - v.iov_len, |
| 1054 | − v.iov_base, | |
| 1148 | + v.iov_base, | |
| 1055 | 1149 | v.iov_len, 0, &err); |
| 1056 | 1150 | if (!err) { |
| 1057 | 1151 | sum = csum_block_add(sum, next, off); |
| @@ -630,7 +630,7 @@ int vcc_sendmsg(struct socket *sock, struct msghdr *m, size_t size) · 629 unmodified lines | ||
| 630 | 630 | goto out; |
| 631 | 631 | skb->dev = NULL; /* for paths shared with net_device interfaces */ |
| 632 | 632 | ATM_SKB(skb)->atm_options = vcc->atm_options; |
| 633 | − if (copy_from_iter(skb_put(skb, size), size, &m->msg_iter) != size) { | |
| 633 | + if (!copy_from_iter_full(skb_put(skb, size), size, &m->msg_iter)) { | |
| 634 | 634 | kfree_skb(skb); |
| 635 | 635 | error = -EFAULT; |
| 636 | 636 | goto out; |
| @@ -2127,7 +2127,7 @@ static inline int l2cap_skbuff_fromiovec(struct l2cap_chan *chan, · 2126 unmodified lines | ||
| 2127 | 2127 | struct sk_buff **frag; |
| 2128 | 2128 | int sent = 0; |
| 2129 | 2129 | |
| 2130 | − if (copy_from_iter(skb_put(skb, count), count, &msg->msg_iter) != count) | |
| 2130 | + if (!copy_from_iter_full(skb_put(skb, count), count, &msg->msg_iter)) | |
| 2131 | 2131 | return -EFAULT; |
| 2132 | 2132 | |
| 2133 | 2133 | sent += count; |
| @@ -2147,8 +2147,8 @@ static inline int l2cap_skbuff_fromiovec(struct l2cap_chan *chan, · 13 unmodified lines | ||
| 2147 | 2147 | |
| 2148 | 2148 | *frag = tmp; |
| 2149 | 2149 | |
| 2150 | − if (copy_from_iter(skb_put(*frag, count), count, | |
| 2151 | − &msg->msg_iter) != count) | |
| 2150 | + if (!copy_from_iter_full(skb_put(*frag, count), count, | |
| 2151 | + &msg->msg_iter)) | |
| 2152 | 2152 | return -EFAULT; |
| 2153 | 2153 | |
| 2154 | 2154 | sent += count; |
| @@ -802,11 +802,11 @@ ip_generic_getfrag(void *from, char *to, int offset, int len, int odd, struct sk · 801 unmodified lines | ||
| 802 | 802 | struct msghdr *msg = from; |
| 803 | 803 | |
| 804 | 804 | if (skb->ip_summed == CHECKSUM_PARTIAL) { |
| 805 | − if (copy_from_iter(to, len, &msg->msg_iter) != len) | |
| 805 | + if (!copy_from_iter_full(to, len, &msg->msg_iter)) | |
| 806 | 806 | return -EFAULT; |
| 807 | 807 | } else { |
| 808 | 808 | __wsum csum = 0; |
| 809 | − if (csum_and_copy_from_iter(to, len, &csum, &msg->msg_iter) != len) | |
| 809 | + if (!csum_and_copy_from_iter_full(to, len, &csum, &msg->msg_iter)) | |
| 810 | 810 | return -EFAULT; |
| 811 | 811 | skb->csum = csum_block_add(skb->csum, csum, odd); |
| 812 | 812 | } |
| @@ -609,15 +609,15 @@ int ping_getfrag(void *from, char *to, · 608 unmodified lines | ||
| 609 | 609 | fraglen -= sizeof(struct icmphdr); |
| 610 | 610 | if (fraglen < 0) |
| 611 | 611 | BUG(); |
| 612 | − if (csum_and_copy_from_iter(to + sizeof(struct icmphdr), | |
| 612 | + if (!csum_and_copy_from_iter_full(to + sizeof(struct icmphdr), | |
| 613 | 613 | fraglen, &pfh->wcheck, |
| 614 | − &pfh->msg->msg_iter) != fraglen) | |
| 614 | + &pfh->msg->msg_iter)) | |
| 615 | 615 | return -EFAULT; |
| 616 | 616 | } else if (offset < sizeof(struct icmphdr)) { |
| 617 | 617 | BUG(); |
| 618 | 618 | } else { |
| 619 | − if (csum_and_copy_from_iter(to, fraglen, &pfh->wcheck, | |
| 620 | − &pfh->msg->msg_iter) != fraglen) | |
| 619 | + if (!csum_and_copy_from_iter_full(to, fraglen, &pfh->wcheck, | |
| 620 | + &pfh->msg->msg_iter)) | |
| 621 | 621 | return -EFAULT; |
| 622 | 622 | } |
| 623 | 623 | |
| @@ -2432,14 +2432,11 @@ static int __packet_snd_vnet_parse(struct virtio_net_hdr *vnet_hdr, size_t len) · 2431 unmodified lines | ||
| 2432 | 2432 | static int packet_snd_vnet_parse(struct msghdr *msg, size_t *len, |
| 2433 | 2433 | struct virtio_net_hdr *vnet_hdr) |
| 2434 | 2434 | { |
| 2435 | − int n; | |
| 2436 | − | |
| 2437 | 2435 | if (*len < sizeof(*vnet_hdr)) |
| 2438 | 2436 | return -EINVAL; |
| 2439 | 2437 | *len -= sizeof(*vnet_hdr); |
| 2440 | 2438 | |
| 2441 | − n = copy_from_iter(vnet_hdr, sizeof(*vnet_hdr), &msg->msg_iter); | |
| 2442 | − if (n != sizeof(*vnet_hdr)) | |
| 2439 | + if (!copy_from_iter_full(vnet_hdr, sizeof(*vnet_hdr), &msg->msg_iter)) | |
| 2443 | 2440 | return -EFAULT; |
| 2444 | 2441 | |
| 2445 | 2442 | return __packet_snd_vnet_parse(vnet_hdr, *len); |
| @@ -268,7 +268,7 @@ int tipc_msg_build(struct tipc_msg *mhdr, struct msghdr *m, · 267 unmodified lines | ||
| 268 | 268 | __skb_queue_tail(list, skb); |
| 269 | 269 | skb_copy_to_linear_data(skb, mhdr, mhsz); |
| 270 | 270 | pktpos = skb->data + mhsz; |
| 271 | − if (copy_from_iter(pktpos, dsz, &m->msg_iter) == dsz) | |
| 271 | + if (copy_from_iter_full(pktpos, dsz, &m->msg_iter)) | |
| 272 | 272 | return dsz; |
| 273 | 273 | rc = -EFAULT; |
| 274 | 274 | goto error; |
| @@ -299,7 +299,7 @@ int tipc_msg_build(struct tipc_msg *mhdr, struct msghdr *m, · 24 unmodified lines | ||
| 299 | 299 | if (drem < pktrem) |
| 300 | 300 | pktrem = drem; |
| 301 | 301 | |
| 302 | − if (copy_from_iter(pktpos, pktrem, &m->msg_iter) != pktrem) { | |
| 302 | + if (!copy_from_iter_full(pktpos, pktrem, &m->msg_iter)) { | |
| 303 | 303 | rc = -EFAULT; |
| 304 | 304 | goto error; |
| 305 | 305 | } |
| @@ -1074,7 +1074,7 @@ long keyctl_instantiate_key_common(key_serial_t id, · 1073 unmodified lines | ||
| 1074 | 1074 | } |
| 1075 | 1075 | |
| 1076 | 1076 | ret = -EFAULT; |
| 1077 | − if (copy_from_iter(payload, plen, from) != plen) | |
| 1077 | + if (!copy_from_iter_full(payload, plen, from)) | |
| 1078 | 1078 | goto error2; |
| 1079 | 1079 | } |
| 1080 | 1080 | |