2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-31 14:25:49 +00:00

iov: Add page_server_iov to iov and back helpers

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
Pavel Emelyanov
2014-06-19 15:39:07 +04:00
parent 3b995f1aef
commit 687c389478

View File

@@ -21,6 +21,18 @@ struct page_server_iov {
u64 dst_id;
};
static void psi2iovec(struct page_server_iov *ps, struct iovec *iov)
{
iov->iov_base = decode_pointer(ps->vaddr);
iov->iov_len = ps->nr_pages * PAGE_SIZE;
}
static void iovec2psi(struct iovec *iov, struct page_server_iov *ps)
{
ps->vaddr = encode_pointer(iov->iov_base);
ps->nr_pages = iov->iov_len / PAGE_SIZE;
}
static int open_page_local_xfer(struct page_xfer *xfer, int fd_type, long id);
#define PS_IOV_ADD 1
@@ -102,9 +114,7 @@ static int page_server_add(int sk, struct page_server_iov *pi)
if (prep_loc_xfer(pi))
return -1;
iov.iov_base = decode_pointer(pi->vaddr);
iov.iov_len = pi->nr_pages * PAGE_SIZE;
psi2iovec(pi, &iov);
if (lxfer->write_pagemap(lxfer, &iov))
return -1;
@@ -141,9 +151,7 @@ static int page_server_hole(int sk, struct page_server_iov *pi)
if (prep_loc_xfer(pi))
return -1;
iov.iov_base = decode_pointer(pi->vaddr);
iov.iov_len = pi->nr_pages * PAGE_SIZE;
psi2iovec(pi, &iov);
if (lxfer->write_hole(lxfer, &iov))
return -1;
@@ -381,8 +389,7 @@ static int write_pagemap_to_server(struct page_xfer *xfer,
pi.cmd = PS_IOV_ADD;
pi.dst_id = xfer->dst_id;
pi.vaddr = encode_pointer(iov->iov_base);
pi.nr_pages = iov->iov_len / PAGE_SIZE;
iovec2psi(iov, &pi);
if (write(xfer->fd, &pi, sizeof(pi)) != sizeof(pi)) {
pr_perror("Can't write pagemap to server");
@@ -411,8 +418,7 @@ static int write_hole_to_server(struct page_xfer *xfer, struct iovec *iov)
pi.cmd = PS_IOV_HOLE;
pi.dst_id = xfer->dst_id;
pi.vaddr = encode_pointer(iov->iov_base);
pi.nr_pages = iov->iov_len / PAGE_SIZE;
iovec2psi(iov, &pi);
if (write(xfer->fd, &pi, sizeof(pi)) != sizeof(pi)) {
pr_perror("Can't write pagehole to server");