Commit 649baf8e authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Pavel Emelyanov

files: Handle eventpoll files deferred

Since event polling depends on other files
to be opened we split main files list into
two parst -- event poll files and all other
files, thus defer the creation of eventpoll
files in prepare_fds().
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 10b46351
...@@ -335,7 +335,7 @@ int collect_reg_files(void) ...@@ -335,7 +335,7 @@ int collect_reg_files(void)
return collect_remaps(); return collect_remaps();
} }
static int collect_fd(int pid, struct fdinfo_entry *e, struct list_head *fds) static int collect_fd(int pid, struct fdinfo_entry *e, struct rst_info *rst_info)
{ {
int i; int i;
struct fdinfo_list_entry *l, *le = &fdinfo_list[nr_fdinfo_list]; struct fdinfo_list_entry *l, *le = &fdinfo_list[nr_fdinfo_list];
...@@ -365,7 +365,11 @@ static int collect_fd(int pid, struct fdinfo_entry *e, struct list_head *fds) ...@@ -365,7 +365,11 @@ static int collect_fd(int pid, struct fdinfo_entry *e, struct list_head *fds)
break; break;
list_add_tail(&le->desc_list, &l->desc_list); list_add_tail(&le->desc_list, &l->desc_list);
list_add_tail(&le->ps_list, fds);
if (unlikely(le->fe.type == FDINFO_EVENTPOLL))
list_add_tail(&le->ps_list, &rst_info->eventpoll);
else
list_add_tail(&le->ps_list, &rst_info->fds);
return 0; return 0;
} }
...@@ -375,6 +379,7 @@ int prepare_fd_pid(int pid, struct rst_info *rst_info) ...@@ -375,6 +379,7 @@ int prepare_fd_pid(int pid, struct rst_info *rst_info)
u32 type = 0; u32 type = 0;
INIT_LIST_HEAD(&rst_info->fds); INIT_LIST_HEAD(&rst_info->fds);
INIT_LIST_HEAD(&rst_info->eventpoll);
fdinfo_fd = open_image_ro(CR_FD_FDINFO, pid); fdinfo_fd = open_image_ro(CR_FD_FDINFO, pid);
if (fdinfo_fd < 0) { if (fdinfo_fd < 0) {
...@@ -391,7 +396,7 @@ int prepare_fd_pid(int pid, struct rst_info *rst_info) ...@@ -391,7 +396,7 @@ int prepare_fd_pid(int pid, struct rst_info *rst_info)
if (ret <= 0) if (ret <= 0)
break; break;
ret = collect_fd(pid, &e, &rst_info->fds); ret = collect_fd(pid, &e, rst_info);
if (ret < 0) if (ret < 0)
break; break;
} }
...@@ -653,13 +658,25 @@ int prepare_fds(struct pstree_item *me) ...@@ -653,13 +658,25 @@ int prepare_fds(struct pstree_item *me)
pr_info("Opening fdinfo-s\n"); pr_info("Opening fdinfo-s\n");
for (state = 0; state < FD_STATE_MAX; state++) for (state = 0; state < FD_STATE_MAX; state++) {
list_for_each_entry(fle, &me->rst->fds, ps_list) { list_for_each_entry(fle, &me->rst->fds, ps_list) {
ret = open_fdinfo(me->pid, &fle->fe, state); ret = open_fdinfo(me->pid, &fle->fe, state);
if (ret) if (ret)
goto done; goto done;
} }
/*
* The eventpoll descriptors require all the other ones
* to be already restored, thus we store them in a separate
* list and restore at the very end.
*/
list_for_each_entry(fle, &me->rst->eventpoll, ps_list) {
ret = open_fdinfo(me->pid, &fle->fe, state);
if (ret)
goto done;
}
}
ret = run_unix_connections(); ret = run_unix_connections();
done: done:
return ret; return ret;
......
...@@ -203,6 +203,7 @@ struct vma_area { ...@@ -203,6 +203,7 @@ struct vma_area {
struct rst_info { struct rst_info {
struct list_head fds; struct list_head fds;
struct list_head eventpoll;
}; };
struct pstree_item { struct pstree_item {
......
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