autofs: use temporary value for virtual pgrp on dump

Submitted by Stanislav Kinsburskiy on April 20, 2016, 4:31 p.m.

Details

Message ID 20160420163118.8998.66134.stgit@skinsbursky-vz7.qa.sw.ru
State Accepted
Series "autofs: use temporary value for virtual pgrp on dump"
Commit 7a0d09511da2a771246e2650a3c18efecd8a86bd
Headers show

Patch hide | download patch | download mbox

diff --git a/criu/autofs.c b/criu/autofs.c
index 8befc62..816a386 100644
--- a/criu/autofs.c
+++ b/criu/autofs.c
@@ -290,7 +290,7 @@  static int autofs_create_entry(struct mount_info *pm, AutofsEntry *entry)
 		entry->has_gid = true;
 
 	if (entry->fd != AUTOFS_CATATONIC_FD) {
-		int found, read_fd;
+		int found, read_fd, virt_pgrp;
 
 		read_fd = autofs_find_read_fd(entry->pgrp, pipe_ino);
 		if (read_fd < 0)
@@ -310,13 +310,14 @@  static int autofs_create_entry(struct mount_info *pm, AutofsEntry *entry)
 		}
 
 		/* We need to get virtual pgrp to restore mount */
-		entry->pgrp = pid_to_virt(entry->pgrp);
-		if (!entry->pgrp) {
+		virt_pgrp = pid_to_virt(entry->pgrp);
+		if (!virt_pgrp) {
 			pr_err("failed to find pstree item with pid %d\n",
 					entry->pgrp);
 			pr_err("Non-catatonic mount without master?\n");
 			return -1;
 		}
+		entry->pgrp = virt_pgrp;
 	}
 	return 0;
 }

Comments

Pavel Emelianov April 22, 2016, 1:34 p.m.
On 04/20/2016 07:31 PM, Stanislav Kinsburskiy wrote:
> Otherwise information about real pid is lost in case of pid_to_virt returned
> zero.

But if pid_to_virt returns zero, the autofs_create_entry returns -1 and dump
gets aborted, so why do we care?

> Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>
> ---
>  criu/autofs.c |    7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/criu/autofs.c b/criu/autofs.c
> index 8befc62..816a386 100644
> --- a/criu/autofs.c
> +++ b/criu/autofs.c
> @@ -290,7 +290,7 @@ static int autofs_create_entry(struct mount_info *pm, AutofsEntry *entry)
>  		entry->has_gid = true;
>  
>  	if (entry->fd != AUTOFS_CATATONIC_FD) {
> -		int found, read_fd;
> +		int found, read_fd, virt_pgrp;
>  
>  		read_fd = autofs_find_read_fd(entry->pgrp, pipe_ino);
>  		if (read_fd < 0)
> @@ -310,13 +310,14 @@ static int autofs_create_entry(struct mount_info *pm, AutofsEntry *entry)
>  		}
>  
>  		/* We need to get virtual pgrp to restore mount */
> -		entry->pgrp = pid_to_virt(entry->pgrp);
> -		if (!entry->pgrp) {
> +		virt_pgrp = pid_to_virt(entry->pgrp);
> +		if (!virt_pgrp) {
>  			pr_err("failed to find pstree item with pid %d\n",
>  					entry->pgrp);
>  			pr_err("Non-catatonic mount without master?\n");
>  			return -1;
>  		}
> +		entry->pgrp = virt_pgrp;
>  	}
>  	return 0;
>  }
> 
> _______________________________________________
> CRIU mailing list
> CRIU@openvz.org
> https://lists.openvz.org/mailman/listinfo/criu
> .
>
Stanislav Kinsburskiy April 22, 2016, 1:35 p.m.
22.04.2016 15:34, Pavel Emelyanov пишет:
> On 04/20/2016 07:31 PM, Stanislav Kinsburskiy wrote:
>> Otherwise information about real pid is lost in case of pid_to_virt returned
>> zero.
> But if pid_to_virt returns zero, the autofs_create_entry returns -1 and dump
> gets aborted, so why do we care?
>

This is required to output the real pid in error message instead of 
always outputting zero (result of pid_to_virt).
IOW, would be nice to know the process pid we failed to find in the tree.

>> Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>
>> ---
>>   criu/autofs.c |    7 ++++---
>>   1 file changed, 4 insertions(+), 3 deletions(-)
>>
>> diff --git a/criu/autofs.c b/criu/autofs.c
>> index 8befc62..816a386 100644
>> --- a/criu/autofs.c
>> +++ b/criu/autofs.c
>> @@ -290,7 +290,7 @@ static int autofs_create_entry(struct mount_info *pm, AutofsEntry *entry)
>>   		entry->has_gid = true;
>>   
>>   	if (entry->fd != AUTOFS_CATATONIC_FD) {
>> -		int found, read_fd;
>> +		int found, read_fd, virt_pgrp;
>>   
>>   		read_fd = autofs_find_read_fd(entry->pgrp, pipe_ino);
>>   		if (read_fd < 0)
>> @@ -310,13 +310,14 @@ static int autofs_create_entry(struct mount_info *pm, AutofsEntry *entry)
>>   		}
>>   
>>   		/* We need to get virtual pgrp to restore mount */
>> -		entry->pgrp = pid_to_virt(entry->pgrp);
>> -		if (!entry->pgrp) {
>> +		virt_pgrp = pid_to_virt(entry->pgrp);
>> +		if (!virt_pgrp) {
>>   			pr_err("failed to find pstree item with pid %d\n",
>>   					entry->pgrp);
>>   			pr_err("Non-catatonic mount without master?\n");
>>   			return -1;
>>   		}
>> +		entry->pgrp = virt_pgrp;
>>   	}
>>   	return 0;
>>   }
>>
>> _______________________________________________
>> CRIU mailing list
>> CRIU@openvz.org
>> https://lists.openvz.org/mailman/listinfo/criu
>> .
>>
Pavel Emelianov April 22, 2016, 2:28 p.m.
OK, applied