[CRIU] [PATCH 1/3] page-read: Do not lseek file to get its current position

Mike Rapoport rppt at linux.vnet.ibm.com
Wed Nov 9 10:39:17 PST 2016


On Mon, Nov 07, 2016 at 07:02:50PM +0300, Pavel Emelyanov wrote:
> It's already written into page_read->pi_off, so just use one.
> 
> Signed-off-by: Pavel Emelyanov <xemul at virtuozzo.com>

Acked-by: Mike Rapoport <rppt at linux.vnet.ibm.com>

> ---
>  criu/pagemap.c | 11 +++++------
>  1 file changed, 5 insertions(+), 6 deletions(-)
> 
> diff --git a/criu/pagemap.c b/criu/pagemap.c
> index 105ad59..cfc9659 100644
> --- a/criu/pagemap.c
> +++ b/criu/pagemap.c
> @@ -260,23 +260,22 @@ static int read_pagemap_page(struct page_read *pr, unsigned long vaddr, int nr,
>  		BUG();
>  	} else {
>  		int fd = img_raw_fd(pr->pi);
> -		off_t current_vaddr = lseek(fd, pr->pi_off, SEEK_SET);
> 
> -		pr_debug("\tpr%u Read page from self %lx/%"PRIx64"\n", pr->id, pr->cvaddr, current_vaddr);
> -		ret = read(fd, buf, len);
> +		pr_debug("\tpr%u Read page from self %lx/%"PRIx64"\n", pr->id, pr->cvaddr, pr->pi_off);
> +		ret = pread(fd, buf, len, pr->pi_off);
>  		if (ret != len) {
>  			pr_perror("Can't read mapping page %d", ret);
>  			return -1;
>  		}
> 
> -		pr->pi_off += len;
> -
>  		if (opts.auto_dedup) {
> -			ret = punch_hole(pr, current_vaddr, len, false);
> +			ret = punch_hole(pr, pr->pi_off, len, false);
>  			if (ret == -1) {
>  				return -1;
>  			}
>  		}
> +
> +		pr->pi_off += len;
>  	}
> 
>  	pr->cvaddr += len;
> -- 
> 2.1.4
> 
> _______________________________________________
> CRIU mailing list
> CRIU at openvz.org
> https://lists.openvz.org/mailman/listinfo/criu
> 



More information about the CRIU mailing list