mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-29 13:28:27 +00:00
page-server: Introduce page_server_start_sync_read
There's no need in two API calls to read xfer header and pages themselves, so merge them into one single call. Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com> Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
This commit is contained in:
parent
47b9438628
commit
b801cd68d9
@ -55,11 +55,10 @@ extern int check_parent_page_xfer(int fd_type, long id);
|
||||
|
||||
/* 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);
|
||||
extern int receive_remote_pages(int len, void *buf);
|
||||
|
||||
typedef int (*ps_async_read_complete)(int pid, unsigned long vaddr, int nr_pages, void *);
|
||||
extern int page_server_start_async_read(void *buf, int nr_pages,
|
||||
ps_async_read_complete complete, void *priv);
|
||||
extern int page_server_start_sync_read(void *buf, int nr_pages, unsigned long *vaddr);
|
||||
|
||||
#endif /* __CR_PAGE_XFER__H__ */
|
||||
|
@ -1171,7 +1171,7 @@ int request_remote_pages(int pid, unsigned long addr, int nr_pages)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int receive_remote_pages_info(int *nr_pages, unsigned long *addr, int *pid)
|
||||
static int receive_remote_pages_info(int *nr_pages, unsigned long *addr, int *pid)
|
||||
{
|
||||
struct page_server_iov pi;
|
||||
|
||||
@ -1191,7 +1191,7 @@ int receive_remote_pages_info(int *nr_pages, unsigned long *addr, int *pid)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int receive_remote_pages(int len, void *buf)
|
||||
static int receive_remote_pages(int len, void *buf)
|
||||
{
|
||||
if (recv(page_server_sk, buf, len, MSG_WAITALL) != len) {
|
||||
pr_perror("Failed to receive page data");
|
||||
@ -1200,3 +1200,21 @@ int receive_remote_pages(int len, void *buf)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int page_server_start_sync_read(void *buf, int nr, unsigned long *vaddr)
|
||||
{
|
||||
int ret, pid, new_nr;
|
||||
|
||||
/*
|
||||
* Note, that for async remote page_read, the actual
|
||||
* transfer happens in the lazy-pages daemon
|
||||
*/
|
||||
ret = receive_remote_pages_info(&new_nr, vaddr, &pid);
|
||||
if (ret == 0) {
|
||||
if (new_nr < 0 || new_nr > nr)
|
||||
return -1;
|
||||
ret = receive_remote_pages(nr * PAGE_SIZE, buf);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -434,7 +434,7 @@ static int read_page_complete(int pid, unsigned long vaddr, int nr_pages, void *
|
||||
static int maybe_read_page_remote(struct page_read *pr, unsigned long vaddr,
|
||||
int nr, void *buf, unsigned flags)
|
||||
{
|
||||
int ret, pid, new_nr;
|
||||
int ret;
|
||||
|
||||
/* We always do PR_ASAP mode here (FIXME?) */
|
||||
ret = request_remote_pages(pr->pid, vaddr, nr);
|
||||
@ -443,17 +443,7 @@ static int maybe_read_page_remote(struct page_read *pr, unsigned long vaddr,
|
||||
if (flags & PR_ASYNC)
|
||||
return page_server_start_async_read(buf, nr, read_page_complete, pr);
|
||||
|
||||
/*
|
||||
* Note, that for async remote page_read, the actual
|
||||
* transfer happens in the lazy-pages daemon
|
||||
*/
|
||||
ret = receive_remote_pages_info(&new_nr, &vaddr, &pid);
|
||||
if (ret == 0) {
|
||||
if (new_nr < 0 || new_nr > nr)
|
||||
return -1;
|
||||
ret = receive_remote_pages(nr * PAGE_SIZE, buf);
|
||||
}
|
||||
|
||||
ret = page_server_start_sync_read(buf, nr, &vaddr);
|
||||
if (ret == 0 && pr->io_complete)
|
||||
ret = pr->io_complete(pr, vaddr, nr);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user