Commit 1b7537f7 authored by Mike Rapoport's avatar Mike Rapoport Committed by Pavel Emelyanov

criu: page-pipe: add ability to allocate IOVs

When collection of dumpee pages is followed by any parasite operation, we
cannot share iovs between parasite args area and page-pipe.
As a bonus we get some simplification of dump_one_shmem.
Signed-off-by: 's avatarMike Rapoport <rppt@linux.vnet.ibm.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
parent 7592d28d
......@@ -93,6 +93,7 @@ struct page_pipe {
bool chunk_mode; /* Restrict the maximum buffer size of pipes
and dump memory for a few iterations */
bool own_iovs; /* create_page_pipe allocated IOVs memory */
};
extern struct page_pipe *create_page_pipe(unsigned int nr,
......
......@@ -111,26 +111,41 @@ struct page_pipe *create_page_pipe(unsigned int nr_segs,
pr_debug("Create page pipe for %u segs\n", nr_segs);
pp = xmalloc(sizeof(*pp));
if (pp) {
pp->nr_pipes = 0;
INIT_LIST_HEAD(&pp->bufs);
INIT_LIST_HEAD(&pp->free_bufs);
pp->nr_iovs = nr_segs;
pp->iovs = iovs;
pp->free_iov = 0;
pp->nr_holes = 0;
pp->free_hole = 0;
pp->holes = NULL;
pp->chunk_mode = chunk_mode;
if (page_pipe_grow(pp))
return NULL;
pp = xzalloc(sizeof(*pp));
if (!pp)
return NULL;
if (!iovs) {
iovs = xmalloc(sizeof(*iovs) * nr_segs);
if (!iovs)
goto err_free_pp;
pp->own_iovs = true;
}
pp->nr_pipes = 0;
INIT_LIST_HEAD(&pp->bufs);
INIT_LIST_HEAD(&pp->free_bufs);
pp->nr_iovs = nr_segs;
pp->iovs = iovs;
pp->free_iov = 0;
pp->nr_holes = 0;
pp->free_hole = 0;
pp->holes = NULL;
pp->chunk_mode = chunk_mode;
if (page_pipe_grow(pp))
goto err_free_iovs;
return pp;
err_free_iovs:
if (pp->own_iovs)
xfree(iovs);
err_free_pp:
xfree(pp);
return NULL;
}
void destroy_page_pipe(struct page_pipe *pp)
......@@ -143,6 +158,8 @@ void destroy_page_pipe(struct page_pipe *pp)
list_for_each_entry_safe(ppb, n, &pp->bufs, l)
ppb_destroy(ppb);
if (pp->own_iovs)
xfree(pp->iovs);
xfree(pp);
}
......
......@@ -527,7 +527,6 @@ static int dump_pages(struct page_pipe *pp, struct page_xfer *xfer, void *addr)
static int dump_one_shmem(struct shmem_info *si)
{
struct iovec *iovs;
struct page_pipe *pp;
struct page_xfer xfer;
int err, ret = -1, fd;
......@@ -565,13 +564,9 @@ static int dump_one_shmem(struct shmem_info *si)
if (err)
goto err_unmap;
iovs = xmalloc(((nrpages + 1) / 2) * sizeof(struct iovec));
if (!iovs)
goto err_unmap;
pp = create_page_pipe((nrpages + 1) / 2, iovs, true);
pp = create_page_pipe((nrpages + 1) / 2, NULL, true);
if (!pp)
goto err_iovs;
goto err_unmap;
err = open_page_xfer(&xfer, CR_FD_SHMEM_PAGEMAP, si->shmid);
if (err)
......@@ -598,8 +593,6 @@ err_xfer:
xfer.close(&xfer);
err_pp:
destroy_page_pipe(pp);
err_iovs:
xfree(iovs);
err_unmap:
munmap(addr, si->size);
err:
......
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