[CRIU] [PATCH 5/6] mem: Split draning pages from xfer-ing them

Pavel Emelyanov xemul at virtuozzo.com
Mon Sep 19 04:18:04 PDT 2016


Signed-off-by: Pavel Emelyanov <xemul at virtuozzo.com>
---
 criu/mem.c | 28 ++++++++++++++++++----------
 1 file changed, 18 insertions(+), 10 deletions(-)

diff --git a/criu/mem.c b/criu/mem.c
index c38f793..09a225d 100644
--- a/criu/mem.c
+++ b/criu/mem.c
@@ -233,9 +233,8 @@ static struct parasite_dump_pages_args *prep_dump_pages_args(struct parasite_ctl
 	return args;
 }
 
-static int dump_pages(struct page_pipe *pp, struct parasite_ctl *ctl,
-		      struct parasite_dump_pages_args *args,
-		      struct page_xfer *xfer, bool lazy)
+static int drain_pages(struct page_pipe *pp, struct parasite_ctl *ctl,
+		      struct parasite_dump_pages_args *args)
 {
 	struct page_pipe_buf *ppb;
 	int ret = 0;
@@ -263,15 +262,20 @@ static int dump_pages(struct page_pipe *pp, struct parasite_ctl *ctl,
 		args->off += args->nr_segs;
 	}
 
+	return 0;
+}
+
+static int xfer_pages(struct page_pipe *pp, struct page_xfer *xfer, bool lazy)
+{
+	int ret;
+
 	/*
 	 * Step 3 -- write pages into image (or delay writing for
 	 *           pre-dump action (see pre_dump_one_task)
 	 */
-	if (xfer) {
-		timing_start(TIME_MEMWRITE);
-		ret = page_xfer_dump_pages(xfer, pp, 0, !lazy);
-		timing_stop(TIME_MEMWRITE);
-	}
+	timing_start(TIME_MEMWRITE);
+	ret = page_xfer_dump_pages(xfer, pp, 0, !lazy);
+	timing_stop(TIME_MEMWRITE);
 
 	return ret;
 }
@@ -363,7 +367,9 @@ again:
 			if (ret == -EAGAIN) {
 				BUG_ON(mdc->delayed_dump);
 
-				ret = dump_pages(pp, ctl, args, &xfer, false);
+				ret = drain_pages(pp, ctl, args);
+				if (!ret)
+					ret = xfer_pages(pp, &xfer, false);
 				if (!ret) {
 					page_pipe_reinit(pp);
 					goto again;
@@ -377,7 +383,9 @@ again:
 	if (mdc->lazy)
 		memcpy(pargs_iovs(args), pp->iovs,
 		       sizeof(struct iovec) * pp->nr_iovs);
-	ret = dump_pages(pp, ctl, args, should_xfer ? &xfer : NULL, mdc->lazy);
+	ret = drain_pages(pp, ctl, args);
+	if (!ret && should_xfer)
+		ret = xfer_pages(pp, &xfer, mdc->lazy);
 	if (ret)
 		goto out_xfer;
 
-- 
2.5.0



More information about the CRIU mailing list