[CRIU] [PATCH 3/5] page-server: Merge async and sync read API calls
Pavel Emelyanov
xemul at virtuozzo.com
Wed Jun 14 13:15:06 MSK 2017
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 at virtuozzo.com>
---
criu/include/page-xfer.h | 6 ++----
criu/page-xfer.c | 13 +++++++++++--
criu/pagemap.c | 10 ++++------
3 files changed, 17 insertions(+), 12 deletions(-)
diff --git a/criu/include/page-xfer.h b/criu/include/page-xfer.h
index 4ccefee..1a00d9c 100644
--- a/criu/include/page-xfer.h
+++ b/criu/include/page-xfer.h
@@ -62,9 +62,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);
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,
- ps_async_read_complete complete, void *priv);
+extern int page_server_start_read(void *buf, int nr_pages,
+ ps_async_read_complete complete, void *priv, unsigned flags);
#endif /* __CR_PAGE_XFER__H__ */
diff --git a/criu/page-xfer.c b/criu/page-xfer.c
index 067b7d3..dd1c6d0 100644
--- a/criu/page-xfer.c
+++ b/criu/page-xfer.c
@@ -1072,7 +1072,7 @@ struct ps_async_read {
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)
{
struct ps_async_read *ar;
@@ -1204,7 +1204,7 @@ static int receive_remote_pages(int len, void *buf)
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)
{
int ret, pid, new_nr;
@@ -1226,3 +1226,12 @@ int page_server_start_sync_read(void *buf, int nr,
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);
+}
diff --git a/criu/pagemap.c b/criu/pagemap.c
index 8a2cce9..2a65c59 100644
--- a/criu/pagemap.c
+++ b/criu/pagemap.c
@@ -470,12 +470,10 @@ static int maybe_read_page_remote(struct page_read *pr, unsigned long vaddr,
/* We always do PR_ASAP mode here (FIXME?) */
ret = request_remote_pages(pr->pid, vaddr, nr);
- if (ret < 0)
- return ret;
- if (flags & PR_ASYNC)
- return page_server_start_async_read(buf, nr, read_page_complete, pr);
- else
- return page_server_start_sync_read(buf, nr, read_page_complete, pr);
+ if (!ret)
+ ret = page_server_start_read(buf, nr,
+ read_page_complete, pr, flags);
+ return ret;
}
static int read_pagemap_page(struct page_read *pr, unsigned long vaddr, int nr,
--
2.1.4
More information about the CRIU
mailing list