[CRIU] [PATCH 1/2] mount: execute propagation logic for the root mount

Pavel Emelyanov xemul at parallels.com
Thu Mar 20 02:27:09 PDT 2014


On 03/18/2014 11:46 PM, Andrey Vagin wrote:

> @@ -1009,14 +1008,24 @@ static int propagate_mount(struct mount_info *mi)
>  		struct mount_info *c;
>  
>  		list_for_each_entry(c, &t->children, siblings) {
> -			if (mounts_equal(mi, c, false)) {
> -				pr_debug("\t\tPropogate %s\n", c->mountpoint);
> -				c->mounted = true;
> -				propagate_siblings(c);
> -				umount_from_slaves(c);
> -			}
> +			if (!mounts_equal(mi, c, false))
> +				continue;
> +			pr_debug("\t\tPropogate %s\n", c->mountpoint);
> +			c->mounted = true;
> +			propagate_siblings(c);
> +			umount_from_slaves(c);
>  		}
>  	}
> +}
> +
> +static int propagate_mount(struct mount_info *mi)

What's the point in splitting this function? You don't call the propagate_over_parents()
separately anywhere.

> +{
> +	struct mount_info *t;
> +
> +	propagate_siblings(mi);
> +
> +	if (mi->parent)
> +		propagate_over_parents(mi);
>  
>  	/*
>  	 * FIXME Currently non-root mounts can be restored
> @@ -1140,16 +1149,29 @@ static bool can_mount_now(struct mount_info *mi)
>  	return false;
>  }
>  
> +static int do_mount_root(struct mount_info *mi)
> +{
> +	if (restore_shared_options(mi, 0, mi->shared_id, mi->master_id))
> +		return -1;
> +
> +	if (propagate_mount(mi))
> +		return -1;
> +
> +	mi->mounted = true;
> +
> +	return 0;
> +}
> +
>  static int do_mount_one(struct mount_info *mi)
>  {
>  	int ret;
>  
> -	if (!mi->parent)
> -		return 0;
> -
>  	if (mi->mounted)
>  		return 0;
>  
> +	if (!mi->parent)
> +		return do_mount_root(mi);

Can we move this below can_mount_now() and make it look like

if (!mi->parent)
	ret = do_mount_root()
else if (!mi->bind && !mi->need_plugin)
	ret = do_new_mount()
else
	ret = do_bind_mount()

if (ret == 0 && propagate_mount())
	ret = -1;

?

This would eliminate the call to propagate_mount() from do_mount_root().

> +
>  	if (!can_mount_now(mi)) {
>  		pr_debug("Postpone slave %s\n", mi->mountpoint);
>  		return 1;
> 


Thanks,
Pavel


More information about the CRIU mailing list