[CRIU] [PATCH v5 16/33] files: Add fdinfo_list_entry::stage
Pavel Emelyanov
xemul at virtuozzo.com
Wed Jan 18 01:12:58 PST 2017
On 01/18/2017 11:57 AM, Kirill Tkhai wrote:
>
>
> On 18.01.2017 11:43, Pavel Emelyanov wrote:
>> On 12/26/2016 05:27 PM, Kirill Tkhai wrote:
>>> Add fle open stages. Set a stage after every operation.
>>>
>>> v2: Do not merge filetype specific state with generic.
>>>
>>> Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
>>> ---
>>> criu/files.c | 13 ++++++++++---
>>> criu/include/files.h | 9 +++++++++
>>> 2 files changed, 19 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/criu/files.c b/criu/files.c
>>> index 87d8fc655..8e04309b6 100644
>>> --- a/criu/files.c
>>> +++ b/criu/files.c
>>> @@ -1005,12 +1005,16 @@ static int post_open_fd(int pid, struct fdinfo_list_entry *fle)
>>> return -1;
>>> }
>>> if (!is_service_fd(fle->fe->fd, CTL_TTY_OFF))
>>> - return 0;
>>> + goto out;
>>> }
>>>
>>> if (!d->ops->post_open)
>>> - return 0;
>>> - return d->ops->post_open(d, fle->fe->fd);
>>> + goto out;
>>> + if (d->ops->post_open(d, fle->fe->fd))
>>> + return -1;
>>> +out:
>>> + fle->stage = FLE_RESTORED;
>>> + return 0;
>>> }
>>>
>>>
>>> @@ -1058,6 +1062,9 @@ static int open_fd(int pid, struct fdinfo_list_entry *fle)
>>> return -1;
>>> }
>>>
>>> + if (fle->stage < FLE_OPEN)
>>
>> Why is this if here?
>
> I supposed, there may be file types, which would need to advance their state
> more, that to FLE_OPEN. But there is no one no.
>
> If you want, I may do patch, which will delete this and below, on top of the series.
If I just remove this if from the patch, will it still work? ;)
>>
>>> + fle->stage = FLE_OPEN;
>>> +
>>> return serve_out_fd(pid, fle->fe->fd, d);
>>> }
>>>
>>> diff --git a/criu/include/files.h b/criu/include/files.h
>>> index 1b44960de..5fffed6a8 100644
>>> --- a/criu/include/files.h
>>> +++ b/criu/include/files.h
>>> @@ -64,6 +64,13 @@ extern int fill_fdlink(int lfd, const struct fd_parms *p, struct fd_link *link);
>>>
>>> struct file_desc;
>>>
>>> +enum {
>>> + FLE_INITIALIZED,
>>> + FLE_OPEN,
>>> + FLE_RESTORING,
>>
>> State not used in this set.
>
> It's aimed for the future using for file types, which need a intermediate state. But, correctly,
> it's not used in this set.
>
>
>>> + FLE_RESTORED,
>>> +};
>>> +
>>> struct fdinfo_list_entry {
>>> struct list_head desc_list; /* To chain on @fd_info_head */
>>> struct file_desc *desc; /* Associated file descriptor */
>>> @@ -72,6 +79,7 @@ struct fdinfo_list_entry {
>>> int pid;
>>> FdinfoEntry *fe;
>>> u8 received:1;
>>> + u8 stage:3;
>>> };
>>>
>>> static inline void fle_init(struct fdinfo_list_entry *fle, int pid, FdinfoEntry *fe)
>>> @@ -79,6 +87,7 @@ static inline void fle_init(struct fdinfo_list_entry *fle, int pid, FdinfoEntry
>>> fle->pid = pid;
>>> fle->fe = fe;
>>> fle->received = 0;
>>> + fle->stage = FLE_INITIALIZED;
>>> }
>>>
>>> /* reports whether fd_a takes prio over fd_b */
>>>
>>> .
>>>
>>
> .
>
More information about the CRIU
mailing list