From 275f81bcb532e1c99e78729ce00db732ba1ccbc6 Mon Sep 17 00:00:00 2001 From: Pavel Emelyanov Date: Wed, 16 Nov 2016 12:39:08 +0300 Subject: [PATCH] page-read: Drop get_remote_pages We already have routines that do send-req, recv-info and recv-page, so no need in yet another one. Signed-off-by: Pavel Emelyanov --- criu/include/page-xfer.h | 3 --- criu/page-xfer.c | 34 ++++------------------------------ criu/pagemap.c | 21 ++++++++++++--------- 3 files changed, 16 insertions(+), 42 deletions(-) diff --git a/criu/include/page-xfer.h b/criu/include/page-xfer.h index 7cd00553d..5b7ec21f2 100644 --- a/criu/include/page-xfer.h +++ b/criu/include/page-xfer.h @@ -52,9 +52,6 @@ extern int check_parent_page_xfer(int fd_type, long id); * - dump-side page server sends the raw page data */ -/* sync receive of remote pages */ -extern int get_remote_pages(int pid, unsigned long addr, int nr_pages, void *dest); - /* async request/receive of remote pages */ extern int request_remote_pages(int pid, unsigned long addr, int nr_pages); extern int receive_remote_pages_info(int *nr_pages, unsigned long *addr, int *pid); diff --git a/criu/page-xfer.c b/criu/page-xfer.c index 2c89ded8a..f0da4e34c 100644 --- a/criu/page-xfer.c +++ b/criu/page-xfer.c @@ -950,36 +950,6 @@ out: return ret ? : status; } -int get_remote_pages(int pid, unsigned long addr, int nr_pages, void *dest) -{ - int ret; - int len = PAGE_SIZE * nr_pages; - - struct page_server_iov pi; - - if (send_psi(page_server_sk, PS_IOV_GET, nr_pages, addr, pid)) - return -1; - - tcp_nodelay(page_server_sk, true); - - ret = recv(page_server_sk, &pi, sizeof(pi), MSG_WAITALL); - if (ret != sizeof(pi)) - return -1; - - /* zero page */ - if (pi.cmd == PS_IOV_ZERO) - return 0; - - if (pi.nr_pages > nr_pages) - return -1; - - ret = recv(page_server_sk, dest, len, MSG_WAITALL); - if (ret != len) - return -1; - - return 1; -} - int request_remote_pages(int pid, unsigned long addr, int nr_pages) { struct page_server_iov pi = { @@ -1008,6 +978,10 @@ int receive_remote_pages_info(int *nr_pages, unsigned long *addr, int *pid) return -1; } + if (pi.cmd == PS_IOV_ZERO) + pr_warn("Unexpected ZERO page received for %d.%lx\n", + (int)pi.dst_id, (unsigned long)pi.vaddr); + *nr_pages = pi.nr_pages; *addr = pi.vaddr; *pid = pi.dst_id; diff --git a/criu/pagemap.c b/criu/pagemap.c index 51639a4c5..16958acfd 100644 --- a/criu/pagemap.c +++ b/criu/pagemap.c @@ -414,16 +414,19 @@ static int maybe_read_page_local(struct page_read *pr, unsigned long vaddr, static int maybe_read_page_remote(struct page_read *pr, unsigned long vaddr, int nr, void *buf, unsigned flags) { - int ret; + int ret, pid; - if (flags & PR_ASYNC) - /* - * Note, that for async remote page_read, the actual - * transfer happens in the lazy-pages daemon - */ - ret = request_remote_pages(pr->pid, vaddr, len / PAGE_SIZE); - else - ret = get_remote_pages(pr->pid, vaddr, nr, buf); + ret = request_remote_pages(pr->pid, vaddr, nr); + if ((ret < 0) || (flags & PR_ASYNC)) + return ret; + + /* + * Note, that for async remote page_read, the actual + * transfer happens in the lazy-pages daemon + */ + ret = receive_remote_pages_info(&nr, &vaddr, &pid); + if (ret == 0) + ret = receive_remote_pages(nr * PAGE_SIZE, buf); return ret; }