[v4,11/15] files: Add file_desc_ops::receive method

Submitted by Kirill Tkhai on June 1, 2016, 4:03 p.m.

Details

Message ID 146479699349.23002.13506050256558270730.stgit@pro
State Rejected
Series "Support for packet's msg_name in receive queue of promiscous DGRAM sockets"
Headers show

Commit Message

Kirill Tkhai June 1, 2016, 4:03 p.m.
Currently, nothing is done for master files in receive_fd().
Add a receive method, which may be useful for subsystems,
which need it (for queuer-less dgram sockets, going in following
patches).

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
---
 criu/files.c         |    3 ++-
 criu/include/files.h |   10 +++++++++-
 2 files changed, 11 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/criu/files.c b/criu/files.c
index bb3b142..22668ec 100644
--- a/criu/files.c
+++ b/criu/files.c
@@ -1053,12 +1053,13 @@  static int open_fd(int pid, struct fdinfo_list_entry *fle)
 
 static int receive_fd(int pid, struct fdinfo_list_entry *fle)
 {
+	struct file_desc *d = fle->desc;
 	int tmp;
 	struct fdinfo_list_entry *flem;
 
 	flem = file_master(fle->desc);
 	if (flem->pid == pid)
-		return 0;
+		return d->ops->receive ? d->ops->receive(d, fle->fe->fd) : 0;
 
 	pr_info("\tReceive fd for %d\n", fle->fe->fd);
 
diff --git a/criu/include/files.h b/criu/include/files.h
index 5e3d6dc..f0d5f23 100644
--- a/criu/include/files.h
+++ b/criu/include/files.h
@@ -90,7 +90,15 @@  struct file_desc_ops {
 	int			(*open)(struct file_desc *d);
 	/*
 	 * Called on a file when all files of that type are opened
-	 * and with the fd being the "restored" one.
+	 * and with the fd being the "restored" one. This may be used
+	 * to receive some additional file descriptors that are needed
+	 * at post_open stage.
+	 */
+	int			(*receive)(struct file_desc *d, int fd);
+	/*
+	 * Called on a file when all files of that type are opened
+	 * and with the fd being the "restored" one and all data need
+	 * to complete restore is received.
 	 */
 	int			(*post_open)(struct file_desc *d, int fd);
 	/*

Comments

Pavel Emelianov June 9, 2016, 1:15 p.m.
On 06/01/2016 07:03 PM, Kirill Tkhai wrote:
> Currently, nothing is done for master files in receive_fd().
> Add a receive method, which may be useful for subsystems,
> which need it (for queuer-less dgram sockets, going in following
> patches).
> 
> Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
> ---
>  criu/files.c         |    3 ++-
>  criu/include/files.h |   10 +++++++++-
>  2 files changed, 11 insertions(+), 2 deletions(-)
> 
> diff --git a/criu/files.c b/criu/files.c
> index bb3b142..22668ec 100644
> --- a/criu/files.c
> +++ b/criu/files.c
> @@ -1053,12 +1053,13 @@ static int open_fd(int pid, struct fdinfo_list_entry *fle)
>  
>  static int receive_fd(int pid, struct fdinfo_list_entry *fle)
>  {
> +	struct file_desc *d = fle->desc;
>  	int tmp;
>  	struct fdinfo_list_entry *flem;
>  
>  	flem = file_master(fle->desc);
>  	if (flem->pid == pid)
> -		return 0;
> +		return d->ops->receive ? d->ops->receive(d, fle->fe->fd) : 0;

Erm... This path is not receiving an fd, it's just us who's the
file master.

>  
>  	pr_info("\tReceive fd for %d\n", fle->fe->fd);
>  
> diff --git a/criu/include/files.h b/criu/include/files.h
> index 5e3d6dc..f0d5f23 100644
> --- a/criu/include/files.h
> +++ b/criu/include/files.h
> @@ -90,7 +90,15 @@ struct file_desc_ops {
>  	int			(*open)(struct file_desc *d);
>  	/*
>  	 * Called on a file when all files of that type are opened
> -	 * and with the fd being the "restored" one.
> +	 * and with the fd being the "restored" one. This may be used
> +	 * to receive some additional file descriptors that are needed
> +	 * at post_open stage.
> +	 */
> +	int			(*receive)(struct file_desc *d, int fd);
> +	/*
> +	 * Called on a file when all files of that type are opened
> +	 * and with the fd being the "restored" one and all data need
> +	 * to complete restore is received.
>  	 */
>  	int			(*post_open)(struct file_desc *d, int fd);
>  	/*
> 
> _______________________________________________
> CRIU mailing list
> CRIU@openvz.org
> https://lists.openvz.org/mailman/listinfo/criu
> .
>
Kirill Tkhai June 9, 2016, 1:31 p.m.
On 09.06.2016 16:15, Pavel Emelyanov wrote:
> On 06/01/2016 07:03 PM, Kirill Tkhai wrote:
>> Currently, nothing is done for master files in receive_fd().
>> Add a receive method, which may be useful for subsystems,
>> which need it (for queuer-less dgram sockets, going in following
>> patches).
>>
>> Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
>> ---
>>  criu/files.c         |    3 ++-
>>  criu/include/files.h |   10 +++++++++-
>>  2 files changed, 11 insertions(+), 2 deletions(-)
>>
>> diff --git a/criu/files.c b/criu/files.c
>> index bb3b142..22668ec 100644
>> --- a/criu/files.c
>> +++ b/criu/files.c
>> @@ -1053,12 +1053,13 @@ static int open_fd(int pid, struct fdinfo_list_entry *fle)
>>  
>>  static int receive_fd(int pid, struct fdinfo_list_entry *fle)
>>  {
>> +	struct file_desc *d = fle->desc;
>>  	int tmp;
>>  	struct fdinfo_list_entry *flem;
>>  
>>  	flem = file_master(fle->desc);
>>  	if (flem->pid == pid)
>> -		return 0;
>> +		return d->ops->receive ? d->ops->receive(d, fle->fe->fd) : 0;
> 
> Erm... This path is not receiving an fd, it's just us who's the
> file master.

I don't understand your comment. Could you please explain what you mean?
 
>>  
>>  	pr_info("\tReceive fd for %d\n", fle->fe->fd);
>>  
>> diff --git a/criu/include/files.h b/criu/include/files.h
>> index 5e3d6dc..f0d5f23 100644
>> --- a/criu/include/files.h
>> +++ b/criu/include/files.h
>> @@ -90,7 +90,15 @@ struct file_desc_ops {
>>  	int			(*open)(struct file_desc *d);
>>  	/*
>>  	 * Called on a file when all files of that type are opened
>> -	 * and with the fd being the "restored" one.
>> +	 * and with the fd being the "restored" one. This may be used
>> +	 * to receive some additional file descriptors that are needed
>> +	 * at post_open stage.
>> +	 */
>> +	int			(*receive)(struct file_desc *d, int fd);
>> +	/*
>> +	 * Called on a file when all files of that type are opened
>> +	 * and with the fd being the "restored" one and all data need
>> +	 * to complete restore is received.
>>  	 */
>>  	int			(*post_open)(struct file_desc *d, int fd);
>>  	/*
>>
>> _______________________________________________
>> CRIU mailing list
>> CRIU@openvz.org
>> https://lists.openvz.org/mailman/listinfo/criu
>> .
>>
>
Pavel Emelianov June 9, 2016, 1:44 p.m.
On 06/09/2016 04:31 PM, Kirill Tkhai wrote:
> 
> 
> On 09.06.2016 16:15, Pavel Emelyanov wrote:
>> On 06/01/2016 07:03 PM, Kirill Tkhai wrote:
>>> Currently, nothing is done for master files in receive_fd().
>>> Add a receive method, which may be useful for subsystems,
>>> which need it (for queuer-less dgram sockets, going in following
>>> patches).
>>>
>>> Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
>>> ---
>>>  criu/files.c         |    3 ++-
>>>  criu/include/files.h |   10 +++++++++-
>>>  2 files changed, 11 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/criu/files.c b/criu/files.c
>>> index bb3b142..22668ec 100644
>>> --- a/criu/files.c
>>> +++ b/criu/files.c
>>> @@ -1053,12 +1053,13 @@ static int open_fd(int pid, struct fdinfo_list_entry *fle)
>>>  
>>>  static int receive_fd(int pid, struct fdinfo_list_entry *fle)
>>>  {
>>> +	struct file_desc *d = fle->desc;
>>>  	int tmp;
>>>  	struct fdinfo_list_entry *flem;
>>>  
>>>  	flem = file_master(fle->desc);
>>>  	if (flem->pid == pid)
>>> -		return 0;
>>> +		return d->ops->receive ? d->ops->receive(d, fle->fe->fd) : 0;
>>
>> Erm... This path is not receiving an fd, it's just us who's the
>> file master.
> 
> I don't understand your comment. Could you please explain what you mean?

The "return 0" you've removed doesn't mean "receive descriptor". It means "OK,
the descriptor is already at the place we want it to". And renaming this
into "go ahead and to fd-specific receiving" is confusing.

Describe what operation you plan to "virtualize" with this callback.

>>>  
>>>  	pr_info("\tReceive fd for %d\n", fle->fe->fd);
>>>  
>>> diff --git a/criu/include/files.h b/criu/include/files.h
>>> index 5e3d6dc..f0d5f23 100644
>>> --- a/criu/include/files.h
>>> +++ b/criu/include/files.h
>>> @@ -90,7 +90,15 @@ struct file_desc_ops {
>>>  	int			(*open)(struct file_desc *d);
>>>  	/*
>>>  	 * Called on a file when all files of that type are opened
>>> -	 * and with the fd being the "restored" one.
>>> +	 * and with the fd being the "restored" one. This may be used
>>> +	 * to receive some additional file descriptors that are needed
>>> +	 * at post_open stage.
>>> +	 */
>>> +	int			(*receive)(struct file_desc *d, int fd);
>>> +	/*
>>> +	 * Called on a file when all files of that type are opened
>>> +	 * and with the fd being the "restored" one and all data need
>>> +	 * to complete restore is received.
>>>  	 */
>>>  	int			(*post_open)(struct file_desc *d, int fd);
>>>  	/*
>>>
>>> _______________________________________________
>>> CRIU mailing list
>>> CRIU@openvz.org
>>> https://lists.openvz.org/mailman/listinfo/criu
>>> .
>>>
>>
> .
>
Kirill Tkhai June 9, 2016, 2:17 p.m.
On 09.06.2016 16:44, Pavel Emelyanov wrote:
> On 06/09/2016 04:31 PM, Kirill Tkhai wrote:
>>
>>
>> On 09.06.2016 16:15, Pavel Emelyanov wrote:
>>> On 06/01/2016 07:03 PM, Kirill Tkhai wrote:
>>>> Currently, nothing is done for master files in receive_fd().
>>>> Add a receive method, which may be useful for subsystems,
>>>> which need it (for queuer-less dgram sockets, going in following
>>>> patches).
>>>>
>>>> Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
>>>> ---
>>>>  criu/files.c         |    3 ++-
>>>>  criu/include/files.h |   10 +++++++++-
>>>>  2 files changed, 11 insertions(+), 2 deletions(-)
>>>>
>>>> diff --git a/criu/files.c b/criu/files.c
>>>> index bb3b142..22668ec 100644
>>>> --- a/criu/files.c
>>>> +++ b/criu/files.c
>>>> @@ -1053,12 +1053,13 @@ static int open_fd(int pid, struct fdinfo_list_entry *fle)
>>>>  
>>>>  static int receive_fd(int pid, struct fdinfo_list_entry *fle)
>>>>  {
>>>> +	struct file_desc *d = fle->desc;
>>>>  	int tmp;
>>>>  	struct fdinfo_list_entry *flem;
>>>>  
>>>>  	flem = file_master(fle->desc);
>>>>  	if (flem->pid == pid)
>>>> -		return 0;
>>>> +		return d->ops->receive ? d->ops->receive(d, fle->fe->fd) : 0;
>>>
>>> Erm... This path is not receiving an fd, it's just us who's the
>>> file master.
>>
>> I don't understand your comment. Could you please explain what you mean?
> 
> The "return 0" you've removed doesn't mean "receive descriptor". It means "OK,
> the descriptor is already at the place we want it to". And renaming this
> into "go ahead and to fd-specific receiving" is confusing.
> 
> Describe what operation you plan to "virtualize" with this callback.

It's quite difficult to choose true name for this. It's not a specific operation,
it's just about a time between open and post_open. We may add new state
in fd_open_state::states instead..

>>>>  
>>>>  	pr_info("\tReceive fd for %d\n", fle->fe->fd);
>>>>  
>>>> diff --git a/criu/include/files.h b/criu/include/files.h
>>>> index 5e3d6dc..f0d5f23 100644
>>>> --- a/criu/include/files.h
>>>> +++ b/criu/include/files.h
>>>> @@ -90,7 +90,15 @@ struct file_desc_ops {
>>>>  	int			(*open)(struct file_desc *d);
>>>>  	/*
>>>>  	 * Called on a file when all files of that type are opened
>>>> -	 * and with the fd being the "restored" one.
>>>> +	 * and with the fd being the "restored" one. This may be used
>>>> +	 * to receive some additional file descriptors that are needed
>>>> +	 * at post_open stage.
>>>> +	 */
>>>> +	int			(*receive)(struct file_desc *d, int fd);
>>>> +	/*
>>>> +	 * Called on a file when all files of that type are opened
>>>> +	 * and with the fd being the "restored" one and all data need
>>>> +	 * to complete restore is received.
>>>>  	 */
>>>>  	int			(*post_open)(struct file_desc *d, int fd);
>>>>  	/*
>>>>
>>>> _______________________________________________
>>>> CRIU mailing list
>>>> CRIU@openvz.org
>>>> https://lists.openvz.org/mailman/listinfo/criu
>>>> .
>>>>
>>>
>> .
>>
>
Pavel Emelianov June 9, 2016, 2:42 p.m.
On 06/09/2016 05:17 PM, Kirill Tkhai wrote:
> 
> 
> On 09.06.2016 16:44, Pavel Emelyanov wrote:
>> On 06/09/2016 04:31 PM, Kirill Tkhai wrote:
>>>
>>>
>>> On 09.06.2016 16:15, Pavel Emelyanov wrote:
>>>> On 06/01/2016 07:03 PM, Kirill Tkhai wrote:
>>>>> Currently, nothing is done for master files in receive_fd().
>>>>> Add a receive method, which may be useful for subsystems,
>>>>> which need it (for queuer-less dgram sockets, going in following
>>>>> patches).
>>>>>
>>>>> Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
>>>>> ---
>>>>>  criu/files.c         |    3 ++-
>>>>>  criu/include/files.h |   10 +++++++++-
>>>>>  2 files changed, 11 insertions(+), 2 deletions(-)
>>>>>
>>>>> diff --git a/criu/files.c b/criu/files.c
>>>>> index bb3b142..22668ec 100644
>>>>> --- a/criu/files.c
>>>>> +++ b/criu/files.c
>>>>> @@ -1053,12 +1053,13 @@ static int open_fd(int pid, struct fdinfo_list_entry *fle)
>>>>>  
>>>>>  static int receive_fd(int pid, struct fdinfo_list_entry *fle)
>>>>>  {
>>>>> +	struct file_desc *d = fle->desc;
>>>>>  	int tmp;
>>>>>  	struct fdinfo_list_entry *flem;
>>>>>  
>>>>>  	flem = file_master(fle->desc);
>>>>>  	if (flem->pid == pid)
>>>>> -		return 0;
>>>>> +		return d->ops->receive ? d->ops->receive(d, fle->fe->fd) : 0;
>>>>
>>>> Erm... This path is not receiving an fd, it's just us who's the
>>>> file master.
>>>
>>> I don't understand your comment. Could you please explain what you mean?
>>
>> The "return 0" you've removed doesn't mean "receive descriptor". It means "OK,
>> the descriptor is already at the place we want it to". And renaming this
>> into "go ahead and to fd-specific receiving" is confusing.
>>
>> Describe what operation you plan to "virtualize" with this callback.
> 
> It's quite difficult to choose true name for this. It's not a specific operation,
> it's just about a time between open and post_open. We may add new state
> in fd_open_state::states instead..

Please, explain what you're trying to do with this callback.

>>>>>  
>>>>>  	pr_info("\tReceive fd for %d\n", fle->fe->fd);
>>>>>  
>>>>> diff --git a/criu/include/files.h b/criu/include/files.h
>>>>> index 5e3d6dc..f0d5f23 100644
>>>>> --- a/criu/include/files.h
>>>>> +++ b/criu/include/files.h
>>>>> @@ -90,7 +90,15 @@ struct file_desc_ops {
>>>>>  	int			(*open)(struct file_desc *d);
>>>>>  	/*
>>>>>  	 * Called on a file when all files of that type are opened
>>>>> -	 * and with the fd being the "restored" one.
>>>>> +	 * and with the fd being the "restored" one. This may be used
>>>>> +	 * to receive some additional file descriptors that are needed
>>>>> +	 * at post_open stage.
>>>>> +	 */
>>>>> +	int			(*receive)(struct file_desc *d, int fd);
>>>>> +	/*
>>>>> +	 * Called on a file when all files of that type are opened
>>>>> +	 * and with the fd being the "restored" one and all data need
>>>>> +	 * to complete restore is received.
>>>>>  	 */
>>>>>  	int			(*post_open)(struct file_desc *d, int fd);
>>>>>  	/*
>>>>>
>>>>> _______________________________________________
>>>>> CRIU mailing list
>>>>> CRIU@openvz.org
>>>>> https://lists.openvz.org/mailman/listinfo/criu
>>>>> .
>>>>>
>>>>
>>> .
>>>
>>
> .
>