mnt: Clean roots yard from criu process

So here it is. If root task dies on restore the roots yard
dir remains unrmdired :( Since we already know its name, we
can remove one from criu. By the time we get to this place
the sub mount namespace(s) are already dead and yard dir
is empty. But umounting should be done by tasks after
successfull restore, so keep depopulation there.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
Pavel Emelyanov 2015-09-21 14:12:16 +03:00
parent 3e7c92ed02
commit 7ca6cc1eb2
3 changed files with 13 additions and 7 deletions

View file

@ -1546,9 +1546,6 @@ static int restore_task_with_children(void *_arg)
return 0;
err_fini_mnt:
if (current->parent == NULL)
depopulate_roots_yard();
err:
if (current->parent == NULL)
futex_abort_and_wake(&task_entries->nr_in_progress);
@ -1835,6 +1832,8 @@ static int restore_root_task(struct pstree_item *init)
*/
task_entries->nr_threads -= atomic_read(&task_entries->nr_zombies);
cleanup_mnt_ns();
ret = stop_usernsd();
if (ret < 0)
goto out_kill;
@ -1919,6 +1918,7 @@ out_kill:
out:
fini_cgroup();
cleanup_mnt_ns();
stop_usernsd();
__restore_switch_stage(CR_STATE_FAIL);
pr_err("Restoring FAILED.\n");

View file

@ -118,5 +118,6 @@ extern int depopulate_roots_yard(void);
extern char *rst_get_mnt_root(int mnt_id);
extern int ext_mount_add(char *key, char *val);
extern int mntns_maybe_create_roots(void);
extern void cleanup_mnt_ns(void);
#endif /* __CR_MOUNT_H__ */

13
mount.c
View file

@ -2734,14 +2734,19 @@ int depopulate_roots_yard(void)
pr_perror("Can't unmount %s", mnt_roots);
ret = 1;
}
if (rmdir(mnt_roots)) {
pr_perror("Can't remove the directory %s", mnt_roots);
ret = 1;
}
return ret;
}
void cleanup_mnt_ns(void)
{
if (mnt_roots == NULL)
return;
if (rmdir(mnt_roots))
pr_perror("Can't remove the directory %s", mnt_roots);
}
int prepare_mnt_ns(void)
{
int ret = -1;