[CRIU] [PATCHv0 4/4] files-reg: move remaps unlink code into single function

Eugene Batalov eabatalov89 at gmail.com
Tue Jun 28 09:01:13 PDT 2016


2016-06-28 16:32 GMT+03:00 Pavel Emelyanov <xemul at virtuozzo.com>:

> On 06/24/2016 11:38 PM, Eugene Batalov wrote:
> > Signed-off-by: Eugene Batalov <eabatalov89 at gmail.com>
> > ---
> >  criu/files-reg.c | 34 +++++++++++++++++++++++-----------
> >  1 file changed, 23 insertions(+), 11 deletions(-)
> >
> > diff --git a/criu/files-reg.c b/criu/files-reg.c
> > index 2f1c695..2b6a876 100644
> > --- a/criu/files-reg.c
> > +++ b/criu/files-reg.c
> > @@ -522,6 +522,26 @@ static void try_clean_ghost(struct remap_info *ri)
> >       pr_perror(" `- XFail [%s] ghost", path);
> >  }
> >
> > +static int clean_one_remap(struct file_remap *remap, int rmntns_root)
> > +{
> > +     int ret = 0;
> > +     if (rmntns_root == -1)
> > +             rmntns_root = mntns_get_root_by_mnt_id(remap->rmnt_id);
> > +
> > +     if (rmntns_root < 0)
> > +             return -1;
> > +
> > +     pr_info("Unlink remap %s\n", remap->rpath);
> > +
> > +     ret = unlinkat(rmntns_root, remap->rpath, remap->is_dir ?
> AT_REMOVEDIR : 0);
> > +     if (ret < 0) {
> > +             pr_perror("Couldn't unlink remap %s", remap->rpath);
> > +             return -1;
> > +     }
> > +
> > +     return 0;
> > +}
> > +
> >  void try_clean_remaps(int ns_fd)
> >  {
> >       struct remap_info *ri;
> > @@ -647,14 +667,8 @@ static int dump_ghost_file(int _fd, u32 id, const
> struct stat *st, dev_t phys_de
> >  void remap_put(struct file_remap *remap)
> >  {
> >       mutex_lock(ghost_file_mutex);
> > -     if (--remap->users == 0) {
> > -             int mntns_root;
> > -
> > -             pr_info("Unlink the ghost %s\n", remap->rpath);
> > -
> > -             mntns_root = mntns_get_root_by_mnt_id(remap->rmnt_id);
> > -             unlinkat(mntns_root, remap->rpath, 0);
> > -     }
> > +     if (--remap->users == 0)
> > +             clean_one_remap(remap, -1);
> >       mutex_unlock(ghost_file_mutex);
> >  }
> >
> > @@ -1514,9 +1528,7 @@ ext:
> >
> >               BUG_ON(!rfi->remap->users);
> >               if (--rfi->remap->users == 0) {
> > -                     pr_info("Unlink the ghost %s\n",
> rfi->remap->rpath);
> > -                     mntns_root =
> mntns_get_root_by_mnt_id(rfi->remap->rmnt_id);
> > -                     unlinkat(mntns_root, rfi->remap->rpath,
> rfi->remap->is_dir ? AT_REMOVEDIR : 0);
> > +                     clean_one_remap(rfi->remap, mntns_root);
>
> You change the behavior -- originall the mntns_root was re-initialized, but
> this patch forces it to get reused. Is that OK?
>
No it's not right.
mntns_root before this hunk is initialized from rfi->rfe->mnt_id but in
this hunk it should be initialized from rfi->remap->rmnt_id.
I've overlooked this very small patch. It is part of a bigger patchset.
Sorry. Will resend proper version (v2) soon.


> >               }
> >
> >               mutex_unlock(ghost_file_mutex);
> >
>
>


-- 
Best regards,
Eugene Batalov.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openvz.org/pipermail/criu/attachments/20160628/ed69b89b/attachment.html>


More information about the CRIU mailing list