[CRIU] [PATCH v2 13/28] files: Kill want_post_open_stage()

Kirill Tkhai ktkhai at virtuozzo.com
Wed Nov 30 08:31:23 PST 2016


Since we are going to get rid of stage at all, kill this function
and call post_open_fd() unconditionally. It can handle the case,
when file_desc_ops::post_open is NULL

Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 criu/files.c |   31 +++----------------------------
 1 file changed, 3 insertions(+), 28 deletions(-)

diff --git a/criu/files.c b/criu/files.c
index cf15364..8a07da6 100644
--- a/criu/files.c
+++ b/criu/files.c
@@ -857,16 +857,6 @@ int set_fd_flags(int fd, int flags)
 struct fd_open_state {
 	char *name;
 	int (*cb)(int, struct fdinfo_list_entry *);
-
-	/*
-	 * Two last stages -- receive fds and post-open them -- are
-	 * not required always. E.g. if no fd sharing takes place
-	 * or task doens't have any files that need to be post-opened.
-	 *
-	 * Thus, in order not to scan through fdinfo-s lists in vain
-	 * and speed things up a little bit, we may want to skeep these.
-	 */
-	bool required;
 };
 
 static int open_fd(int pid, struct fdinfo_list_entry *fle);
@@ -874,13 +864,11 @@ static int receive_fd(int pid, struct fdinfo_list_entry *fle);
 static int post_open_fd(int pid, struct fdinfo_list_entry *fle);
 
 static struct fd_open_state states[] = {
-	{ "create",		open_fd,		true,},
-	{ "receive",		receive_fd,		true,},
-	{ "post_create",	post_open_fd,		false,},
+	{ "create",		open_fd,	},
+	{ "receive",		receive_fd,	},
+	{ "post_create",	post_open_fd,	},
 };
 
-#define want_post_open_stage()	do { states[2].required = true; } while (0)
-
 static void transport_name_gen(struct sockaddr_un *addr, int *len, int pid)
 {
 	addr->sun_family = AF_UNIX;
@@ -1025,9 +1013,6 @@ static int open_fd(int pid, struct fdinfo_list_entry *fle)
 	struct file_desc *d = fle->desc;
 	int new_fd;
 
-	if (d->ops->post_open)
-		want_post_open_stage();
-
 	if (fle != file_master(d))
 		return 0;
 
@@ -1162,11 +1147,6 @@ int prepare_fds(struct pstree_item *me)
 	}
 
 	for (state = 0; state < ARRAY_SIZE(states); state++) {
-		if (!states[state].required) {
-			pr_debug("Skipping %s fd stage\n", states[state].name);
-			continue;
-		}
-
 		ret = open_fdinfos(me->pid.virt, &rsti(me)->fds, state);
 		if (ret)
 			break;
@@ -1193,11 +1173,6 @@ int prepare_fds(struct pstree_item *me)
 		goto out_w;
 
 	for (state = 0; state < ARRAY_SIZE(states); state++) {
-		if (!states[state].required) {
-			pr_debug("Skipping %s fd stage\n", states[state].name);
-			continue;
-		}
-
 		/*
 		 * Opening current TTYs require session to be already set up,
 		 * thus slave peers already handled now it's time for cttys,



More information about the CRIU mailing list