[CRIU] [PATCH v5 22/33] eventpoll: Make post_open stage may fail

Pavel Emelyanov xemul at virtuozzo.com
Wed Jan 18 02:57:25 PST 2017


On 01/18/2017 01:16 PM, Kirill Tkhai wrote:
> 
> 
> On 18.01.2017 13:11, Pavel Emelyanov wrote:
>> On 12/26/2016 05:28 PM, Kirill Tkhai wrote:
>>> Currently, it's just an additional check. But later this will be used.
>>>
>>> v5: Use "1" for return
>>
>> Why 1?
> 
> 1 means "the fle is not ready for restore". Where should I add a comment
> about that?

In patch comment :) And in the code near the callback that allows this
behavior explaining which code means what.

> Starting from this set there's still a mix between explicit numbers
>> (in code) and ORV_something (in comments).
> 
> Ah, sure, there is ORV in comment to patch "files: Kill struct file_desc_ops::post_open",
> which should sounds as
> 
> "    files: Kill struct file_desc_ops::post_open
>     
>     This make open fds asynchronous. Now we restore them in a poll-style.
>     Every ->open callback operates like a poll. It returns 1, i.e.
>     "call me again", if some events have not received yet, OR 0,
>     if restoring of a fle has finished.
>     
>     We iterate over list of file descriptors and look at its return value.
>     If there were not progress in restoring of a fle, we sleep on task_st
>     futex. As all events are sent together with changing task_st, we will
>     be woken up, when there is a some new work for us.	"
> 
> Should I resend it or series?

Would you pick up the rest of the patches, check/add/fix comments and
re-send what's not yet merged?

>>> v2: Use generic FLE_OPEN and FLE_RESTORED to determ if a fle is ready
>>>
>>> Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
>>> ---
>>>  criu/eventpoll.c |   27 +++++++++++++++++++++++++++
>>>  1 file changed, 27 insertions(+)
>>>
>>> diff --git a/criu/eventpoll.c b/criu/eventpoll.c
>>> index 88076db8a..42a656f31 100644
>>> --- a/criu/eventpoll.c
>>> +++ b/criu/eventpoll.c
>>> @@ -21,6 +21,7 @@
>>>  #include "image.h"
>>>  #include "util.h"
>>>  #include "log.h"
>>> +#include "pstree.h"
>>>  
>>>  #include "protobuf.h"
>>>  #include "images/eventpoll.pb-c.h"
>>> @@ -140,6 +141,24 @@ static int eventpoll_open(struct file_desc *d)
>>>  	close(tmp);
>>>  	return -1;
>>>  }
>>> +
>>> +static int epoll_not_ready_tfd(EventpollTfdEntry *tdefe)
>>> +{
>>> +	struct fdinfo_list_entry *fle;
>>> +
>>> +	list_for_each_entry(fle, &rsti(current)->used, used_list) {
>>> +		if (tdefe->tfd != fle->fe->fd)
>>> +			continue;
>>> +
>>> +		if (fle->desc->ops->type == FD_TYPES__EVENTPOLL)
>>> +			return (fle->stage != FLE_OPEN);
>>> +		else
>>> +			return (fle->stage != FLE_RESTORED);
>>> +	}
>>> +	BUG();
>>> +	return 0;
>>> +}
>>> +
>>>  static int eventpoll_retore_tfd(int fd, int id, EventpollTfdEntry *tdefe)
>>>  {
>>>  	struct epoll_event event;
>>> @@ -165,11 +184,19 @@ static int eventpoll_post_open(struct file_desc *d, int fd)
>>>  	info = container_of(d, struct eventpoll_file_info, d);
>>>  
>>>  	for (i = 0; i < info->efe->n_tfd; i++) {
>>> +		if (epoll_not_ready_tfd(info->efe->tfd[i]))
>>> +			return 1;
>>> +	}
>>> +	for (i = 0; i < info->efe->n_tfd; i++) {
>>>  		if (eventpoll_retore_tfd(fd, info->efe->id, info->efe->tfd[i]))
>>>  			return -1;
>>>  	}
>>>  
>>>  	list_for_each_entry(td_info, &eventpoll_tfds, list) {
>>> +		if (epoll_not_ready_tfd(td_info->tdefe))
>>> +			return 1;
>>> +	}
>>> +	list_for_each_entry(td_info, &eventpoll_tfds, list) {
>>>  		if (td_info->tdefe->id != info->efe->id)
>>>  			continue;
>>>  
>>>
>>> .
>>>
>>
> .
> 



More information about the CRIU mailing list