2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-29 05:18:00 +00:00

mount: Factor out mount tree build for NEWNS and non-NS cases

We anyway build the tree, in the NS case -- few calls later.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
Pavel Emelyanov 2013-12-12 16:19:48 +04:00
parent bd69c6173d
commit ae98ef6ae0
4 changed files with 13 additions and 27 deletions

View File

@ -1703,7 +1703,7 @@ int cr_dump_tasks(pid_t pid)
if (collect_file_locks()) if (collect_file_locks())
goto err; goto err;
if (collect_mount_info(pid, true)) if (collect_mount_info(pid))
goto err; goto err;
if (mntns_collect_root(root_item->pid.real)) if (mntns_collect_root(root_item->pid.real))

View File

@ -1260,14 +1260,7 @@ static int restore_task_with_children(void *_arg)
/* Restore root task */ /* Restore root task */
if (current->parent == NULL) { if (current->parent == NULL) {
/* if (collect_mount_info(getpid()))
* For ghost file path resolving on BTRFS we will need
* parsed mount tree, but IIF we're not restoring task
* with mount namespace cloned, in this case we don't parse
* mount tree early because we will be reading mount points
* from image later and generate new mount tree.
*/
if (collect_mount_info(getpid(), !(ca->clone_flags & CLONE_NEWNS)))
exit(1); exit(1);
if (prepare_namespace(current, ca->clone_flags)) if (prepare_namespace(current, ca->clone_flags))

View File

@ -7,7 +7,7 @@ extern int mntns_collect_root(pid_t pid);
struct proc_mountinfo; struct proc_mountinfo;
extern int open_mount(unsigned int s_dev); extern int open_mount(unsigned int s_dev);
extern int collect_mount_info(pid_t pid, bool parse); extern int collect_mount_info(pid_t pid);
extern struct fstype *find_fstype_by_name(char *fst); extern struct fstype *find_fstype_by_name(char *fst);
struct cr_fdset; struct cr_fdset;

27
mount.c
View File

@ -70,7 +70,7 @@ int open_mount(unsigned int s_dev)
return -ENOENT; return -ENOENT;
} }
int collect_mount_info(pid_t pid, bool parse) int collect_mount_info(pid_t pid)
{ {
pr_info("Collecting mountinfo\n"); pr_info("Collecting mountinfo\n");
@ -81,16 +81,15 @@ int collect_mount_info(pid_t pid, bool parse)
} }
/* /*
* WARN: Don't ever parse already parsed mount tree, * Build proper tree in any case -- for NEWNS one we'll use
* this will corrupt mount lists leading to weird * it for old NS clean, otherwise we'll use the tree for
* errors. * path resolution (btrfs stat workaround).
*/ */
if (parse) {
mntinfo_tree = mnt_build_tree(mntinfo); mntinfo_tree = mnt_build_tree(mntinfo);
if (!mntinfo_tree) { if (!mntinfo_tree) {
pr_err("Building mount tree %d failed\n", getpid()); pr_err("Building mount tree %d failed\n", getpid());
return -1; return -1;
}
} }
return 0; return 0;
@ -1117,8 +1116,6 @@ static int do_umount_one(struct mount_info *mi)
static int clean_mnt_ns(void) static int clean_mnt_ns(void)
{ {
struct mount_info *pm;
pr_info("Cleaning mount namespace\n"); pr_info("Cleaning mount namespace\n");
/* /*
@ -1130,11 +1127,7 @@ static int clean_mnt_ns(void)
return -1; return -1;
} }
pm = mnt_build_tree(mntinfo); return mnt_tree_for_each_reverse(mntinfo_tree, do_umount_one);
if (!pm)
return -1;
return mnt_tree_for_each_reverse(pm, do_umount_one);
} }
static int cr_pivot_root() static int cr_pivot_root()