kill iov_iter_copy_from_user()
authorAl Viro <viro@zeniv.linux.org.uk>
Fri, 11 Apr 2014 00:54:51 +0000 (20:54 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Tue, 6 May 2014 21:32:42 +0000 (17:32 -0400)
all callers can use copy_page_from_iter() and it actually simplifies
them.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/ceph/file.c
fs/cifs/file.c
include/linux/uio.h
mm/iov_iter.c
mm/process_vm_access.c

index 88a6df4cbe6d8a52bd083a756ac452b798c33708..ef9115e4a6fad2d389a941ef82f097d86637ab61 100644 (file)
@@ -737,13 +737,12 @@ static ssize_t ceph_sync_write(struct kiocb *iocb, const struct iovec *iov,
                left = len;
                for (n = 0; n < num_pages; n++) {
                        size_t plen = min_t(size_t, left, PAGE_SIZE);
-                       ret = iov_iter_copy_from_user(pages[n], &i, 0, plen);
+                       ret = copy_page_from_iter(pages[n], 0, plen, &i);
                        if (ret != plen) {
                                ret = -EFAULT;
                                break;
                        }
                        left -= ret;
-                       iov_iter_advance(&i, ret);
                }
 
                if (ret < 0) {
index 5ed03e0b8b40e28b10aa46630d973b47e229c194..2900d150654e352c5ca2220ca0ba5035cdb4eb0e 100644 (file)
@@ -2444,11 +2444,10 @@ cifs_iovec_write(struct file *file, const struct iovec *iov,
 
                save_len = cur_len;
                for (i = 0; i < nr_pages; i++) {
-                       bytes = min_t(const size_t, cur_len, PAGE_SIZE);
-                       copied = iov_iter_copy_from_user(wdata->pages[i], &it,
-                                                        0, bytes);
+                       bytes = min_t(size_t, cur_len, PAGE_SIZE);
+                       copied = copy_page_from_iter(wdata->pages[i], 0, bytes,
+                                                    &it);
                        cur_len -= copied;
-                       iov_iter_advance(&it, copied);
                        /*
                         * If we didn't copy as much as we expected, then that
                         * may mean we trod into an unmapped area. Stop copying
index 199bcc34241ba0155a367f11d05edf5d9c138a02..abbe83ded63054a57a6a982869420bbe7f34f2b6 100644 (file)
@@ -62,8 +62,6 @@ unsigned long iov_shorten(struct iovec *iov, unsigned long nr_segs, size_t to);
 
 size_t iov_iter_copy_from_user_atomic(struct page *page,
                struct iov_iter *i, unsigned long offset, size_t bytes);
-size_t iov_iter_copy_from_user(struct page *page,
-               struct iov_iter *i, unsigned long offset, size_t bytes);
 void iov_iter_advance(struct iov_iter *i, size_t bytes);
 int iov_iter_fault_in_readable(struct iov_iter *i, size_t bytes);
 size_t iov_iter_single_seg_count(const struct iov_iter *i);
index 10e46cd721de5876d0016aab5969d0b2c6ebdeb3..22ec1ef068a83141e5ab4c3719eb67913cbc617a 100644 (file)
@@ -129,33 +129,6 @@ size_t iov_iter_copy_from_user_atomic(struct page *page,
 }
 EXPORT_SYMBOL(iov_iter_copy_from_user_atomic);
 
-/*
- * This has the same sideeffects and return value as
- * iov_iter_copy_from_user_atomic().
- * The difference is that it attempts to resolve faults.
- * Page must not be locked.
- */
-size_t iov_iter_copy_from_user(struct page *page,
-               struct iov_iter *i, unsigned long offset, size_t bytes)
-{
-       char *kaddr;
-       size_t copied;
-
-       kaddr = kmap(page);
-       if (likely(i->nr_segs == 1)) {
-               int left;
-               char __user *buf = i->iov->iov_base + i->iov_offset;
-               left = __copy_from_user(kaddr + offset, buf, bytes);
-               copied = bytes - left;
-       } else {
-               copied = __iovec_copy_from_user_inatomic(kaddr + offset,
-                                               i->iov, i->iov_offset, bytes);
-       }
-       kunmap(page);
-       return copied;
-}
-EXPORT_SYMBOL(iov_iter_copy_from_user);
-
 void iov_iter_advance(struct iov_iter *i, size_t bytes)
 {
        BUG_ON(i->count < bytes);
index 8505c9262b35853e22580c6c9b74c4d12bc86acc..f32b1fbbfe6925b772db236821eb45f721bf7881 100644 (file)
@@ -46,11 +46,7 @@ static int process_vm_rw_pages(struct page **pages,
                        copy = len;
 
                if (vm_write) {
-                       if (copy > iov_iter_count(iter))
-                               copy = iov_iter_count(iter);
-                       copied = iov_iter_copy_from_user(page, iter,
-                                       offset, copy);
-                       iov_iter_advance(iter, copied);
+                       copied = copy_page_from_iter(page, offset, copy, iter);
                        set_page_dirty_lock(page);
                } else {
                        copied = copy_page_to_iter(page, offset, copy, iter);