[CRIU] [PATCH 10/14]v3 deduplication: add punching holes in "parent"

Kir Kolyshkin kir at parallels.com
Thu Dec 19 13:39:26 PST 2013


On 12/17/2013 07:27 AM, Tikhomirov Pavel wrote:
> punch where coresponding data was updated in curent snapshot
>
> Signed-off-by: Tikhomirov Pavel <snorcht at gmail.com>
> ---
>   cr-dedup.c |   13 +++++++++++++
>   1 file changed, 13 insertions(+)
>
> diff --git a/cr-dedup.c b/cr-dedup.c
> index 7c19d48..3cd349a 100644
> --- a/cr-dedup.c
> +++ b/cr-dedup.c
> @@ -1,4 +1,6 @@
>   #include <sys/uio.h>
> +#include <fcntl.h>
> +#include <linux/falloc.h>
>   #include <unistd.h>
>   
>   #include "crtools.h"
> @@ -102,6 +104,7 @@ exit:
>   int dedup_one_iovec(struct page_read *pr, struct iovec *iov)
>   {
>   	unsigned long off;
> +	unsigned long off_real;
>   	unsigned long iov_end;
>   
>   	iov_end = (unsigned long)iov->iov_base + iov->iov_len;
> @@ -125,6 +128,16 @@ int dedup_one_iovec(struct page_read *pr, struct iovec *iov)
>   			return -1;
>   		pagemap2iovec(pr->pe, &piov);
>   		piov_end = (unsigned long)piov.iov_base + piov.iov_len;
> +		off_real = lseek(pr->fd_pg, 0, SEEK_CUR);
> +		if (!pr->pe->in_parent) {
> +			pr_debug("Punch!/%lu/%lu/\n", off_real, min(piov_end, iov_end) - off);
> +			ret = fallocate(pr->fd_pg, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE,
> +					off_real, min(piov_end, iov_end) - off);
> +			if (ret != 0) {
> +				pr_perror("Error punching hole : %d", errno);

It will end up printing something like this:

     Error punching hole : 22: Invalid argument

I think it's better to not use a numeric value of errno here, since
pr_perror() already prints a corresponding string. So I suggest to
use

     pr_perror("Error punching hole");

which will print something like

     Error punching hole: Invalid argument

(and you can easily guess that it is EINVAL).

NOTE this applies to other patches in this series.

> +				return -1;
> +			}
> +		}
>   
>   		if (piov_end < iov_end) {
>   			off = piov_end;



More information about the CRIU mailing list