[CRIU] [PATCH v2 1/2] dedup_one_iovec: explicitly pass start and end instead of iovec
Mike Rapoport
rppt at linux.vnet.ibm.com
Tue Dec 6 01:15:08 PST 2016
Signed-off-by: Mike Rapoport <rppt at linux.vnet.ibm.com>
---
criu/cr-dedup.c | 3 ++-
criu/include/pagemap.h | 9 ++++++++-
criu/page-xfer.c | 3 ++-
criu/pagemap.c | 12 +++++-------
4 files changed, 17 insertions(+), 10 deletions(-)
diff --git a/criu/cr-dedup.c b/criu/cr-dedup.c
index 7ecc99c..b17fa20 100644
--- a/criu/cr-dedup.c
+++ b/criu/cr-dedup.c
@@ -91,7 +91,8 @@ static int cr_dedup_one_pagemap(int id, int flags)
pagemap2iovec(pr.pe, &iov);
pr_debug("dedup iovec base=%p, len=%zu\n", iov.iov_base, iov.iov_len);
if (!pagemap_in_parent(pr.pe)) {
- ret = dedup_one_iovec(prp, &iov);
+ ret = dedup_one_iovec(prp, pr.pe->vaddr,
+ pagemap_len(pr.pe));
if (ret)
goto exit;
}
diff --git a/criu/include/pagemap.h b/criu/include/pagemap.h
index 87795a3..89d465e 100644
--- a/criu/include/pagemap.h
+++ b/criu/include/pagemap.h
@@ -3,6 +3,7 @@
#include "common/list.h"
#include "images/pagemap.pb-c.h"
+#include "page.h"
/*
* page_read -- engine, that reads pages from image file(s)
@@ -105,7 +106,13 @@ extern int open_page_read_at(int dfd, int pid, struct page_read *pr,
extern void pagemap2iovec(PagemapEntry *pe, struct iovec *iov);
extern void iovec2pagemap(struct iovec *iov, PagemapEntry *pe);
-extern int dedup_one_iovec(struct page_read *pr, struct iovec *iov);
+extern int dedup_one_iovec(struct page_read *pr, unsigned long base,
+ unsigned long len);
+
+static inline unsigned long pagemap_len(PagemapEntry *pe)
+{
+ return pe->nr_pages * PAGE_SIZE;
+}
/* Pagemap flags */
#define PE_PARENT (1 << 0) /* pages are in parent snapshot */
diff --git a/criu/page-xfer.c b/criu/page-xfer.c
index b60863a..4c65f2a 100644
--- a/criu/page-xfer.c
+++ b/criu/page-xfer.c
@@ -244,7 +244,8 @@ static int write_pagemap_loc(struct page_xfer *xfer, struct iovec *iov, u32 flag
if (flags & PE_PRESENT) {
if (opts.auto_dedup && xfer->parent != NULL) {
- ret = dedup_one_iovec(xfer->parent, iov);
+ ret = dedup_one_iovec(xfer->parent, pe.vaddr,
+ pagemap_len(&pe));
if (ret == -1) {
pr_perror("Auto-deduplication failed");
return ret;
diff --git a/criu/pagemap.c b/criu/pagemap.c
index e7a45bd..c881bb5 100644
--- a/criu/pagemap.c
+++ b/criu/pagemap.c
@@ -85,18 +85,17 @@ static int punch_hole(struct page_read *pr, unsigned long off,
static int seek_pagemap_page(struct page_read *pr, unsigned long vaddr);
-int dedup_one_iovec(struct page_read *pr, struct iovec *iov)
+int dedup_one_iovec(struct page_read *pr, unsigned long base, unsigned long len)
{
unsigned long off;
unsigned long iov_end;
- iov_end = (unsigned long)iov->iov_base + iov->iov_len;
- off = (unsigned long)iov->iov_base;
+ iov_end = base + len;
+ off = base;
while (1) {
int ret;
struct iovec piov;
unsigned long piov_end;
- struct iovec tiov;
struct page_read * prp;
ret = seek_pagemap_page(pr, off);
@@ -122,9 +121,8 @@ int dedup_one_iovec(struct page_read *pr, struct iovec *iov)
if (prp) {
/* recursively */
pr_debug("Go to next parent level\n");
- tiov.iov_base = (void*)off;
- tiov.iov_len = min(piov_end, iov_end) - off;
- ret = dedup_one_iovec(prp, &tiov);
+ len = min(piov_end, iov_end) - off;
+ ret = dedup_one_iovec(prp, off, len);
if (ret != 0)
return -1;
}
--
1.9.1
More information about the CRIU
mailing list