Commit f0a6d32c authored by Tikhomirov Pavel's avatar Tikhomirov Pavel Committed by Pavel Emelyanov

v2 deduplication: add auto-dedup on restore

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: 's avatarTikhomirov Pavel <snorcht@gmail.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent a355affd
...@@ -338,9 +338,15 @@ static int restore_priv_vma_content(pid_t pid) ...@@ -338,9 +338,15 @@ static int restore_priv_vma_content(pid_t pid)
struct page_read pr; struct page_read pr;
vma = list_first_entry(vmas, struct vma_area, list); vma = list_first_entry(vmas, struct vma_area, list);
ret = open_page_read(pid, &pr); if (!opts.auto_dedup) {
if (ret) ret = open_page_read(pid, &pr);
return -1; if (ret)
return -1;
} else {
ret = open_page_rw(pid, &pr);
if (ret)
return -1;
}
/* /*
* Read page contents. * Read page contents.
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#include <unistd.h> #include <unistd.h>
#include "image.h" #include "image.h"
#include "cr_options.h"
#include "servicefd.h" #include "servicefd.h"
#include "page-read.h" #include "page-read.h"
...@@ -146,6 +147,13 @@ static int read_pagemap_page(struct page_read *pr, unsigned long vaddr, void *bu ...@@ -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); pr_perror("Can't read mapping page %d", ret);
return -1; 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; pr->cvaddr += PAGE_SIZE;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment