[CRIU] [PATCH 2/5] page-server: Unify async/sync calls
Mike Rapoport
mike.rapoport at gmail.com
Wed Jun 14 14:53:29 MSK 2017
On Wed, Jun 14, 2017 at 01:14:46PM +0300, Pavel Emelyanov wrote:
> The newly introduced sync-read call may look exactly
> the same as its async pair by using the respective
> complete callback.
>
> Signed-off-by: Pavel Emelyanov <xemul at virtuozzo.com>
Acked-by: Mike Rapoport <rppt at linux.vnet.ibm.com>
> ---
> criu/include/page-xfer.h | 3 ++-
> criu/page-xfer.c | 9 +++++++--
> criu/pagemap.c | 8 ++------
> 3 files changed, 11 insertions(+), 9 deletions(-)
>
> diff --git a/criu/include/page-xfer.h b/criu/include/page-xfer.h
> index 5d8dc81..4ccefee 100644
> --- a/criu/include/page-xfer.h
> +++ b/criu/include/page-xfer.h
> @@ -64,6 +64,7 @@ extern int request_remote_pages(int pid, unsigned long addr, int nr_pages);
> typedef int (*ps_async_read_complete)(int pid, unsigned long vaddr, int nr_pages, void *);
> extern int page_server_start_async_read(void *buf, int nr_pages,
> ps_async_read_complete complete, void *priv);
> -extern int page_server_start_sync_read(void *buf, int nr_pages, unsigned long *vaddr);
> +extern int page_server_start_sync_read(void *buf, int nr_pages,
> + ps_async_read_complete complete, void *priv);
>
> #endif /* __CR_PAGE_XFER__H__ */
> diff --git a/criu/page-xfer.c b/criu/page-xfer.c
> index 761985a..067b7d3 100644
> --- a/criu/page-xfer.c
> +++ b/criu/page-xfer.c
> @@ -1204,20 +1204,25 @@ static int receive_remote_pages(int len, void *buf)
> return 0;
> }
>
> -int page_server_start_sync_read(void *buf, int nr, unsigned long *vaddr)
> +int page_server_start_sync_read(void *buf, int nr,
> + ps_async_read_complete complete, void *priv)
> {
> int ret, pid, new_nr;
> + unsigned long vaddr;
>
> /*
> * Note, that for async remote page_read, the actual
> * transfer happens in the lazy-pages daemon
> */
> - ret = receive_remote_pages_info(&new_nr, vaddr, &pid);
> + ret = receive_remote_pages_info(&new_nr, &vaddr, &pid);
> if (ret == 0) {
> if (new_nr < 0 || new_nr > nr)
> return -1;
> ret = receive_remote_pages(nr * PAGE_SIZE, buf);
> }
>
> + if (ret == 0)
> + ret = complete(pid, vaddr, nr, priv);
> +
> return ret;
> }
> diff --git a/criu/pagemap.c b/criu/pagemap.c
> index 06264a1..8a2cce9 100644
> --- a/criu/pagemap.c
> +++ b/criu/pagemap.c
> @@ -474,12 +474,8 @@ static int maybe_read_page_remote(struct page_read *pr, unsigned long vaddr,
> return ret;
> if (flags & PR_ASYNC)
> return page_server_start_async_read(buf, nr, read_page_complete, pr);
> -
> - ret = page_server_start_sync_read(buf, nr, &vaddr);
> - if (ret == 0 && pr->io_complete)
> - ret = pr->io_complete(pr, vaddr, nr);
> -
> - return ret;
> + else
> + return page_server_start_sync_read(buf, nr, read_page_complete, pr);
> }
>
> static int read_pagemap_page(struct page_read *pr, unsigned long vaddr, int nr,
> --
> 2.1.4
>
> _______________________________________________
> CRIU mailing list
> CRIU at openvz.org
> https://lists.openvz.org/mailman/listinfo/criu
More information about the CRIU
mailing list