[CRIU] [PATCH 3/3] mount: wait when mntns will be created to get its root

Pavel Emelyanov xemul at parallels.com
Fri Nov 13 11:40:12 PST 2015


On 11/13/2015 08:59 PM, Andrew Vagin wrote:
> On Fri, Nov 13, 2015 at 07:58:26PM +0300, Pavel Emelyanov wrote:
>> On 11/13/2015 05:56 PM, Andrey Vagin wrote:
>>> From: Andrew Vagin <avagin at virtuozzo.com>
>>>
>>> Reported-by: Andrey Ryabinin <aryabinin at virtuozzo.com>
>>> Signed-off-by: Andrew Vagin <avagin at virtuozzo.com>
>>> ---
>>>  mount.c      | 2 ++
>>>  namespaces.c | 1 +
>>>  2 files changed, 3 insertions(+)
>>>
>>> diff --git a/mount.c b/mount.c
>>> index 9666e5a..df1fdf9 100644
>>> --- a/mount.c
>>> +++ b/mount.c
>>> @@ -2929,6 +2929,8 @@ set_root:
>>>  
>>>  int mntns_get_root_fd(struct ns_id *mntns)
>>>  {
>>> +	if (mntns->type != NS_ROOT)
>>> +		futex_wait_while_eq(&mntns->ns_created, 0);
>>
>> Huh? All the namespaces are "created" by root task before forking
>> the others in patch #2.
> 
> Their file descriptors will be closed in close_old_fds(), so we need to
> open /proc/pid/root to get a namespace root.

I still don't get. What's the calls in non-root process that lead to the
need to wait for mntns to be created?

>>
>>>  	return __mntns_get_root_fd(mntns->ns_pid);
>>>  }
>>>  
>>> diff --git a/namespaces.c b/namespaces.c
>>> index 1123492..a2293c3 100644
>>> --- a/namespaces.c
>>> +++ b/namespaces.c
>>> @@ -268,6 +268,7 @@ static unsigned int generate_ns_id(int pid, unsigned int kid, struct ns_desc *nd
>>>  
>>>  	nsid->type = type;
>>>  	nsid->kid = kid;
>>> +	futex_set(&nsid->ns_created, 1);
>>>  	nsid_add(nsid, nd, ns_next_id++, pid);
>>>  
>>>  found:
>>>
>>
> .
> 



More information about the CRIU mailing list