[CRIU] [PATCH 4/5] deduplication: add punching holes in "parent"

Pavel Emelyanov xemul at parallels.com
Tue Oct 15 00:21:33 PDT 2013


On 10/13/2013 04:22 PM, Tikhomirov Pavel wrote:
> punch where coresponding data was updated in curent snapshot
> 
> Signed-off-by: Tikhomirov Pavel <snorcht at gmail.com>
> ---
>  cr-dedup.c         |   11 +++++++++++
>  include/cr-dedup.h |    9 +++++++++
>  2 files changed, 20 insertions(+)
> 
> diff --git a/cr-dedup.c b/cr-dedup.c
> index 25a3129..b76b7fb 100644
> --- a/cr-dedup.c
> +++ b/cr-dedup.c
> @@ -101,6 +101,17 @@ int _cr_dedup(int predump_fd, int pid)
>  		i_len = (long)(min(iov.iov_base + iov.iov_len, iov2.iov_base + iov2.iov_len)
>  			- max(iov.iov_base, iov2.iov_base));
>  
> +		if (i_len > 0 && !pr.pe->in_parent && !pr2.pe->in_parent) {
> +			/* punch */
> +			pr_info("Punch!/%lu/%lu/\n", off * PAGE_SIZE + i_off, i_len);
> +
> +			ret = fallocate(pr2.fd_pg, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, off * PAGE_SIZE + i_off, i_len);
> +			if (ret != 0) {
> +				pr_err("Error fallocate : %d\n", errno);

"Error punching hole"

> +				goto exit;
> +			}
> +		}
> +
>  		if (iov.iov_base + iov.iov_len == iov2.iov_base + iov2.iov_len) {
>  			ret = pr.get_pagemap(&pr, &iov);
>  			if (ret <= 0)
> diff --git a/include/cr-dedup.h b/include/cr-dedup.h
> index 3840a12..54a5ec9 100644
> --- a/include/cr-dedup.h
> +++ b/include/cr-dedup.h
> @@ -1,6 +1,15 @@
>  #ifndef __CR_DEDUP_H__
>  #define __CR_DEDUP_H__
>  
> +#define FALLOC_FL_KEEP_SIZE	0x01 /* default is extend size */
> +#define FALLOC_FL_PUNCH_HOLE	0x02 /* de-allocates range */

These two should be surrounded by #ifndef-s. Modern glibc-s do have these macros.

> +
> +struct to_punch{

Useless struct.

> +	struct list_head list;
> +	unsigned long off;
> +	unsigned long nr_pages;
> +};
> +
>  int cr_dedup(void);
>  
>  #endif
> 




More information about the CRIU mailing list