[CRIU] [PATCH v4 12/33] files: Kill fd_open_state::receive_fd stage
Kirill Tkhai
ktkhai at virtuozzo.com
Tue Dec 13 07:05:56 PST 2016
Since "receive" stage is used only for slave fds
and nobody depends on slave fds receiving is finished,
we may move it functionality in "post_open" stage.
This just makes slave fds to be received a little bit later.
In other words, only masters have post_open stage,
and only slaves have receive stage. So, in the case of
A and B files:
A->open
B->open
A->recv
A->post_open
B->recv
B->post_open
A->post_open can't depend on B->recv. This follows
just from analyzing of all file types post_open methods.
Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
criu/files.c | 22 +++++++++-------------
1 file changed, 9 insertions(+), 13 deletions(-)
diff --git a/criu/files.c b/criu/files.c
index c09e33d..6554ca2 100644
--- a/criu/files.c
+++ b/criu/files.c
@@ -865,7 +865,6 @@ static int post_open_fd(int pid, struct fdinfo_list_entry *fle);
static struct fd_open_state states[] = {
{ "create", open_fd, },
- { "receive", receive_fd, },
{ "post_create", post_open_fd, },
};
@@ -971,15 +970,17 @@ static int post_open_fd(int pid, struct fdinfo_list_entry *fle)
{
struct file_desc *d = fle->desc;
- if (!d->ops->post_open)
- return 0;
-
- if (is_service_fd(fle->fe->fd, CTL_TTY_OFF))
- return d->ops->post_open(d, fle->fe->fd);
+ if (fle != file_master(d)) {
+ if (receive_fd(pid, fle) < 0) {
+ pr_err("Can't receive\n");
+ return -1;
+ }
+ if (!is_service_fd(fle->fe->fd, CTL_TTY_OFF))
+ return 0;
+ }
- if (fle != file_master(d))
+ if (!d->ops->post_open)
return 0;
-
return d->ops->post_open(d, fle->fe->fd);
}
@@ -1034,11 +1035,6 @@ static int open_fd(int pid, struct fdinfo_list_entry *fle)
static int receive_fd(int pid, struct fdinfo_list_entry *fle)
{
int fd;
- struct fdinfo_list_entry *flem;
-
- flem = file_master(fle->desc);
- if (flem->pid == pid)
- return 0;
pr_info("\tReceive fd for %d\n", fle->fe->fd);
More information about the CRIU
mailing list