[CRIU] [PATCH 7/9] mounts: if a mount can't be mounted, it is queued in postpone list
Andrew Vagin
avagin at parallels.com
Mon Jul 15 04:00:39 EDT 2013
On Mon, Jul 15, 2013 at 11:25:50AM +0400, Andrew Vagin wrote:
> On Tue, Jul 09, 2013 at 08:44:07PM +0400, Pavel Emelyanov wrote:
> > On 07/09/2013 03:05 PM, Andrey Vagin wrote:
> > > Try to restore mounts while a postpone list isn't empty and check
> > > that each iteration has some progress, otherwice it will fails for
> > > preventing infinite loops
> > >
> > > Signed-off-by: Andrey Vagin <avagin at openvz.org>
> > > ---
> > > include/proc_parse.h | 2 ++
> > > mount.c | 40 ++++++++++++++++++++++++++++++++++++----
> > > 2 files changed, 38 insertions(+), 4 deletions(-)
> > >
> > > diff --git a/include/proc_parse.h b/include/proc_parse.h
> > > index 1325424..85bde36 100644
> > > --- a/include/proc_parse.h
> > > +++ b/include/proc_parse.h
> > > @@ -123,6 +123,8 @@ struct mount_info {
> > > struct list_head mnt_slave_list;/* list of slave mounts */
> > > struct list_head mnt_slave; /* slave list entry */
> > > struct mount_info *mnt_master; /* slave is on master->mnt_slave_list */
> > > +
> > > + struct list_head postpone;
> > > };
> > >
> > > struct proc_posix_timer {
> > > diff --git a/mount.c b/mount.c
> > > index 0609ded..fae9513 100644
> > > --- a/mount.c
> > > +++ b/mount.c
> > > @@ -533,12 +533,25 @@ int dump_mnt_ns(int ns_pid, struct cr_fdset *fdset)
> > > return 0;
> > > }
> > >
> > > -#define MNT_TREE_WALK(_r, _el, _fn_f, _fn_r) do { \
> > > +static int mount_progress;
> > > +
> > > +#define MNT_TREE_WALK(_r, _el, _fn_f, _fn_r, _plist) do { \
> > > struct mount_info *_mi = _r; \
> > > \
> > > while (1) { \
> > > - if (_fn_f(_mi)) \
> > > + int ret; \
> > > + \
> > > + ret = _fn_f(_mi); \
> > > + if (ret < 0) \
> > > return -1; \
> > > + else if (ret > 0) { \
> > > + list_add_tail(&_mi->postpone, _plist); \
> >
> > _plist can be NULL here, can't it?
>
> No, it can't.
>
> For example clean_mnt_ns sets _plist = NULL, but _fn_f always returns 0
> in this case.
>
Actually I don't like this part too, but MNT_TREE_WALK is a macros and
if we will check _plist here, gcc will say something like this
(26 of 73): error: the address of ‘postpone’ will always evaluate as ‘true’
We know that if _plist is NULL, _fn_f can't return positive value. I'm
goint to write this in a comment before this macros.
> >
More information about the CRIU
mailing list