[CRIU] [PATCH 2/5]v2 deduplication: add auto-dedup on restore
Pavel Emelyanov
xemul at parallels.com
Wed Feb 19 08:11:46 PST 2014
On 02/19/2014 06:56 PM, Tikhomirov Pavel wrote:
> if option --auto-dedup is set on restore, then as soon as page is
> restored it will be punched from the image.
This should be reflected in the criu --help text.
> 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 22614db..63768d8 100644
> --- a/cr-restore.c
> +++ b/cr-restore.c
> @@ -338,9 +338,15 @@ static int restore_priv_vma_content(pid_t pid)
> struct page_read pr;
>
> vma = list_first_entry(vmas, 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;
>
More information about the CRIU
mailing list