[CRIU] [PATCH 1/2] dedup: make bunched auto-deduplication on restore for shmem

Pavel Emelyanov xemul at parallels.com
Tue Mar 11 11:26:22 PDT 2014


On 03/11/2014 11:07 AM, Tikhomirov Pavel wrote:
> in restore_shmem_content() put pe, fd, fd_pg into page_read struct
> 
> Signed-off-by: Tikhomirov Pavel <snorcht at gmail.com>
> ---
>  shmem.c | 59 +++++++++++++++++++++++++++++++++++++++--------------------
>  1 file changed, 39 insertions(+), 20 deletions(-)
> 
> diff --git a/shmem.c b/shmem.c
> index 2f8e7e9..ee79e85 100644
> --- a/shmem.c
> +++ b/shmem.c
> @@ -6,6 +6,7 @@
>  #include "pid.h"
>  #include "shmem.h"
>  #include "image.h"
> +#include "cr_options.h"
>  #include "page-pipe.h"
>  #include "page-xfer.h"
>  #include "rst-malloc.h"
> @@ -106,16 +107,22 @@ static int shmem_wait_and_open(int pid, struct shmem_info *si)
>  
>  static int restore_shmem_content(void *addr, struct shmem_info *si)
>  {
> -	int fd, fd_pg, ret = 0;
> -
> -	fd = open_image(CR_FD_SHMEM_PAGEMAP, O_RSTR, si->shmid);
> -	if (fd < 0) {
> -		fd_pg = open_image(CR_FD_SHM_PAGES_OLD, O_RSTR, si->shmid);
> -		if (fd_pg < 0)
> +	struct page_read pr;
> +	int ret = 0;
> +	unsigned long off_real = 0;
> +
> +	pr.bunch.iov_base = NULL;
> +	pr.bunch.iov_len = 0;
> +	pr.id = si->shmid;
> +
> +	pr.fd = open_image(CR_FD_SHMEM_PAGEMAP, opts.auto_dedup ? O_RDWR : O_RSTR, si->shmid);
> +	if (pr.fd < 0) {
> +		pr.fd_pg = open_image(CR_FD_SHM_PAGES_OLD, opts.auto_dedup ? O_RDWR : O_RSTR, si->shmid);

You're doing open_page_read() by hands. Please, don't. Update the function
to better suite your needs.

> +		if (pr.fd_pg < 0)
>  			goto err_unmap;
>  	} else {
> -		fd_pg = open_pages_image(O_RSTR, fd);
> -		if (fd_pg < 0)
> +		pr.fd_pg = open_pages_image(opts.auto_dedup ? O_RDWR : O_RSTR, pr.fd);
> +		if (pr.fd_pg < 0)
>  			goto out_close;
>  	}
>  


More information about the CRIU mailing list