[09/13] page-xfer: Normalize remote/local parent xfer checks

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

Details

Message ID fc1c16c7-4128-2034-f542-01de66f26b47@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:40 a.m.
We have two places to check for parent via page server -- as
a part of _OPEN req and explicit req. Make the latter code
be in-sync with the opening one.

Acked-by: Mike Rapoport <rppt@linux.vnet.ibm.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
---
 criu/page-xfer.c | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

Patch hide | download patch | download mbox

diff --git a/criu/page-xfer.c b/criu/page-xfer.c
index ea38172..41a0e68 100644
--- a/criu/page-xfer.c
+++ b/criu/page-xfer.c
@@ -461,16 +461,12 @@  int check_parent_local_xfer(int fd_type, int id)
 	struct stat st;
 	int ret, pfd;
 
-	if (opts.remote) {
-		pfd = get_curr_parent_snapshot_id_idx();
-		pr_err("Unable to get parent snapshot id\n");
-		if (pfd == -1)
-			return -1;
-	} else {
-		pfd = openat(get_service_fd(IMG_FD_OFF), CR_PARENT_LINK, O_RDONLY);
-		if (pfd < 0 && errno == ENOENT)
-			return 0;
-	}
+	if (opts.remote)
+		return get_curr_parent_snapshot_id_idx() == -1 ? 0 : 1;
+
+	pfd = openat(get_service_fd(IMG_FD_OFF), CR_PARENT_LINK, O_RDONLY);
+	if (pfd < 0 && errno == ENOENT)
+		return 0;
 
 	snprintf(path, sizeof(path), imgset_template[fd_type].fmt, id);
 	ret = fstatat(pfd, path, &st, 0);
@@ -530,8 +526,6 @@  int check_parent_page_xfer(int fd_type, long id)
 {
 	if (opts.use_page_server)
 		return check_parent_server_xfer(fd_type, id);
-	else if (opts.remote)
-		return get_curr_parent_snapshot_id_idx() == -1 ? 0 : 1;
 	else
 		return check_parent_local_xfer(fd_type, id);
 }