[CRIU] [PATCH 7/9] page-pipe: Introduce object to collect pages within

Cyrill Gorcunov gorcunov at openvz.org
Fri Mar 1 15:20:30 EST 2013


On Fri, Mar 01, 2013 at 08:03:53PM +0400, Pavel Emelyanov wrote:
> +static int page_pipe_grow(struct page_pipe *pp)
> +{
> +	struct page_pipe_buf *ppb;
> +
> +	pr_debug("Will grow page pipe (iov off is %u)\n", pp->free_iov);
> +
> +	ppb = xmalloc(sizeof(*ppb));
> +	if (!ppb)
> +		return -1;
> +
> +	if (pipe(ppb->p)) {

		xfree(ppb);

> +		pr_perror("Can't make pipe for page-pipe");
> +		return -1;
> +	}
> +
> +	ppb->pipe_size = fcntl(ppb->p[0], F_GETPIPE_SZ, 0) / PAGE_SIZE;
> +	ppb->pages_in = 0;
> +	ppb->nr_segs = 0;
> +	ppb->iov = &pp->iovs[pp->free_iov];
> +
> +	list_add_tail(&ppb->l, &pp->bufs);
> +	pp->nr_pipes++;
> +
> +	return 0;
> +}
> +
> +struct page_pipe *create_page_pipe(unsigned int nr_segs, struct iovec *iovs)
> +{
> +	struct page_pipe *pp;
> +
> +	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);
> +		pp->nr_iovs = nr_segs;
> +		pp->iovs = iovs;
> +		pp->free_iov = 0;
> +
> +		if (page_pipe_grow(pp))

			xfree(pp);

> +			return NULL;
> +	}
> +
> +	return pp;
> +}
> +


More information about the CRIU mailing list