[11/13] page-xfer: Move lazy bool on xfer

Submitted by Pavel Emelianov on July 6, 2017, 9:41 a.m.

Details

Message ID 8a80c49e-92ef-62c3-626a-de4b0cbecdb5@virtuozzo.com
State Accepted
Series "A set of cleanups for pagemaps/xfers/reads before master merge (resend)"
Headers show

Commit Message

Pavel Emelianov July 6, 2017, 9:41 a.m.
Same thing for the boolean value saying whether or not to send
lazy pagemaps alone or follow them with the respective pages.
This value is non-true in the single place, so let's simplify
the API and keep this bool on xfer object.

Acked-by: Mike Rapoport <rppt@linux.vnet.ibm.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
---
 criu/cr-dump.c           |  2 +-
 criu/include/page-xfer.h |  3 ++-
 criu/mem.c               | 10 ++++++----
 criu/page-xfer.c         |  6 +++---
 criu/shmem.c             |  2 +-
 5 files changed, 13 insertions(+), 10 deletions(-)

Patch hide | download patch | download mbox

diff --git a/criu/cr-dump.c b/criu/cr-dump.c
index 98edf17..06f3966 100644
--- a/criu/cr-dump.c
+++ b/criu/cr-dump.c
@@ -1574,7 +1574,7 @@  static int cr_pre_dump_finish(int ret)
 			goto err;
 
 		mem_pp = dmpi(item)->mem_pp;
-		ret = page_xfer_dump_pages(&xfer, mem_pp, true);
+		ret = page_xfer_dump_pages(&xfer, mem_pp);
 
 		xfer.close(&xfer);
 
diff --git a/criu/include/page-xfer.h b/criu/include/page-xfer.h
index 38ea59c..ffb6b08 100644
--- a/criu/include/page-xfer.h
+++ b/criu/include/page-xfer.h
@@ -27,6 +27,7 @@  struct page_xfer {
 	 * relative to some address. Used, e.g. by shmem.
 	 */
 	unsigned long offset;
+	bool transfer_lazy;
 
 	/* private data for every page-xfer engine */
 	union {
@@ -46,7 +47,7 @@  struct page_xfer {
 
 extern int open_page_xfer(struct page_xfer *xfer, int fd_type, long id);
 struct page_pipe;
-extern int page_xfer_dump_pages(struct page_xfer *, struct page_pipe *, bool dump_lazy);
+extern int page_xfer_dump_pages(struct page_xfer *, struct page_pipe *);
 extern int connect_to_page_server_to_send(void);
 extern int connect_to_page_server_to_recv(int epfd);
 extern int disconnect_from_page_server(void);
diff --git a/criu/mem.c b/criu/mem.c
index 4b4b3c8..1089270 100644
--- a/criu/mem.c
+++ b/criu/mem.c
@@ -275,7 +275,7 @@  static int drain_pages(struct page_pipe *pp, struct parasite_ctl *ctl,
 	return 0;
 }
 
-static int xfer_pages(struct page_pipe *pp, struct page_xfer *xfer, bool lazy)
+static int xfer_pages(struct page_pipe *pp, struct page_xfer *xfer)
 {
 	int ret;
 
@@ -284,7 +284,7 @@  static int xfer_pages(struct page_pipe *pp, struct page_xfer *xfer, bool lazy)
 	 *           pre-dump action (see pre_dump_one_task)
 	 */
 	timing_start(TIME_MEMWRITE);
-	ret = page_xfer_dump_pages(xfer, pp, !lazy);
+	ret = page_xfer_dump_pages(xfer, pp);
 	timing_stop(TIME_MEMWRITE);
 
 	return ret;
@@ -349,6 +349,8 @@  static int __parasite_dump_pages_seized(struct pstree_item *item,
 		ret = open_page_xfer(&xfer, CR_FD_PAGEMAP, vpid(item));
 		if (ret < 0)
 			goto out_pp;
+
+		xfer.transfer_lazy = !mdc->lazy;
 	} else {
 		ret = check_parent_page_xfer(CR_FD_PAGEMAP, vpid(item));
 		if (ret < 0)
@@ -390,7 +392,7 @@  again:
 
 				ret = drain_pages(pp, ctl, args);
 				if (!ret)
-					ret = xfer_pages(pp, &xfer, mdc->lazy /* false actually */);
+					ret = xfer_pages(pp, &xfer);
 				if (!ret) {
 					page_pipe_reinit(pp);
 					goto again;
@@ -406,7 +408,7 @@  again:
 		       sizeof(struct iovec) * pp->nr_iovs);
 	ret = drain_pages(pp, ctl, args);
 	if (!ret && !mdc->pre_dump)
-		ret = xfer_pages(pp, &xfer, mdc->lazy);
+		ret = xfer_pages(pp, &xfer);
 	if (ret)
 		goto out_xfer;
 
diff --git a/criu/page-xfer.c b/criu/page-xfer.c
index 91398e7..10da75f 100644
--- a/criu/page-xfer.c
+++ b/criu/page-xfer.c
@@ -350,6 +350,7 @@  out:
 int open_page_xfer(struct page_xfer *xfer, int fd_type, long id)
 {
 	xfer->offset = 0;
+	xfer->transfer_lazy = true;
 
 	if (opts.use_page_server)
 		return open_page_server_xfer(xfer, fd_type, id);
@@ -404,8 +405,7 @@  static int dump_holes(struct page_xfer *xfer, struct page_pipe *pp,
 	return 0;
 }
 
-int page_xfer_dump_pages(struct page_xfer *xfer, struct page_pipe *pp,
-		bool dump_lazy)
+int page_xfer_dump_pages(struct page_xfer *xfer, struct page_pipe *pp)
 {
 	struct page_pipe_buf *ppb;
 	unsigned int cur_hole = 0;
@@ -432,7 +432,7 @@  int page_xfer_dump_pages(struct page_xfer *xfer, struct page_pipe *pp,
 					(unsigned int)(iov.iov_len / PAGE_SIZE));
 
 			if (ppb->flags & PPB_LAZY) {
-				if (!dump_lazy) {
+				if (!xfer->transfer_lazy) {
 					if (xfer->write_pagemap(xfer, &iov, PE_LAZY))
 						return -1;
 					continue;
diff --git a/criu/shmem.c b/criu/shmem.c
index 27778f9..2de8cb4 100644
--- a/criu/shmem.c
+++ b/criu/shmem.c
@@ -636,7 +636,7 @@  static int dump_pages(struct page_pipe *pp, struct page_xfer *xfer)
 			return -1;
 		}
 
-	return page_xfer_dump_pages(xfer, pp, true);
+	return page_xfer_dump_pages(xfer, pp);
 }
 
 static int next_data_segment(int fd, unsigned long pfn,