[CRIU] [PATCH 3/6] pageserver: Merge page_server_add with page_server_hole

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


Do the same here, the flags is now enough to tell hole
from pagemap.

Signed-off-by: Pavel Emelyanov <xemul at virtuozzo.com>
---
 criu/page-xfer.c | 32 ++++++++------------------------
 1 file changed, 8 insertions(+), 24 deletions(-)

diff --git a/criu/page-xfer.c b/criu/page-xfer.c
index 3e61d65..548903a 100644
--- a/criu/page-xfer.c
+++ b/criu/page-xfer.c
@@ -582,12 +582,11 @@ static int prep_loc_xfer(struct page_server_iov *pi)
 		return 0;
 }
 
-static int page_server_add(int sk, struct page_server_iov *pi)
+static int page_server_add(int sk, struct page_server_iov *pi, u32 flags)
 {
 	size_t len;
 	struct page_xfer *lxfer = &cxfer.loc_xfer;
 	struct iovec iov;
-	u32 flags;
 
 	pr_debug("Adding %"PRIx64"/%u\n", pi->vaddr, pi->nr_pages);
 
@@ -595,10 +594,12 @@ static int page_server_add(int sk, struct page_server_iov *pi)
 		return -1;
 
 	psi2iovec(pi, &iov);
-	flags = decode_ps_flags(pi->cmd);
 	if (lxfer->write_pagemap(lxfer, &iov, flags))
 		return -1;
 
+	if (!(flags & PE_PRESENT))
+		return 0;
+
 	len = iov.iov_len;
 	while (len > 0) {
 		ssize_t chunk;
@@ -622,23 +623,6 @@ static int page_server_add(int sk, struct page_server_iov *pi)
 	return 0;
 }
 
-static int page_server_hole(int sk, struct page_server_iov *pi, u32 flags)
-{
-	struct page_xfer *lxfer = &cxfer.loc_xfer;
-	struct iovec iov;
-
-	pr_debug("Adding %"PRIx64"/%u hole\n", pi->vaddr, pi->nr_pages);
-
-	if (prep_loc_xfer(pi))
-		return -1;
-
-	psi2iovec(pi, &iov);
-	if (lxfer->write_pagemap(lxfer, &iov, flags))
-		return -1;
-
-	return 0;
-}
-
 static int page_server_get_pages(int sk, struct page_server_iov *pi)
 {
 	struct pstree_item *item;
@@ -734,16 +718,16 @@ static int page_server_serve(int sk)
 			ret = page_server_check_parent(sk, &pi);
 			break;
 		case PS_IOV_ADD:
-			ret = page_server_add(sk, &pi);
+			ret = page_server_add(sk, &pi, PE_PRESENT | decode_ps_flags(pi.cmd));
 			break;
 		case PS_IOV_HOLE:
-			ret = page_server_hole(sk, &pi, PE_PARENT);
+			ret = page_server_add(sk, &pi, PE_PARENT);
 			break;
 		case PS_IOV_ZERO:
-			ret = page_server_hole(sk, &pi, PE_ZERO);
+			ret = page_server_add(sk, &pi, PE_ZERO);
 			break;
 		case PS_IOV_LAZY:
-			ret = page_server_hole(sk, &pi, PE_LAZY);
+			ret = page_server_add(sk, &pi, PE_LAZY);
 			break;
 		case PS_IOV_FLUSH:
 		case PS_IOV_FLUSH_N_CLOSE:
-- 
2.5.0



More information about the CRIU mailing list