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

Pavel Emelyanov xemul at parallels.com
Thu Sep 10 04:39:47 PDT 2015


> @@ -1925,24 +1928,45 @@ skip_parent:
>  
>  static int do_new_mount(struct mount_info *mi)
>  {
> -	unsigned long mflags = MS_SHARED | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE;
> +	unsigned long sflags = mi->sb_flags;
> +	unsigned long mflags = mi->flags & (~MS_PROPAGATE);
>  	char *src;
>  	struct fstype *tp = mi->fstype;
> -	bool remount_ro = (tp->restore && mi->flags & MS_RDONLY);
> +	bool remount_ro = (tp->restore && mi->sb_flags & MS_RDONLY);

If we get here with old images then remount_ro will ALWAYS be false. Is it OK?

>  
>  	src = resolve_source(mi);
>  	if (!src)
>  		return -1;
>  
>  	if (remount_ro)
> -		mflags |= MS_RDONLY;
> +		sflags &= ~MS_RDONLY;
>  
> -	if (mount(src, mi->mountpoint, tp->name,
> -			mi->flags & ~mflags, mi->options) < 0) {
> +	/* Merge superblock and mount flags if it's posiable */
> +	if ((mflags & ~(MS_NOSUID | MS_NOEXEC | MS_NODEV | MS_NOATIME |
> +				MS_NODIRATIME | MS_RELATIME | MS_RDONLY)) &&
> +	    ((sflags & mflags) ^ MS_RDONLY)) {

I have a feeling that this is an attempt to handle the case when we get here
with zero sb_flags, but ... it does something more than just that. What?

> +		sflags |= mflags;
> +		mflags = 0;
> +	}
> +
> +	if (mount(src, mi->mountpoint, tp->name, sflags, mi->options) < 0) {
>  		pr_perror("Can't mount at %s", mi->mountpoint);
>  		return -1;
>  	}
>  
> +	if (tp->restore && tp->restore(mi))
> +		return -1;
> +
> +	if (remount_ro)
> +		return mount(NULL, mi->mountpoint, tp->name,
> +			     MS_REMOUNT | MS_RDONLY, NULL);
> +
> +	if (mflags && mount(NULL, mi->mountpoint, NULL,
> +				MS_REMOUNT | MS_BIND | mflags, NULL)) {
> +		pr_perror("Unable to apply bind-mount options\n");
> +		return -1;
> +	}
> +
>  	if (restore_shared_options(mi, !mi->shared_id && !mi->master_id,
>  					mi->shared_id,
>  					mi->master_id))

> @@ -2031,6 +2050,13 @@ do_bind:
>  			return -1;
>  		}
>  
> +		mflags = mi->flags & (~MS_PROPAGATE);
> +		if (!mi->bind || mflags != (mi->bind->flags & (~MS_PROPAGATE)))

What does this mean?

> +			if (mount(NULL, mi->mountpoint, NULL, MS_BIND | MS_REMOUNT | mflags, NULL)) {
> +				pr_perror("Can't mount at %s", mi->mountpoint);
> +				return -1;
> +			}
> +
>  		if (unlikely(mi->deleted)) {
>  			if (S_ISDIR(st.st_mode)) {
>  				if (rmdir(root)) {



More information about the CRIU mailing list