mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-28 12:57:57 +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:
parent
bd69c6173d
commit
ae98ef6ae0
@ -1703,7 +1703,7 @@ int cr_dump_tasks(pid_t pid)
|
||||
if (collect_file_locks())
|
||||
goto err;
|
||||
|
||||
if (collect_mount_info(pid, true))
|
||||
if (collect_mount_info(pid))
|
||||
goto err;
|
||||
|
||||
if (mntns_collect_root(root_item->pid.real))
|
||||
|
@ -1260,14 +1260,7 @@ static int restore_task_with_children(void *_arg)
|
||||
|
||||
/* Restore root task */
|
||||
if (current->parent == NULL) {
|
||||
/*
|
||||
* 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)))
|
||||
if (collect_mount_info(getpid()))
|
||||
exit(1);
|
||||
|
||||
if (prepare_namespace(current, ca->clone_flags))
|
||||
|
@ -7,7 +7,7 @@ extern int mntns_collect_root(pid_t pid);
|
||||
struct proc_mountinfo;
|
||||
|
||||
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);
|
||||
|
||||
struct cr_fdset;
|
||||
|
27
mount.c
27
mount.c
@ -70,7 +70,7 @@ int open_mount(unsigned int s_dev)
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
int collect_mount_info(pid_t pid, bool parse)
|
||||
int collect_mount_info(pid_t pid)
|
||||
{
|
||||
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,
|
||||
* this will corrupt mount lists leading to weird
|
||||
* errors.
|
||||
* Build proper tree in any case -- for NEWNS one we'll use
|
||||
* it for old NS clean, otherwise we'll use the tree for
|
||||
* path resolution (btrfs stat workaround).
|
||||
*/
|
||||
if (parse) {
|
||||
mntinfo_tree = mnt_build_tree(mntinfo);
|
||||
if (!mntinfo_tree) {
|
||||
pr_err("Building mount tree %d failed\n", getpid());
|
||||
return -1;
|
||||
}
|
||||
|
||||
mntinfo_tree = mnt_build_tree(mntinfo);
|
||||
if (!mntinfo_tree) {
|
||||
pr_err("Building mount tree %d failed\n", getpid());
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -1117,8 +1116,6 @@ static int do_umount_one(struct mount_info *mi)
|
||||
|
||||
static int clean_mnt_ns(void)
|
||||
{
|
||||
struct mount_info *pm;
|
||||
|
||||
pr_info("Cleaning mount namespace\n");
|
||||
|
||||
/*
|
||||
@ -1130,11 +1127,7 @@ static int clean_mnt_ns(void)
|
||||
return -1;
|
||||
}
|
||||
|
||||
pm = mnt_build_tree(mntinfo);
|
||||
if (!pm)
|
||||
return -1;
|
||||
|
||||
return mnt_tree_for_each_reverse(pm, do_umount_one);
|
||||
return mnt_tree_for_each_reverse(mntinfo_tree, do_umount_one);
|
||||
}
|
||||
|
||||
static int cr_pivot_root()
|
||||
|
Loading…
x
Reference in New Issue
Block a user