[CRIU] [PATCH 1/2] mount: don't destruct an external mount-namespace

Andrew Vagin avagin at parallels.com
Thu Jul 4 04:41:08 EDT 2013


On Thu, Jul 04, 2013 at 03:27:12PM +0400, Pavel Emelyanov wrote:
> On 07/04/2013 03:21 PM, Andrey Vagin wrote:
> > If a parent mount point is shared with exteranl mntns, a child will be
> > umounted from the external mntns too.
> 
> I don't understand, please, elaborate.

Look at Documentation/filesystems/sharedsubtree.txt, there is
exmplanation and examples.

"""
A shared mount can be replicated to as many mountpoints and all the
replicas continue to be exactly same.
"""

# mount -t tmpfs xxx /root/tmp/
# mount --make-shared tmp
# mkdir tmp/xxx
# mount -t tmpfs xxx /root/tmp/xxx
# touch tmp/xxx/a

# unshare -m umount tmp/xxx
# ls -l tmp/xxx/a
ls: cannot access tmp/xxx/a: No such file or directory

Modern distributives mounts all fs-es as shared
$ cat /proc/self/mountinfo  | grep shared

> 
> > This patch changes a parent mnt to private for umounting childrens.
> > 
> > Signed-off-by: Andrey Vagin <avagin at openvz.org>
> > ---
> >  mount.c | 2 ++
> >  1 file changed, 2 insertions(+)
> > 
> > diff --git a/mount.c b/mount.c
> > index 9e64e4f..b0aaf51 100644
> > --- a/mount.c
> > +++ b/mount.c
> > @@ -634,6 +634,8 @@ static int do_umount_one(struct mount_info *mi)
> >  	if (!mi->parent)
> >  		return 0;
> >  
> > +	if ( mount("none", mi->parent->mountpoint, "none", MS_REC|MS_PRIVATE, NULL))
> > +		pr_perror("Can't mark %s as private", mi->parent->mountpoint);
> >  	if (umount(mi->mountpoint)) {
> >  		pr_perror("Can't umount at %s", mi->mountpoint);
> >  		return -1;
> > 
> 
> 


More information about the CRIU mailing list