Commit 34204fde authored by Al Viro's avatar Al Viro Committed by Mike Marshall

pvfs_bufmap_copy_from_iovec(): don't rely upon size being equal to iov_iter_count(iter)

Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
Signed-off-by: default avatarMike Marshall <hubcap@omnibond.com>
parent 5c278228
...@@ -512,26 +512,25 @@ int pvfs_bufmap_copy_from_iovec(struct pvfs2_bufmap *bufmap, ...@@ -512,26 +512,25 @@ int pvfs_bufmap_copy_from_iovec(struct pvfs2_bufmap *bufmap,
int buffer_index, int buffer_index,
size_t size) size_t size)
{ {
struct pvfs_bufmap_desc *to; struct pvfs_bufmap_desc *to = &bufmap->desc_array[buffer_index];
struct page *page;
size_t copied;
int i; int i;
gossip_debug(GOSSIP_BUFMAP_DEBUG, gossip_debug(GOSSIP_BUFMAP_DEBUG,
"%s: buffer_index:%d: size:%lu:\n", "%s: buffer_index:%d: size:%zu:\n",
__func__, buffer_index, size); __func__, buffer_index, size);
to = &bufmap->desc_array[buffer_index];
for (i = 0; size; i++) { for (i = 0; size; i++) {
page = to->page_array[i]; struct page *page = to->page_array[i];
copied = copy_page_from_iter(page, 0, PAGE_SIZE, iter); size_t n = size;
size -= copied; if (n > PAGE_SIZE)
if ((copied == 0) && (size)) n = PAGE_SIZE;
break; n = copy_page_from_iter(page, 0, n, iter);
if (!n)
return -EFAULT;
size -= n;
} }
return 0;
return size ? -EFAULT : 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment