Commit aadc309a authored by Andrey Vagin's avatar Andrey Vagin Committed by Pavel Emelyanov

mount: validate mounts only once on dump (v3)

mntinfo contains mounts from all namespaces, so we can validate it only
once after collecting mounts.

v2: add a fake comment about goto
v3: add a real comment about goto
Signed-off-by: 's avatarAndrey Vagin <avagin@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 32b032b6
...@@ -992,9 +992,6 @@ static int dump_mnt_ns(struct ns_id *ns, struct mount_info *pms) ...@@ -992,9 +992,6 @@ static int dump_mnt_ns(struct ns_id *ns, struct mount_info *pms)
int img_fd = -1, ret = -1; int img_fd = -1, ret = -1;
int ns_id = ns->id; int ns_id = ns->id;
if (validate_mounts(pms, true))
goto err;
pr_info("Dumping mountpoints\n"); pr_info("Dumping mountpoints\n");
img_fd = open_image(CR_FD_MNTS, O_DUMP, ns_id); img_fd = open_image(CR_FD_MNTS, O_DUMP, ns_id);
if (img_fd < 0) if (img_fd < 0)
...@@ -2095,8 +2092,12 @@ static int walk_mnt_ns(int (*cb)(struct ns_id *, struct mount_info *, void *), v ...@@ -2095,8 +2092,12 @@ static int walk_mnt_ns(int (*cb)(struct ns_id *, struct mount_info *, void *), v
if (mntinfo == NULL) if (mntinfo == NULL)
goto err; goto err;
} }
/*
continue; * Mount namespaces are dumped only if the root task lives in
* its own mntns, so we can stop enumeration of namespaces.
* We are not going to dump this tree, so we skip validation.
*/
goto out;
} }
pr_info("Dump MNT namespace (mountpoints) %d via %d\n", ns->id, ns->pid); pr_info("Dump MNT namespace (mountpoints) %d via %d\n", ns->id, ns->pid);
...@@ -2111,6 +2112,9 @@ static int walk_mnt_ns(int (*cb)(struct ns_id *, struct mount_info *, void *), v ...@@ -2111,6 +2112,9 @@ static int walk_mnt_ns(int (*cb)(struct ns_id *, struct mount_info *, void *), v
} }
if (collect_shared(mntinfo)) if (collect_shared(mntinfo))
goto err; goto err;
if (validate_mounts(mntinfo, true))
goto err;
out:
ret = 0; ret = 0;
err: err:
return ret; return ret;
......
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