Commit 867bcd21 authored by Pavel's avatar Pavel Committed by Pavel Emelyanov

mnt: Shorten the mntns dumping loop

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.
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
Acked-by: 's avatarAndrew Vagin <avagin@parallels.com>
parent 6382ed43
......@@ -18,6 +18,7 @@ struct ns_id {
futex_t created; /* boolean */
union {
struct {
struct mount_info *mntinfo_list;
struct mount_info *mntinfo_tree;
} mnt;
};
......
......@@ -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;
}
......
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