[CRIU] [PATCH 03/11] mount: save remapped links on tmpfs
Pavel Emelyanov
xemul at parallels.com
Mon Aug 4 03:34:49 PDT 2014
On 07/25/2014 01:12 AM, Andrey Vagin wrote:
> For that mnt namespaces should be dumped after files.
>
> Signed-off-by: Andrey Vagin <avagin at openvz.org>
> ---
> cr-dump.c | 6 +++++-
> mount.c | 20 +++++++++++++++++++-
> 2 files changed, 24 insertions(+), 2 deletions(-)
>
> diff --git a/cr-dump.c b/cr-dump.c
> index d8ad0fc..aa44b95 100644
> --- a/cr-dump.c
> +++ b/cr-dump.c
> @@ -1803,7 +1803,7 @@ int cr_dump_tasks(pid_t pid)
> if (collect_file_locks())
> goto err;
>
> - if (dump_mnt_namespaces() < 0)
> + if (collect_mnt_namespaces() < 0)
> goto err;
>
> if (collect_sockets(pid))
> @@ -1818,6 +1818,10 @@ int cr_dump_tasks(pid_t pid)
> goto err;
> }
>
> + /* MNT namespaces are dumped after files to save remapped links */
> + if (dump_mnt_namespaces() < 0)
> + goto err;
> +
> if (dump_verify_tty_sids())
> goto err;
>
> diff --git a/mount.c b/mount.c
> index 50171a3..80ed133 100644
> --- a/mount.c
> +++ b/mount.c
> @@ -2123,7 +2123,25 @@ int collect_mnt_namespaces(void)
> int dump_mnt_namespaces(void)
> {
> int n = 0;
> - return walk_mnt_ns(dump_mnt_ns, &n);
We don't need arguments for walk_mnt_ns in that case.
> + struct mount_info *pm = NULL, *m, *ml = NULL;
> +
> + if (!(root_ns_mask & CLONE_NEWNS))
> + return 0;
> +
> + for (ml = m = mntinfo; m; pm = m, m = m->next) {
> + if (ml->nsid == m->nsid)
> + continue;
> +
> + pm->next = NULL;
> + if (dump_mnt_ns(ml->nsid, ml, &n))
> + return -1;
> + pm->next = m;
> + ml = m;
> + }
> + if (dump_mnt_ns(ml->nsid, ml, &n))
O_o Can we make all calls to dump_mnt_ns in one loop?
> + return -1;
> +
> + return 0;
> }
>
> struct ns_desc mnt_ns_desc = NS_DESC_ENTRY(CLONE_NEWNS, "mnt");
>
More information about the CRIU
mailing list