Commit ae98ef6a authored by Pavel Emelyanov's avatar Pavel Emelyanov

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: 's avatarPavel Emelyanov <xemul@parallels.com>
parent bd69c617
......@@ -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;
......
......@@ -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()
......
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