From b01bd93757b78b10c293edef1ab90c1d9d445e6a Mon Sep 17 00:00:00 2001 From: Pavel Emelyanov Date: Thu, 18 May 2017 12:35:19 +0300 Subject: [PATCH] rst: Collect procfs remaps at once MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There's no need in separate call to prepare_procfs_remaps(). All remaps are collected one step earlier and we can do open_remap_dead_process() right at once. Also rename the latter routine. ✓ travis-ci: success for Sanitize initialization bits Signed-off-by: Pavel Emelyanov --- criu/cr-restore.c | 5 ----- criu/files-reg.c | 42 +++++++++++++--------------------------- criu/include/files-reg.h | 1 - 3 files changed, 13 insertions(+), 35 deletions(-) diff --git a/criu/cr-restore.c b/criu/cr-restore.c index 1fb7a9243..d29dfa40d 100644 --- a/criu/cr-restore.c +++ b/criu/cr-restore.c @@ -229,11 +229,6 @@ static int crtools_prepare_shared(void) if (collect_remaps_and_regfiles()) return -1; - /* dead pid remap needs to allocate task helpers which all tasks need - * to see */ - if (prepare_procfs_remaps()) - return -1; - /* Connections are unlocked from criu */ if (collect_inet_sockets()) return -1; diff --git a/criu/files-reg.c b/criu/files-reg.c index 451427589..b0ac71f86 100644 --- a/criu/files-reg.c +++ b/criu/files-reg.c @@ -374,7 +374,7 @@ static int open_remap_linked(struct reg_file_info *rfi, return 0; } -static int open_remap_dead_process(struct reg_file_info *rfi, +static int collect_remap_dead_process(struct reg_file_info *rfi, RemapFilePathEntry *rfe) { struct pstree_item *helper; @@ -434,12 +434,21 @@ static int collect_one_remap(void *obj, ProtobufCMessage *msg, struct cr_img *i) ri->rfi = container_of(fdesc, struct reg_file_info, d); - if (rfe->remap_type == REMAP_TYPE__GHOST) { + switch (rfe->remap_type) { + case REMAP_TYPE__GHOST: if (collect_remap_ghost(ri->rfi, ri->rfe)) return -1; - } else if (rfe->remap_type == REMAP_TYPE__LINKED) { + break; + case REMAP_TYPE__LINKED: if (collect_remap_linked(ri->rfi, ri->rfe)) return -1; + break; + case REMAP_TYPE__PROCFS: + if (collect_remap_dead_process(ri->rfi, rfe) < 0) + return -1; + break; + default: + break; } list_add_tail(&ri->list, &remaps); @@ -463,7 +472,7 @@ static int prepare_one_remap(struct remap_info *ri) ret = open_remap_ghost(rfi, rfe); break; case REMAP_TYPE__PROCFS: - /* handled earlier by prepare_procfs_remaps */ + /* handled earlier by collect_remap_dead_process */ ret = 0; break; default: @@ -475,31 +484,6 @@ out: return ret; } -/* We separate the preparation of PROCFS remaps because they allocate pstree - * items, which need to be seen by the root task. We can't do all remaps here, - * because the files haven't been loaded yet. - */ -int prepare_procfs_remaps(void) -{ - struct remap_info *ri; - - list_for_each_entry(ri, &remaps, list) { - RemapFilePathEntry *rfe = ri->rfe; - struct reg_file_info *rfi = ri->rfi; - - switch (rfe->remap_type) { - case REMAP_TYPE__PROCFS: - if (open_remap_dead_process(rfi, rfe) < 0) - return -1; - break; - default: - continue; - } - } - - return 0; -} - int prepare_remaps(void) { struct remap_info *ri; diff --git a/criu/include/files-reg.h b/criu/include/files-reg.h index 5a6c69132..ba2ad6c81 100644 --- a/criu/include/files-reg.h +++ b/criu/include/files-reg.h @@ -53,7 +53,6 @@ extern int try_clean_remaps(bool only_ghosts); extern int strip_deleted(struct fd_link *link); -extern int prepare_procfs_remaps(void); extern int dead_pid_conflict(void); #endif /* __CR_FILES_REG_H__ */