2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-29 05:18:00 +00:00

page-server: Merge async and sync read API calls

Now these two look exactly the same and we can have
only one call with additional sync/async (flags) arg.

Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Acked-by: Mike Rapoport <rppt@linux.vnet.ibm.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
This commit is contained in:
Pavel Emelyanov 2017-06-14 13:15:06 +03:00 committed by Andrei Vagin
parent 832f3844f6
commit 2cc7e90d5b
3 changed files with 17 additions and 12 deletions

View File

@ -57,9 +57,7 @@ extern int check_parent_page_xfer(int fd_type, long id);
extern int request_remote_pages(int pid, unsigned long addr, int nr_pages); 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 *); 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, extern int page_server_start_read(void *buf, int nr_pages,
ps_async_read_complete complete, void *priv); ps_async_read_complete complete, void *priv, unsigned flags);
extern int page_server_start_sync_read(void *buf, int nr_pages,
ps_async_read_complete complete, void *priv);
#endif /* __CR_PAGE_XFER__H__ */ #endif /* __CR_PAGE_XFER__H__ */

View File

@ -1069,7 +1069,7 @@ struct ps_async_read {
static LIST_HEAD(async_reads); static LIST_HEAD(async_reads);
int page_server_start_async_read(void *buf, int nr_pages, static int page_server_start_async_read(void *buf, int nr_pages,
ps_async_read_complete complete, void *priv) ps_async_read_complete complete, void *priv)
{ {
struct ps_async_read *ar; struct ps_async_read *ar;
@ -1201,7 +1201,7 @@ static int receive_remote_pages(int len, void *buf)
return 0; return 0;
} }
int page_server_start_sync_read(void *buf, int nr, static int page_server_start_sync_read(void *buf, int nr,
ps_async_read_complete complete, void *priv) ps_async_read_complete complete, void *priv)
{ {
int ret, pid, new_nr; int ret, pid, new_nr;
@ -1223,3 +1223,12 @@ int page_server_start_sync_read(void *buf, int nr,
return ret; return ret;
} }
int page_server_start_read(void *buf, int nr,
ps_async_read_complete complete, void *priv, unsigned flags)
{
if (flags & PR_ASYNC)
return page_server_start_async_read(buf, nr, complete, priv);
else
return page_server_start_sync_read(buf, nr, complete, priv);
}

View File

@ -438,12 +438,10 @@ static int maybe_read_page_remote(struct page_read *pr, unsigned long vaddr,
/* We always do PR_ASAP mode here (FIXME?) */ /* We always do PR_ASAP mode here (FIXME?) */
ret = request_remote_pages(pr->pid, vaddr, nr); ret = request_remote_pages(pr->pid, vaddr, nr);
if (ret < 0) if (!ret)
return ret; ret = page_server_start_read(buf, nr,
if (flags & PR_ASYNC) read_page_complete, pr, flags);
return page_server_start_async_read(buf, nr, read_page_complete, pr); 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, static int read_pagemap_page(struct page_read *pr, unsigned long vaddr, int nr,