Commit e3c6784b authored by Andrei Vagin's avatar Andrei Vagin

parasite: remove restriction to a number of iovec-s

vmsplice can't splice more than UIO_MAXIOV, but we can
call it a few times from a parasite.

v2: s/nr/nr_segs/
Acked-by: 's avatarMike Rapoport <rppt@linux.vnet.ibm.com>
Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
parent c949e759
......@@ -207,15 +207,9 @@ static inline int try_add_page_to(struct page_pipe *pp, struct page_pipe_buf *pp
return 1; /* need to add another buf */
}
if (ppb->nr_segs) {
if (iov_grow_page(&ppb->iov[ppb->nr_segs - 1], addr))
if (ppb->nr_segs && iov_grow_page(&ppb->iov[ppb->nr_segs - 1], addr))
goto out;
if (ppb->nr_segs == UIO_MAXIOV)
/* XXX -- shrink pipe back? */
return 1;
}
pr_debug("Add iov to page pipe (%u iovs, %u/%u total)\n",
ppb->nr_segs, pp->free_iov, pp->nr_iovs);
iov_init(&ppb->iov[ppb->nr_segs++], addr);
......
......@@ -6,6 +6,7 @@
#include <sys/mount.h>
#include <stdarg.h>
#include <sys/ioctl.h>
#include <sys/uio.h>
#include "common/config.h"
#include "int.h"
......@@ -66,6 +67,7 @@ static int dump_pages(struct parasite_dump_pages_args *args)
{
int p, ret, tsock;
struct iovec *iovs;
int off, nr_segs, nr_pages;
tsock = parasite_get_rpc_sock();
p = recv_fd(tsock);
......@@ -73,11 +75,30 @@ static int dump_pages(struct parasite_dump_pages_args *args)
return -1;
iovs = pargs_iovs(args);
ret = sys_vmsplice(p, &iovs[args->off], args->nr_segs,
nr_pages = 0;
off = 0;
nr_segs = args->nr_segs;
if (nr_segs > UIO_MAXIOV)
nr_segs = UIO_MAXIOV;
while (1) {
ret = sys_vmsplice(p, &iovs[args->off + off], nr_segs,
SPLICE_F_GIFT | SPLICE_F_NONBLOCK);
if (ret != PAGE_SIZE * args->nr_pages) {
if (ret < 0) {
sys_close(p);
pr_err("Can't splice pages to pipe (%d/%d/%d)\n",
ret, nr_segs, args->off + off);
return -1;
}
nr_pages += ret;
off += nr_segs;
if (off == args->nr_segs)
break;
if (off + nr_segs > args->nr_segs)
nr_segs = args->nr_segs - off;
}
if (nr_pages != args->nr_pages * PAGE_SIZE) {
sys_close(p);
pr_err("Can't splice pages to pipe (%d/%d)\n", ret, args->nr_pages);
pr_err("Can't splice all pages to pipe (%d/%d)\n", nr_pages, args->nr_pages);
return -1;
}
......
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