[CRIU] [PATCH 7/9] mount: add the mnt_roots mount in the mount tree on restore

Pavel Emelyanov xemul at parallels.com
Wed Nov 5 08:57:44 PST 2014


On 10/23/2014 05:49 PM, Andrey Vagin wrote:
> Currently we connect roots of sub-namespaces to the root of the root
> mount namespace. And we get problems, if the root of the root mntns is
> shared, because all children of a shared mount must be propagated to
> other mounts in this group.
> 
> Actually we mount tmpfs in mnt_roots and here is nothing wrong to add it
> in a tree.

What problems do we solve with this trick?

> Signed-off-by: Andrey Vagin <avagin at openvz.org>
> ---
>  mount.c | 30 +++++++++++++++++++++++-------
>  1 file changed, 23 insertions(+), 7 deletions(-)
> 
> diff --git a/mount.c b/mount.c
> index 7ccdef3..fe33b51 100644
> --- a/mount.c
> +++ b/mount.c
> @@ -238,9 +238,26 @@ static bool mounts_equal(struct mount_info* mi, struct mount_info *c, bool bind)
>  	return true;
>  }
>  
> +/*
> + * mnt_roots is a temporary directory for restoring sub-trees of
> + * non-root namespaces.
> + */
> +static char *mnt_roots;
> +
>  static struct mount_info *mnt_build_ids_tree(struct mount_info *list)
>  {
>  	struct mount_info *m, *root = NULL;
> +	struct mount_info *tmp_root_mount = NULL;
> +
> +	if (mnt_roots) {
> +		/* mnt_roots is a tmpfs mount and it's private */
> +		tmp_root_mount = mnt_entry_alloc();
> +		if (!tmp_root_mount)
> +			return NULL;
> +
> +		tmp_root_mount->mountpoint = mnt_roots;
> +		tmp_root_mount->mounted = true;
> +	}
>  
>  	/*
>  	 * Just resolve the mnt_id:parent_mnt_id relations
> @@ -280,7 +297,7 @@ static struct mount_info *mnt_build_ids_tree(struct mount_info *list)
>  				 * root mount namespace, so its parent is
>  				 * the main root.
>  				 */
> -				p = root;
> +				p = tmp_root_mount;
>  			} else
>  				return NULL;
>  		}
> @@ -294,6 +311,11 @@ static struct mount_info *mnt_build_ids_tree(struct mount_info *list)
>  		return NULL;
>  	}
>  
> +	if (mnt_roots) {
> +		tmp_root_mount->parent = root;
> +		list_add_tail(&tmp_root_mount->siblings, &root->children);
> +	}
> +
>  	return root;
>  }
>  
> @@ -1628,12 +1650,6 @@ void mnt_entry_free(struct mount_info *mi)
>  }
>  
>  /*
> - * mnt_roots is a temporary directory for restoring sub-trees of
> - * non-root namespaces.
> - */
> -static char *mnt_roots;
> -
> -/*
>   * Helper for getting a path to where the namespace's root
>   * is re-constructed.
>   */
> 



More information about the CRIU mailing list