mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-31 06:15:24 +00:00
pstree: Change type of init_pstree_helper() and check for parent
This is refactoring, which will be used in next patches. BUG_ON() just to mention that parent must be set before call of this function. v5: New Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com> Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
This commit is contained in:
committed by
Andrei Vagin
parent
1dce09bb14
commit
61a38fba15
@@ -534,13 +534,15 @@ static int collect_remap_dead_process(struct reg_file_info *rfi,
|
||||
return 0;
|
||||
}
|
||||
|
||||
init_pstree_helper(helper);
|
||||
|
||||
vsid(helper) = vsid(root_item);
|
||||
vpgid(helper) = vpgid(root_item);
|
||||
vpid(helper) = rfe->remap_id;
|
||||
helper->parent = root_item;
|
||||
helper->ids = root_item->ids;
|
||||
if (init_pstree_helper(helper)) {
|
||||
pr_err("Can't init helper\n");
|
||||
return -1;
|
||||
}
|
||||
list_add_tail(&helper->sibling, &root_item->children);
|
||||
|
||||
pr_info("Added a helper for restoring /proc/%d\n", vpid(helper));
|
||||
|
@@ -89,7 +89,7 @@ extern void free_pstree_item(struct pstree_item *item);
|
||||
extern void free_pstree(struct pstree_item *root_item);
|
||||
extern struct pstree_item *__alloc_pstree_item(bool rst, int level);
|
||||
#define alloc_pstree_item() __alloc_pstree_item(false, 1)
|
||||
extern void init_pstree_helper(struct pstree_item *ret);
|
||||
extern int init_pstree_helper(struct pstree_item *ret);
|
||||
|
||||
extern struct pstree_item *lookup_create_item(pid_t *pid, int level, uint32_t ns_id);
|
||||
extern void pstree_insert_pid(struct pid *pid_node, uint32_t ns_id);
|
||||
|
@@ -257,11 +257,13 @@ struct pstree_item *__alloc_pstree_item(bool rst, int level)
|
||||
return item;
|
||||
}
|
||||
|
||||
void init_pstree_helper(struct pstree_item *ret)
|
||||
int init_pstree_helper(struct pstree_item *ret)
|
||||
{
|
||||
BUG_ON(!ret->parent);
|
||||
ret->pid->state = TASK_HELPER;
|
||||
rsti(ret)->clone_flags = CLONE_FILES | CLONE_FS;
|
||||
task_entries->nr_helpers++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Deep first search on children */
|
||||
@@ -807,7 +809,10 @@ static int prepare_pstree_ids(void)
|
||||
helper->ids = root_item->ids;
|
||||
list_add_tail(&helper->sibling, &helpers);
|
||||
}
|
||||
init_pstree_helper(helper);
|
||||
if (init_pstree_helper(helper)) {
|
||||
pr_err("Can't init helper\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
pr_info("Add a helper %d for restoring SID %d\n",
|
||||
vpid(helper), vsid(helper));
|
||||
@@ -895,13 +900,16 @@ static int prepare_pstree_ids(void)
|
||||
continue;
|
||||
|
||||
helper = pid->item;
|
||||
init_pstree_helper(helper);
|
||||
|
||||
vsid(helper) = vsid(item);
|
||||
vpgid(helper) = vpgid(item);
|
||||
vpid(helper) = vpgid(item);
|
||||
helper->parent = item;
|
||||
helper->ids = item->ids;
|
||||
if (init_pstree_helper(helper)) {
|
||||
pr_err("Can't init helper\n");
|
||||
return -1;
|
||||
}
|
||||
list_add(&helper->sibling, &item->children);
|
||||
rsti(item)->pgrp_leader = helper;
|
||||
|
||||
|
Reference in New Issue
Block a user