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

Pavel Emelyanov xemul at parallels.com
Wed Jul 10 06:52:48 EDT 2013


On 07/10/2013 12:40 PM, Andrew Vagin wrote:
> On Tue, Jul 09, 2013 at 08:41:34PM +0400, Pavel Emelyanov wrote:
>> On 07/09/2013 03:05 PM, Andrey Vagin wrote:
>>> A non-root mount is bind-mounted to a proper root mount.
>>>
>>> Non-root mount without root mount is not supported yet
>>>
>>> Signed-off-by: Andrey Vagin <avagin at openvz.org>
>>> ---
>>>  include/proc_parse.h |  2 ++
>>>  mount.c              | 75 +++++++++++++++++++++++++++++++++++++---------------
>>>  2 files changed, 55 insertions(+), 22 deletions(-)
>>>
>>> diff --git a/include/proc_parse.h b/include/proc_parse.h
>>> index 99255c4..1325424 100644
>>> --- a/include/proc_parse.h
>>> +++ b/include/proc_parse.h
>>> @@ -114,9 +114,11 @@ struct mount_info {
>>>  
>>>  	/* tree linkage */
>>>  	struct mount_info *parent;
>>> +	struct mount_info *bind;
>>>  	struct list_head children;
>>>  	struct list_head siblings;
>>>  
>>> +	struct list_head mnt_bind;
>>
>> Document the fields please.
>>
>>>  	struct list_head mnt_share;	/* circular list of shared mounts */
>>>  	struct list_head mnt_slave_list;/* list of slave mounts */
>>>  	struct list_head mnt_slave;	/* slave list entry */
>>> diff --git a/mount.c b/mount.c
>>> index 640cd12..31b1f3c 100644
>>> --- a/mount.c
>>> +++ b/mount.c
>>> @@ -77,6 +77,16 @@ struct mount_info *lookup_mnt_sdev(unsigned int s_dev)
>>>  	return NULL;
>>>  }
>>>  
>>> +/* two bind-mounts are reported as equal if bind is true */
>>> +static bool mntcmp(struct mount_info* mi, struct mount_info *c, bool bind)
>>> +{
>>> +	return (mi->s_dev == c->s_dev &&
>>> +		(bind || !strcmp(c->root, mi->root)) &&
>>
>> I see no callers of these with bind == true. Where is it?
> 
> in the next patches
> 
>>
>>> +		!strcmp(c->source, mi->source) &&
>>> +		!strcmp(c->options, mi->options) &&
> 
> ...
>>> +
>>> +		/* Search bind-mounts */
>>> +		if (list_empty(&m->mnt_bind))
>>> +			for (t = m->next; t; t = t->next) {
>>> +				if (mntcmp(m, t, true))
>>> +					list_add(&t->mnt_bind, &m->mnt_bind);
>>
>> I don't understand what the mnt_bind list links together.
> 
> It links together all mounts, which are the same except root. Only one

What does "mounts are the same" mean?

> of them must be mounted and all other can be bind-mounted
> 
>>
>>> +			}
>>>  	}
>>>  
>>>  	return 0;
>>> @@ -432,16 +465,6 @@ static struct fstype *decode_fstype(u32 fst)
>>>  	return &fstypes[fst];
>>>  }
>>>  
> .
> 




More information about the CRIU mailing list