orangefs: explicitly pass the size to pvfs_bufmap_copy_to_iovec()
authorAl Viro <viro@zeniv.linux.org.uk>
Thu, 8 Oct 2015 21:43:58 +0000 (17:43 -0400)
committerMike Marshall <hubcap@omnibond.com>
Fri, 13 Nov 2015 15:25:01 +0000 (10:25 -0500)
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Mike Marshall <hubcap@omnibond.com>
fs/orangefs/file.c
fs/orangefs/pvfs2-bufmap.c
fs/orangefs/pvfs2-bufmap.h

index feb1764c2f8062148462d7704a0ae0dc7cc9f29a..92a0974f074311f40283aff082fe2ae39a32931a 100644 (file)
@@ -89,7 +89,8 @@ static int postcopy_buffers(struct pvfs2_bufmap *bufmap,
                iov_iter_init(&iter, READ, vec, nr_segs, total_size);
                ret = pvfs_bufmap_copy_to_iovec(bufmap,
                                                &iter,
-                                               buffer_index);
+                                               buffer_index,
+                                               total_size);
                if (ret < 0)
                        gossip_err("%s: Failed to copy-out buffers. Please make sure that the pvfs2-client is running (%ld)\n",
                                __func__,
index 9d0392a3e8245a6da7a6cc8b93e4c24184edc99e..8438830352145084a60e4269cbdf5457f14ba132 100644 (file)
@@ -542,25 +542,26 @@ int pvfs_bufmap_copy_from_iovec(struct pvfs2_bufmap *bufmap,
  */
 int pvfs_bufmap_copy_to_iovec(struct pvfs2_bufmap *bufmap,
                                    struct iov_iter *iter,
-                                   int buffer_index)
+                                   int buffer_index,
+                                   size_t size)
 {
-       struct pvfs_bufmap_desc *from;
-       struct page *page;
+       struct pvfs_bufmap_desc *from = &bufmap->desc_array[buffer_index];
        int i;
-       size_t written;
 
        gossip_debug(GOSSIP_BUFMAP_DEBUG,
-                    "%s: buffer_index:%d: iov_iter_count(iter):%lu:\n",
-                    __func__, buffer_index, iov_iter_count(iter));
+                    "%s: buffer_index:%d: size:%zu:\n",
+                    __func__, buffer_index, size);
 
-       from = &bufmap->desc_array[buffer_index];
 
-       for (i = 0; iov_iter_count(iter); i++) {
-               page = from->page_array[i];
-               written = copy_page_to_iter(page, 0, PAGE_SIZE, iter);
-               if ((written == 0) && (iov_iter_count(iter)))
-                       break;
+       for (i = 0; size; i++) {
+               struct page *page = from->page_array[i];
+               size_t n = size;
+               if (n > PAGE_SIZE)
+                       n = PAGE_SIZE;
+               n = copy_page_to_iter(page, 0, n, iter);
+               if (!n)
+                       return -EFAULT;
+               size -= n;
        }
-
-       return iov_iter_count(iter) ? -EFAULT : 0;
+       return 0;
 }
index a0f84c045d735fdbb845fb9aa17bb2114b8285c5..d1aedb52a877edc93bffc2b88fe036af81167882 100644 (file)
@@ -49,7 +49,8 @@ int pvfs_bufmap_copy_from_iovec(struct pvfs2_bufmap *bufmap,
 
 int pvfs_bufmap_copy_to_iovec(struct pvfs2_bufmap *bufmap,
                              struct iov_iter *iter,
-                             int buffer_index);
+                             int buffer_index,
+                             size_t size);
 
 size_t pvfs_bufmap_copy_to_user_task_iovec(struct task_struct *tsk,
                                           struct iovec *iovec,