[CRIU] [PATCH 14/14] mount: don't open the same root twise

Pavel Emelyanov xemul at parallels.com
Fri Apr 18 02:51:30 PDT 2014


On 04/18/2014 01:21 PM, Andrew Vagin wrote:
> On Fri, Apr 18, 2014 at 12:42:34PM +0400, Pavel Emelyanov wrote:
>> On 04/17/2014 11:24 PM, Andrey Vagin wrote:
>>> Signed-off-by: Andrey Vagin <avagin at openvz.org>
>>> ---
>>>  mount.c | 7 +++++++
>>>  1 file changed, 7 insertions(+)
>>>
>>> diff --git a/mount.c b/mount.c
>>> index 92c6a6c..72ec81d 100644
>>> --- a/mount.c
>>> +++ b/mount.c
>>> @@ -1789,10 +1789,15 @@ out:
>>>  
>>>  int mntns_collect_root(pid_t pid)
>>>  {
>>> +	static int mntns_root_pid = -1;
>>> +
>>>  	int fd, pfd;
>>>  	int ret;
>>>  	char path[PATH_MAX + 1];
>>>  
>>> +	if (mntns_root_pid == pid) /* The required root is already opened */
>>> +		return get_service_fd(ROOT_FD_OFF);
>>> +
>>>  	close_service_fd(ROOT_FD_OFF);
>>>  
>>>  	if (!(root_ns_mask & CLONE_NEWNS)) {
>>> @@ -1841,6 +1846,8 @@ int mntns_collect_root(pid_t pid)
>>>  
>>>  set_root:
>>>  	ret = install_service_fd(ROOT_FD_OFF, fd);
>>> +	if (ret >= 0)
>>> +		mntns_root_pid = pid;
>>
>> If we're going to get mntns root fd always, I see no sense in service
>> FD. It's like open_proc_fd thing.
> 
> It's service fd to avoid conflicts with restored descriptors.

Ah, open_proc_fd one is not such. OK, I like the series then.


More information about the CRIU mailing list