[CRIU] [PATCH] Punch holes in input files when restoring anonymous non-shared memory if --auto-dedup is enabled.

Paweł Stradomski pstradomski at google.com
Mon Jul 30 19:18:21 MSK 2018


pt., 27 lip 2018 o 04:00 Andrei Vagin <avagin at virtuozzo.com> wrote:
> Applied, thanks! Here is one in-line comment
>
> > --- a/criu/mem.c
> > +++ b/criu/mem.c
> > @@ -1271,7 +1271,11 @@ static int prepare_vma_ios(struct pstree_item *t, struct task_restore_args *ta)
> >  {
> >       struct cr_img *pages;
> >
> > -     pages = open_image(CR_FD_PAGES, O_RSTR, rsti(t)->pages_img_id);
> > +     /* if auto-dedup is on we need RDWR mode to be able to punch holes
> > +      * in the input files (in restorer.c)
> > +      */
> > +     pages = open_image(CR_FD_PAGES, opts.auto_dedup ? O_RDWR : O_RSTR,
> > +                             rsti(t)->pages_img_id);
>
> This doesn't work for userns tests:
>
> CRIU opens an image from a target userns and fails to open it for read-write:
> -rw-r--r-- 1 root root 106496 Jul 27 04:54 test/dump/zdtm/static/env00/43/1/pages-1.img
>
> Probably, we need to use userns_call() to open images in this case.

I've added fallback to opening read-only if read-write fails.
userns_call seems like a good idea, but given that open_image not only
opens file but also allocates a few objects, we'd need to break it
apart first. I'd like to do that in a separate commit.

-- 
Paweł Stradomski



More information about the CRIU mailing list