Commit ae9f1bfd authored by Pavel Emelyanov's avatar Pavel Emelyanov Committed by Cyrill Gorcunov

dump: Restart seize in case reparent occurred

This can happen while dumping a pid-namespace (we can't do it now), thus
put this check not to forget one in the future.
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
parent a1fe2c58
......@@ -1010,14 +1010,31 @@ static int collect_subtree(pid_t pid, pid_t ppid, struct list_head *pstree_list,
return 0;
}
static int collect_pstree(pid_t pid, struct list_head *pstree_list, int leader_only)
static int collect_pstree(pid_t pid, struct list_head *pstree_list,
struct cr_options *opts)
{
int ret, attempts = 5;
while (1) {
ret = collect_subtree(pid, -1, pstree_list, leader_only);
if (ret == 0)
struct pstree_item *item;
ret = collect_subtree(pid, -1, pstree_list, opts->leader_only);
if (ret == 0) {
/*
* Some tasks could have been reparented to
* namespaces' reaper. Check this.
*/
if (opts->namespaces_flags & CLONE_NEWPID) {
item = list_first_entry(pstree_list,
struct pstree_item, list);
BUG_ON(item->pid != 1);
if (check_subtree(item))
goto try_again;
}
break;
}
/*
* Old tasks can die and new ones can appear while we
......@@ -1025,7 +1042,7 @@ static int collect_pstree(pid_t pid, struct list_head *pstree_list, int leader_o
* just to restart the collection from the beginning
* rather than trying to chase them.
*/
try_again:
if (attempts == 0)
break;
......@@ -1033,8 +1050,6 @@ static int collect_pstree(pid_t pid, struct list_head *pstree_list, int leader_o
pr_info("Trying to suspend tasks again\n");
while (!list_empty(pstree_list)) {
struct pstree_item *item;
item = list_first_entry(pstree_list,
struct pstree_item, list);
list_del(&item->list);
......@@ -1389,7 +1404,7 @@ int cr_dump_tasks(pid_t pid, struct cr_options *opts)
pr_info("Dumping process (pid: %d)\n", pid);
pr_info("========================================\n");
if (collect_pstree(pid, &pstree_list, opts->leader_only))
if (collect_pstree(pid, &pstree_list, opts))
goto err;
if (opts->namespaces_flags) {
......
......@@ -414,6 +414,10 @@ sys_kcmp(pid_t pid1, pid_t pid2, int type, unsigned long idx1, unsigned long idx
return syscall5(__NR_kcmp, (long)pid1, (long)pid2, (long)type, idx1, idx2);
}
#ifndef CLONE_NEWPID
#define CLONE_NEWPID 0x20000000
#endif
#ifndef CLONE_NEWUTS
#define CLONE_NEWUTS 0x04000000
#endif
......
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