[CRIU] [PATCH 2/3] deduplication: add auto-dedup on restore
Tikhomirov Pavel
snorcht at gmail.com
Wed Jan 29 05:55:37 PST 2014
if option --auto-dedup is set on restore, then as soon as page is
restored it will be punched from the image.
open image in O_RDWR mode
Signed-off-by: Tikhomirov Pavel <snorcht at gmail.com>
---
cr-restore.c | 12 +++++++++---
page-read.c | 8 ++++++++
2 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/cr-restore.c b/cr-restore.c
index 2aa2c37..2f501dc 100644
--- a/cr-restore.c
+++ b/cr-restore.c
@@ -329,9 +329,15 @@ static int restore_priv_vma_content(pid_t pid)
struct page_read pr;
vma = list_first_entry(&rst_vmas.h, struct vma_area, list);
- ret = open_page_read(pid, &pr);
- if (ret)
- return -1;
+ if (!opts.auto_dedup) {
+ ret = open_page_read(pid, &pr);
+ if (ret)
+ return -1;
+ } else {
+ ret = open_page_rw(pid, &pr);
+ if (ret)
+ return -1;
+ }
/*
* Read page contents.
diff --git a/page-read.c b/page-read.c
index a499b2a..3f1d326 100644
--- a/page-read.c
+++ b/page-read.c
@@ -3,6 +3,7 @@
#include <unistd.h>
#include "image.h"
+#include "cr_options.h"
#include "servicefd.h"
#include "page-read.h"
@@ -146,6 +147,13 @@ static int read_pagemap_page(struct page_read *pr, unsigned long vaddr, void *bu
pr_perror("Can't read mapping page %d", ret);
return -1;
}
+
+ if (opts.auto_dedup) {
+ ret = punch_hole(pr->fd_pg, current_vaddr, (unsigned int)PAGE_SIZE);
+ if (ret == -1) {
+ return -1;
+ }
+ }
}
pr->cvaddr += PAGE_SIZE;
--
1.8.3.2
More information about the CRIU
mailing list