From 7ca6cc1eb232fd467006c732af615cafcaee8e42 Mon Sep 17 00:00:00 2001 From: Pavel Emelyanov Date: Mon, 21 Sep 2015 14:12:16 +0300 Subject: [PATCH] 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 --- cr-restore.c | 6 +++--- include/mount.h | 1 + mount.c | 13 +++++++++---- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/cr-restore.c b/cr-restore.c index d3cc50c5d..4171155f4 100644 --- a/cr-restore.c +++ b/cr-restore.c @@ -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"); diff --git a/include/mount.h b/include/mount.h index ca2759330..08edfa2f7 100644 --- a/include/mount.h +++ b/include/mount.h @@ -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__ */ diff --git a/mount.c b/mount.c index 46f28e816..cd946d9f9 100644 --- a/mount.c +++ b/mount.c @@ -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;