Commit dcac6d66 authored by Kirill Tkhai's avatar Kirill Tkhai Committed by Andrei Vagin

mnt_ns: Use fdstore to keep mount namespaces

This allows to decrese number of file descriptors,
which are passed to children, and that is need to
close in close_old_files().

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>:
Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
parent 58b3b9ee
...@@ -104,7 +104,7 @@ struct ns_id { ...@@ -104,7 +104,7 @@ struct ns_id {
struct { struct {
struct mount_info *mntinfo_list; struct mount_info *mntinfo_list;
struct mount_info *mntinfo_tree; struct mount_info *mntinfo_tree;
int ns_fd; int nsfd_id;
int root_fd_id; int root_fd_id;
} mnt; } mnt;
......
...@@ -2947,7 +2947,7 @@ static int do_restore_task_mnt_ns(struct ns_id *nsid, struct pstree_item *curren ...@@ -2947,7 +2947,7 @@ static int do_restore_task_mnt_ns(struct ns_id *nsid, struct pstree_item *curren
{ {
int fd; int fd;
fd = open_proc(vpid(root_item), "fd/%d", nsid->mnt.ns_fd); fd = fdstore_get(nsid->mnt.nsfd_id);
if (fd < 0) if (fd < 0)
return -1; return -1;
...@@ -3007,7 +3007,6 @@ void fini_restore_mntns(void) ...@@ -3007,7 +3007,6 @@ void fini_restore_mntns(void)
for (nsid = ns_ids; nsid != NULL; nsid = nsid->next) { for (nsid = ns_ids; nsid != NULL; nsid = nsid->next) {
if (nsid->nd != &mnt_ns_desc) if (nsid->nd != &mnt_ns_desc)
continue; continue;
close_safe(&nsid->mnt.ns_fd);
nsid->ns_populated = true; nsid->ns_populated = true;
} }
} }
...@@ -3287,7 +3286,12 @@ int prepare_mnt_ns(void) ...@@ -3287,7 +3286,12 @@ int prepare_mnt_ns(void)
} }
/* Pin one with a file descriptor */ /* Pin one with a file descriptor */
nsid->mnt.ns_fd = fd; nsid->mnt.nsfd_id = fdstore_add(fd);
close(fd);
if (nsid->mnt.nsfd_id < 0) {
pr_err("Can't add ns fd\n");
goto err;
}
/* Set its root */ /* Set its root */
path[0] = '/'; path[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