[CRIU] [PATCH 3/4] iov: Add iovec2pagemap() helper

Pavel Emelyanov xemul at parallels.com
Thu Jun 19 04:38:26 PDT 2014


Signed-off-by: Pavel Emelyanov <xemul at parallels.com>
---
 include/page-read.h | 1 +
 page-read.c         | 6 ++++++
 page-xfer.c         | 7 ++-----
 3 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/include/page-read.h b/include/page-read.h
index 7a063e9..64a8579 100644
--- a/include/page-read.h
+++ b/include/page-read.h
@@ -71,6 +71,7 @@ struct page_read {
 extern int open_page_read(int pid, struct page_read *, int flags, bool shmem);
 extern int open_page_read_at(int dfd, int pid, struct page_read *pr, int flags, bool shmem);
 extern void pagemap2iovec(PagemapEntry *pe, struct iovec *iov);
+extern void iovec2pagemap(struct iovec *iov, PagemapEntry *pe);
 extern int seek_pagemap_page(struct page_read *pr, unsigned long vaddr, bool warn);
 
 extern int dedup_one_iovec(struct page_read *pr, struct iovec *iov);
diff --git a/page-read.c b/page-read.c
index 8937f33..3cb43de 100644
--- a/page-read.c
+++ b/page-read.c
@@ -49,6 +49,12 @@ void pagemap2iovec(PagemapEntry *pe, struct iovec *iov)
 	iov->iov_len = pe->nr_pages * PAGE_SIZE;
 }
 
+void iovec2pagemap(struct iovec *iov, PagemapEntry *pe)
+{
+	pe->vaddr = encode_pointer(iov->iov_base);
+	pe->nr_pages = iov->iov_len / PAGE_SIZE;
+}
+
 static int get_pagemap(struct page_read *pr, struct iovec *iov)
 {
 	int ret;
diff --git a/page-xfer.c b/page-xfer.c
index 56e8575..2b4ff53 100644
--- a/page-xfer.c
+++ b/page-xfer.c
@@ -457,9 +457,7 @@ static int write_pagemap_loc(struct page_xfer *xfer,
 	int ret;
 	PagemapEntry pe = PAGEMAP_ENTRY__INIT;
 
-	pe.vaddr = encode_pointer(iov->iov_base);
-	pe.nr_pages = iov->iov_len / PAGE_SIZE;
-
+	iovec2pagemap(iov, &pe);
 	if (opts.auto_dedup && xfer->parent != NULL) {
 		ret = dedup_one_iovec(xfer->parent, iov);
 		if (ret == -1) {
@@ -544,8 +542,7 @@ static int write_pagehole_loc(struct page_xfer *xfer, struct iovec *iov)
 		}
 	}
 
-	pe.vaddr = encode_pointer(iov->iov_base);
-	pe.nr_pages = iov->iov_len / PAGE_SIZE;
+	iovec2pagemap(iov, &pe);
 	pe.has_in_parent = true;
 	pe.in_parent = true;
 
-- 
1.8.4.2


More information about the CRIU mailing list