[CRIU] [PATCH CRIU v2 2/2] mount: separate private remount conditions for external and non-external

Andrew Vagin avagin at virtuozzo.com
Fri Jan 22 09:23:10 PST 2016


On Fri, Jan 22, 2016 at 03:29:54PM +0300, Pavel Tikhomirov wrote:
> We have two separate cases 1) mount is external - has mi->external set,
> 2) mount is internal - mi->external == 0. For those two cases we need
> separate decesions on making moutn private.
> 
> In both cases we need private remount if:
> a)mount does not have master_id and shared_id
> or
> b)if mount has different shared_id from bind source.
> 
> But do not private remount if has master_id or it will be lost. As after
> setting private the mount is alone in its shared group so setting master
> will silently fail as kernel can not find any for our mount.
> (see do_make_slave)
> 
> https://jira.sw.ru/browse/PSBM-42829
> 
> v2: rework patches 2/4 and 4/4 together and no need then in 3/4

Acked-by: Andrew Vagin <avagin at virtuozzo.com>

> Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
> ---
>  mount.c | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/mount.c b/mount.c
> index e267e10..c561b20 100644
> --- a/mount.c
> +++ b/mount.c
> @@ -2290,11 +2290,11 @@ static int do_bind_mount(struct mount_info *mi)
>  	char mnt_path_tmp[] = "/tmp/cr-tmpfs.XXXXXX";
>  	char mnt_path_root[] = "/cr-tmpfs.XXXXXX";
>  	char *root, *cut_root, rpath[PATH_MAX];
> -	bool force_private_remount = false;
>  	unsigned long mflags;
>  	int exit_code = -1;
>  	bool shared = false;
>  	bool master = false;
> +	bool private = false;
>  	char *mnt_path = NULL;
>  	struct stat st;
>  	bool umount_mnt_path = false;
> @@ -2313,12 +2313,13 @@ static int do_bind_mount(struct mount_info *mi)
>  		 * to proper location in the namespace we restore.
>  		 */
>  		root = mi->external->val;
> -		force_private_remount = mi->internal_sharing;
> +		private = !mi->master_id && (mi->internal_sharing || !mi->shared_id);
>  		goto do_bind;
>  	}
>  
>  	shared = mi->shared_id && mi->shared_id == mi->bind->shared_id;
>  	master = mi->master_id && mi->master_id == mi->bind->master_id;
> +	private = !mi->master_id && !shared;
>  	cut_root = cut_root_for_bind(mi->root, mi->bind->root);
>  
>  	if (list_empty(&mi->bind->children))
> @@ -2392,9 +2393,9 @@ static int do_bind_mount(struct mount_info *mi)
>  	 * shared - the mount is in the same shared group with mi->bind
>  	 * mi->shared_id && !shared - create a new shared group
>  	 */
> -	if (restore_shared_options(mi, force_private_remount || (!shared && !master),
> -					mi->shared_id && !shared,
> -					mi->master_id && !master))
> +	if (restore_shared_options(mi, private,
> +	                           mi->shared_id && !shared,
> +	                           mi->master_id && !master))
>  		return -1;
>  
>  	mi->mounted = true;
> -- 
> 1.9.3
> 


More information about the CRIU mailing list