[CRIU] [PATCH] mnt: Shorten the mntns dumping loop
Andrew Vagin
avagin at parallels.com
Mon Sep 22 07:18:04 PDT 2014
On Mon, Sep 22, 2014 at 04:26:44PM +0400, Pavel wrote:
> We currently have all mouninfo-s from all mnt namespaces collected
> in one big list. On dump we scan through it to find the namespaces
> we need to dump.
>
> This can be optimized by walking the list of namespaces instead.
Acked-by: Andrew Vagin <avagin at parallels.com>
>
> Signed-off-by: Pavel Emelyanov <xemul at parallels.com>
> ---
> include/namespaces.h | 1 +
> mount.c | 14 ++++++--------
> 2 files changed, 7 insertions(+), 8 deletions(-)
>
> diff --git a/include/namespaces.h b/include/namespaces.h
> index 350b8b4..ccf55f8 100644
> --- a/include/namespaces.h
> +++ b/include/namespaces.h
> @@ -18,6 +18,7 @@ struct ns_id {
> futex_t created; /* boolean */
> union {
> struct {
> + struct mount_info *mntinfo_list;
> struct mount_info *mntinfo_tree;
> } mnt;
> };
> diff --git a/mount.c b/mount.c
> index fb3fe6b..685f340 100644
> --- a/mount.c
> +++ b/mount.c
> @@ -975,7 +975,7 @@ struct mount_info *collect_mntinfo(struct ns_id *ns)
> {
> struct mount_info *pm;
>
> - pm = parse_mountinfo(ns->pid, ns);
> + ns->mnt.mntinfo_list = pm = parse_mountinfo(ns->pid, ns);
> if (!pm) {
> pr_err("Can't parse %d's mountinfo\n", ns->pid);
> return NULL;
> @@ -2133,15 +2133,14 @@ int collect_mnt_namespaces(void)
>
> int dump_mnt_namespaces(void)
> {
> - struct ns_id *nsid = NULL;
> - struct mount_info *m;
> + struct ns_id *nsid;
> int n = 0;
>
> if (!(root_ns_mask & CLONE_NEWNS))
> return 0;
>
> - for (m = mntinfo; m; m = m->next) {
> - if (m->nsid == nsid)
> + for (nsid = ns_ids; nsid != NULL; nsid = nsid->next) {
> + if (nsid->nd != &mnt_ns_desc)
> continue;
>
> if (++n == 2 && check_mnt_id()) {
> @@ -2150,11 +2149,10 @@ int dump_mnt_namespaces(void)
> return -1;
> }
>
> - if (dump_mnt_ns(m->nsid, m))
> + if (dump_mnt_ns(nsid, nsid->mnt.mntinfo_list))
> return -1;
> -
> - nsid = m->nsid;
> }
> +
> return 0;
> }
>
> --
> 1.8.4.2
>
> _______________________________________________
> CRIU mailing list
> CRIU at openvz.org
> https://lists.openvz.org/mailman/listinfo/criu
More information about the CRIU
mailing list