Commit b01bd937 authored by Pavel Emelyanov's avatar Pavel Emelyanov Committed by Andrei Vagin

rst: Collect procfs remaps at once

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: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
parent 30e2fd21
......@@ -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;
......
......@@ -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;
......
......@@ -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__ */
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