Commit c6312764 authored by Kirill Tkhai's avatar Kirill Tkhai Committed by Pavel Emelyanov

files: Add fdinfo_list_entry::stage

Add fle open stages. Set a stage after every operation.

v2: Do not merge filetype specific state with generic.

travis-ci: success for Rework file opening scheme to make it asynchronous (rev5)
Signed-off-by: 's avatarKirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
parent 735461e1
...@@ -1005,12 +1005,16 @@ static int post_open_fd(int pid, struct fdinfo_list_entry *fle) ...@@ -1005,12 +1005,16 @@ static int post_open_fd(int pid, struct fdinfo_list_entry *fle)
return -1; return -1;
} }
if (!is_service_fd(fle->fe->fd, CTL_TTY_OFF)) if (!is_service_fd(fle->fe->fd, CTL_TTY_OFF))
return 0; goto out;
} }
if (!d->ops->post_open) if (!d->ops->post_open)
return 0; goto out;
return d->ops->post_open(d, fle->fe->fd); if (d->ops->post_open(d, fle->fe->fd))
return -1;
out:
fle->stage = FLE_RESTORED;
return 0;
} }
...@@ -1058,6 +1062,8 @@ static int open_fd(int pid, struct fdinfo_list_entry *fle) ...@@ -1058,6 +1062,8 @@ static int open_fd(int pid, struct fdinfo_list_entry *fle)
return -1; return -1;
} }
fle->stage = FLE_OPEN;
return serve_out_fd(pid, fle->fe->fd, d); return serve_out_fd(pid, fle->fe->fd, d);
} }
......
...@@ -64,6 +64,12 @@ extern int fill_fdlink(int lfd, const struct fd_parms *p, struct fd_link *link); ...@@ -64,6 +64,12 @@ extern int fill_fdlink(int lfd, const struct fd_parms *p, struct fd_link *link);
struct file_desc; struct file_desc;
enum {
FLE_INITIALIZED,
FLE_OPEN,
FLE_RESTORED,
};
struct fdinfo_list_entry { struct fdinfo_list_entry {
struct list_head desc_list; /* To chain on @fd_info_head */ struct list_head desc_list; /* To chain on @fd_info_head */
struct file_desc *desc; /* Associated file descriptor */ struct file_desc *desc; /* Associated file descriptor */
...@@ -72,6 +78,7 @@ struct fdinfo_list_entry { ...@@ -72,6 +78,7 @@ struct fdinfo_list_entry {
int pid; int pid;
FdinfoEntry *fe; FdinfoEntry *fe;
u8 received:1; u8 received:1;
u8 stage:3;
}; };
static inline void fle_init(struct fdinfo_list_entry *fle, int pid, FdinfoEntry *fe) static inline void fle_init(struct fdinfo_list_entry *fle, int pid, FdinfoEntry *fe)
...@@ -79,6 +86,7 @@ static inline void fle_init(struct fdinfo_list_entry *fle, int pid, FdinfoEntry ...@@ -79,6 +86,7 @@ static inline void fle_init(struct fdinfo_list_entry *fle, int pid, FdinfoEntry
fle->pid = pid; fle->pid = pid;
fle->fe = fe; fle->fe = fe;
fle->received = 0; fle->received = 0;
fle->stage = FLE_INITIALIZED;
} }
/* reports whether fd_a takes prio over fd_b */ /* reports whether fd_a takes prio over fd_b */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment