[PATCH 21/23] mnt: Add mount namespaces into ns_idr

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Now they are exposed in /proc/namespace/ directory.

Signed-off-by: Kirill Tkhai <ktkhai@xxxxxxxxxxxxx>
---
 fs/mount.h     |    1 +
 fs/namespace.c |   10 +++++++++-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/fs/mount.h b/fs/mount.h
index f296862032ec..cde7f7bed8ec 100644
--- a/fs/mount.h
+++ b/fs/mount.h
@@ -23,6 +23,7 @@ struct mnt_namespace {
 	u64 event;
 	unsigned int		mounts; /* # of mounts in the namespace */
 	unsigned int		pending_mounts;
+	struct rcu_head		rcu;
 } __randomize_layout;
 
 struct mnt_pcp {
diff --git a/fs/namespace.c b/fs/namespace.c
index 8c39810e6ec3..756e43fd21f3 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -3258,7 +3258,7 @@ static void free_mnt_ns(struct mnt_namespace *ns)
 		ns_free_inum(&ns->ns);
 	dec_mnt_namespaces(ns->ucounts);
 	put_user_ns(ns->user_ns);
-	kfree(ns);
+	kfree_rcu(ns, rcu);
 }
 
 /*
@@ -3382,6 +3382,12 @@ struct mnt_namespace *copy_mnt_ns(unsigned long flags, struct mnt_namespace *ns,
 	if (pwdmnt)
 		mntput(pwdmnt);
 
+	if (ns_idr_register(&new_ns->ns) < 0) {
+		drop_collected_mounts(&new_ns->root->mnt);
+		free_mnt_ns(new_ns);
+		new_ns = ERR_PTR(-ENOMEM);
+	}
+
 	return new_ns;
 }
 
@@ -3824,6 +3830,7 @@ static void __init init_mount_tree(void)
 	list_add(&m->mnt_list, &ns->list);
 	init_task.nsproxy->mnt_ns = ns;
 	get_mnt_ns(ns);
+	WARN_ON(ns_idr_register(&ns->ns) < 0);
 
 	root.mnt = mnt;
 	root.dentry = mnt->mnt_root;
@@ -3872,6 +3879,7 @@ void put_mnt_ns(struct mnt_namespace *ns)
 {
 	if (!refcount_dec_and_test(&ns->ns.count))
 		return;
+	ns_idr_unregister(&ns->ns);
 	drop_collected_mounts(&ns->root->mnt);
 	free_mnt_ns(ns);
 }





[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux