[CRIU] AUFS Support in CRIU

Saied Kazemi saied at google.com
Wed Aug 20 09:54:08 PDT 2014


On Wed, Aug 20, 2014 at 3:39 AM, Pavel Emelyanov <xemul at parallels.com>
wrote:

> On 08/20/2014 10:21 AM, Saied Kazemi wrote:
>
> >     > Thanks again for your feedback.  I hope the answers are clear.  If
> it's easier or more productive,
> >     > I am available on video chat to discuss in greater detail.  My
> schedule is flexible, so time
> >     > difference shouldn't be a problem.
> >
> >     OK, I'll keep that in mind :) Your timezone is US Pacific one, right?
> >
> >
> > Yes, I am in Mountain View.
> >
> > Looking forward to your comments on this patch which I think has
> addressed everything above.
>
> Yup, I think this patch is perfect. Only one question left:
>

Great!



>
> > @@ -240,6 +244,31 @@ static int vma_get_mapfile(struct vma_area *vma,
> DIR *mfd,
> >                       vma->vm_socket_id = buf.st_ino;
> >               } else if (errno != ENOENT)
> >                       return -1;
> > +     } else if (opts.aufs) {
> > +             /*
> > +              * AUFS support to compensate for the kernel bug
> > +              * exposing branch pathnames in map_files.
> > +              *
> > +              * If the link points inside a branch, replace it
> > +              * with a pathname from the root for later use in
> > +              * dump_filemap().
> > +              */
> > +             char p[PATH_MAX];
> > +             int n;
> > +
> > +             p[0] = '.';
> > +             n = read_fd_link(vma->vm_file_fd, &p[1], sizeof p - 1);
> > +             if (n < 0)
> > +                     return -1;
> > +             n = fixup_aufs_path(&p[1], sizeof p - 1, true);
> > +             if (n < 0)
> > +                     return -1;
> > +             if (n > 0) {
> > +                     vma->aufs_rpath = xmalloc(n + 2);
> > +                     if (!vma->aufs_rpath)
> > +                             return -1;
> > +                     strcpy(vma->aufs_rpath, p);
> > +             }
> >       }
> >
> >       return 0;
> > @@ -450,12 +479,24 @@ int parse_smaps(pid_t pid, struct vm_area_list
> *vma_area_list, bool use_map_file
> >                       vma_area->st = prev->st;
> >               } else if (vma_area->vm_file_fd >= 0) {
> >                       struct stat *st_buf;
> > +                     char *f;
> >
> >                       st_buf = vma_area->st = xmalloc(sizeof(*st_buf));
> >                       if (!st_buf)
> >                               goto err;
> >
> > -                     if (fstat(vma_area->vm_file_fd, st_buf) < 0) {
> > +                     /*
> > +                      * For AUFS support, we cannot fstat() a file
> descriptor that
> > +                      * is a symbolic link to a branch.  Instead, we
> obtain the
> > +                      * pathname of the file from the root and use
> stat().
> > +                      */
> > +                     if (opts.aufs && (f =
> fixup_aufs_fd_path(vma_area->vm_file_fd))) {
> > +                             if (stat(f, st_buf) < 0) {
> > +                                     pr_perror("Failed stat on %d's map
> %lu (%s)",
> > +                                             pid, start, f);
> > +                                     goto err;
> > +                             }
> > +                     } else if (fstat(vma_area->vm_file_fd, st_buf) <
> 0) {
> >                               pr_perror("Failed fstat on %d's map %lu",
> pid, start);
> >                               goto err;
> >                       }
>
> Why do we need the 2nd call to fixup branch name? Can't we just stat
> the vma->aufs_rpath here?
>

That's because vma->aufs_rpath is relative from the root of the mount
namespace (e.g., ./bin/busybox) but we are not in that directory (we're in
/).  To avoid calling fixup we can construct the full path by prepending
aufs_root as follows:

-                       if (opts.aufs && (f =
> fixup_aufs_fd_path(vma_area->vm_file_fd))) {
> -                               if (stat(f, st_buf) < 0) {
> +                       if (opts.aufs && vma_area->aufs_rpath &&
> opts.aufs_root) {
> +                               char path[PATH_MAX];
> +                               int n;
> +
> +                               n = snprintf(path, PATH_MAX, "%s/%s",
> opts.aufs_root, vma_area->aufs_rpath);
> +                               if (n >= PATH_MAX) {
> +                                       pr_err("Path %s/%s too long\n",
> opts.aufs_root, vma_area->aufs_rpath);
> +                                       goto err;
> +                               }
> +                               if (stat(path, st_buf) < 0) {
>

If you prefer this approach, I will send you a new patch with this change
and removal of fixup_aufs_fd_path().

Cheers!

--Saied
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openvz.org/pipermail/criu/attachments/20140820/3ff51473/attachment-0001.html>


More information about the CRIU mailing list