[CRIU] [PATCH 9/9] mounts: handle bind-mounts

Pavel Emelyanov xemul at parallels.com
Thu Jul 25 07:02:37 EDT 2013


On 07/24/2013 12:10 PM, Andrey Vagin wrote:
> A non-root mount is bind-mounted from a proper root mount.
> 
> Non-root mount without root mount is not supported yet
> 
> Signed-off-by: Andrey Vagin <avagin at openvz.org>
> ---
>  mount.c | 42 +++++++++++++++++++++++++++++++-----------
>  1 file changed, 31 insertions(+), 11 deletions(-)
> 
> diff --git a/mount.c b/mount.c
> index 8016dcc..3ede19a 100644
> --- a/mount.c
> +++ b/mount.c
> @@ -224,13 +224,20 @@ static int collect_shared(struct mount_info *info)
>  				list_add(&t->mnt_share, &m->mnt_share);
>  			}
>  		}
> -		if (!need_master)
> -			continue;
>  
> -		pr_err("Mount %d (master_id: %d shared_id: %d) "
> -		       "has unreachable sharing\n", m->mnt_id,
> -			m->master_id, m->shared_id);
> -		return -1;
> +		if (need_master) {
> +			pr_err("Mount %d (master_id: %d shared_id: %d) "
> +			       "has unreachable sharing\n", m->mnt_id,
> +				m->master_id, m->shared_id);
> +			return -1;
> +		}
> +
> +		/* Search bind-mounts */
> +		if (list_empty(&m->mnt_bind))
> +			for (t = m->next; t; t = t->next) {
> +				if (mounts_equal(m, t, true))
> +					list_add(&t->mnt_bind, &m->mnt_bind);
> +			}
>  	}
>  
>  	return 0;
> @@ -703,6 +710,11 @@ static int propagate_siblings(struct mount_info *mi)
>  	return 0;
>  }
>  
> +static inline int fsroot_mounted(struct mount_info *mi)
> +{
> +	return is_root(mi->root);
> +}
> +
>  static int propagate_mount(struct mount_info *mi)
>  {
>  	struct mount_info *t;
> @@ -725,6 +737,19 @@ static int propagate_mount(struct mount_info *mi)
>  		}
>  	}
>  
> +	/*
> +	 * FIXME Currently non-root mounts can be restored
> +	 * only if a proper root mount exists
> +	 */

Need comment why t->bind assignment is here, not in the collect_shared, where you
link them together.

> +	if (fsroot_mounted(mi))
> +		list_for_each_entry(t, &mi->mnt_bind, mnt_bind) {
> +			if (t->bind)
> +				continue;
> +			if (t->master_id)
> +				continue;
> +			t->bind = mi;
> +		}
> +
>  	return 0;
>  }
>  
> @@ -799,11 +824,6 @@ static int do_bind_mount(struct mount_info *mi)
>  	return 0;
>  }
>  
> -static inline int fsroot_mounted(struct mount_info *mi)
> -{
> -	return is_root(mi->root);
> -}
> -
>  static int do_mount_one(struct mount_info *mi)
>  {
>  	int ret;
> 




More information about the CRIU mailing list