[CRIU] [PATCH 2/3] files: Handle eventpoll files deferred

Cyrill Gorcunov gorcunov at openvz.org
Fri May 4 08:31:13 EDT 2012


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: Cyrill Gorcunov <gorcunov at openvz.org>
---
 files.c           |   19 +++++++++++++++----
 include/crtools.h |    1 +
 2 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/files.c b/files.c
index 137f8e3..2af9178 100644
--- a/files.c
+++ b/files.c
@@ -336,7 +336,7 @@ int collect_reg_files(void)
 	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;
 	struct fdinfo_list_entry *l, *le = &fdinfo_list[nr_fdinfo_list];
@@ -366,7 +366,11 @@ static int collect_fd(int pid, struct fdinfo_entry *e, struct list_head *fds)
 			break;
 
 	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;
 }
 
@@ -376,6 +380,7 @@ int prepare_fd_pid(int pid, struct rst_info *rst_info)
 	u32 type = 0;
 
 	INIT_LIST_HEAD(&rst_info->fds);
+	INIT_LIST_HEAD(&rst_info->eventpoll);
 
 	fdinfo_fd = open_image_ro(CR_FD_FDINFO, pid);
 	if (fdinfo_fd < 0) {
@@ -392,7 +397,7 @@ int prepare_fd_pid(int pid, struct rst_info *rst_info)
 		if (ret <= 0)
 			break;
 
-		ret = collect_fd(pid, &e, &rst_info->fds);
+		ret = collect_fd(pid, &e, rst_info);
 		if (ret < 0)
 			break;
 	}
@@ -654,12 +659,18 @@ int prepare_fds(struct pstree_item *me)
 
 	pr_info("%d: Opening fdinfo-s\n", me->pid);
 
-	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) {
 			ret = open_fdinfo(me->pid, &fle->fe, state);
 			if (ret)
 				goto done;
 		}
+		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();
 done:
diff --git a/include/crtools.h b/include/crtools.h
index 3c6a50b..9f091ad 100644
--- a/include/crtools.h
+++ b/include/crtools.h
@@ -199,6 +199,7 @@ struct vma_area {
 
 struct rst_info {
 	struct list_head	fds;
+	struct list_head	eventpoll;
 };
 
 struct pstree_item {
-- 
1.7.7.6



More information about the CRIU mailing list