[CRIU] [PATCH 3/4] mount: handle mnt_flags and sb_flags separatly

Andrew Vagin avagin at gmail.com
Fri Aug 14 03:55:39 PDT 2015


On Fri, Aug 14, 2015 at 01:06:32PM +0300, Pavel Emelyanov wrote:
> On 08/13/2015 09:05 PM, Andrew Vagin wrote:
> > On Thu, Aug 13, 2015 at 06:34:40PM +0300, Pavel Emelyanov wrote:
> >> On 08/11/2015 06:33 PM, Andrey Vagin wrote:
> >>> They both can container the MS_READONLY flag. And in one case it will be
> >>> read-only bind-mount and in another case it will be read-only
> >>> super-block.
> >>>
> >>> Signed-off-by: Andrey Vagin <avagin at openvz.org>
> >>> ---
> >>>  include/proc_parse.h |  1 +
> >>>  mount.c              | 27 +++++++++++++++++++--------
> >>>  proc_parse.c         |  2 +-
> >>>  protobuf/mnt.proto   |  2 ++
> >>>  4 files changed, 23 insertions(+), 9 deletions(-)
> >>>
> >>> diff --git a/include/proc_parse.h b/include/proc_parse.h
> >>> index 42f8893..ed68c95 100644
> >>> --- a/include/proc_parse.h
> >>> +++ b/include/proc_parse.h
> >>> @@ -118,6 +118,7 @@ struct mount_info {
> >>>  	char		*mountpoint;
> >>>  	char		*ns_mountpoint;
> >>>  	unsigned	flags;
> >>> +	unsigned	sb_flags;
> >>
> >> OK, let's look at random mountinfo entry
> >>
> >> 37 17 0:13 / /dev/mqueue rw,relatime shared:24 - mqueue mqueue rw
> >>
> >> The rw.relatime is mountpoint flags and the trailing rw is sb flags.
> >> In old version of criu wil restore relatime with the single mount()
> >> call. With this patch will mount mqueue with RW flag and then call
> >> remount(MS_REMOUNT | MS_BIND | MS_RELATIME). Will this create the
> >> same mountinfo entry?
> > 
> > No, it will not. We use MS_REMOUNT.
> > 
> > do_mount:
> > ...
> >         if (flags & MS_REMOUNT)
> >                 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
> >                                     data_page);
> >         else if (flags & MS_BIND)
> >                 retval = do_loopback(&path, dev_name, flags & MS_REC);
> > ...
> > 
> > do_remount
> > ...
> >         if (flags & MS_BIND)
> >                 err = change_mount_flags(path->mnt, flags);
> >         else if (!capable(CAP_SYS_ADMIN))
> >                 err = -EPERM;
> >         else
> >                 err = do_remount_sb(sb, flags, data, 0);
> > ....
> 
> So after the patch the whole mount tree will be restored differently as compared
> as it used to. Right?

No, I found only one flag which can be in both sets. It's MS_RDONLY.
do_mount() separates mount point flags and superblock flags

        /* Separate the per-mountpoint flags */
        if (flags & MS_NOSUID)
                mnt_flags |= MNT_NOSUID;
        if (flags & MS_NODEV)
                mnt_flags |= MNT_NODEV;
        if (flags & MS_NOEXEC)
                mnt_flags |= MNT_NOEXEC;
        if (flags & MS_NOATIME)
                mnt_flags |= MNT_NOATIME;
        if (flags & MS_NODIRATIME)
                mnt_flags |= MNT_NODIRATIME;
        if (flags & MS_STRICTATIME)
                mnt_flags &= ~(MNT_RELATIME | MNT_NOATIME);
        if (flags & MS_RDONLY)
                mnt_flags |= MNT_READONLY;
> 


More information about the CRIU mailing list