mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-07-29 04:50:26 +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:
parent
0fcaeea912
commit
563efd3f25
3 changed files with 16 additions and 5 deletions
|
|
@ -532,13 +532,16 @@ static int collect_remap_dead_process(struct reg_file_info *rfi,
|
|||
return 0;
|
||||
}
|
||||
|
||||
init_pstree_helper(helper);
|
||||
|
||||
helper->sid = root_item->sid;
|
||||
helper->pgid = root_item->pgid;
|
||||
helper->pid->ns[0].virt = 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));
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ static inline bool task_alive(struct pstree_item *i)
|
|||
extern void free_pstree(struct pstree_item *root_item);
|
||||
extern struct pstree_item *__alloc_pstree_item(bool rst);
|
||||
#define alloc_pstree_item() __alloc_pstree_item(false)
|
||||
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);
|
||||
extern void pstree_insert_pid(struct pid *pid_node);
|
||||
|
|
|
|||
|
|
@ -229,11 +229,13 @@ struct pstree_item *__alloc_pstree_item(bool rst)
|
|||
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 */
|
||||
|
|
@ -675,7 +677,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), helper->sid);
|
||||
|
|
@ -763,13 +768,16 @@ static int prepare_pstree_ids(void)
|
|||
continue;
|
||||
|
||||
helper = pid->item;
|
||||
init_pstree_helper(helper);
|
||||
|
||||
helper->sid = item->sid;
|
||||
helper->pgid = item->pgid;
|
||||
helper->pid->ns[0].virt = item->pgid;
|
||||
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;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue