summaryrefslogtreecommitdiff
path: root/include/linux/ns
diff options
context:
space:
mode:
authorChristian Brauner <brauner@kernel.org>2025-11-10 16:08:17 +0100
committerChristian Brauner <brauner@kernel.org>2025-11-11 10:01:30 +0100
commita657bc8a75cf40c3d0814fe6488ba4af56528f42 (patch)
tree0b61d6df0081d379da867ac5c07db4285b24878e /include/linux/ns
parentd12ea8062fd31f02beeeb76a7884ab9bc4f5b197 (diff)
nstree: switch to new structures
Switch the nstree management to the new combined structures. Link: https://patch.msgid.link/20251110-work-namespace-nstree-fixes-v1-5-e8a9264e0fb9@kernel.org Signed-off-by: Christian Brauner <brauner@kernel.org>
Diffstat (limited to 'include/linux/ns')
-rw-r--r--include/linux/ns/ns_common_types.h27
-rw-r--r--include/linux/ns/nstree_types.h19
2 files changed, 28 insertions, 18 deletions
diff --git a/include/linux/ns/ns_common_types.h b/include/linux/ns/ns_common_types.h
index ccd1d1e116f6..b332b019b29c 100644
--- a/include/linux/ns/ns_common_types.h
+++ b/include/linux/ns/ns_common_types.h
@@ -3,6 +3,7 @@
#define _LINUX_NS_COMMON_TYPES_H
#include <linux/atomic.h>
+#include <linux/ns/nstree_types.h>
#include <linux/rbtree.h>
#include <linux/refcount.h>
#include <linux/types.h>
@@ -98,6 +99,13 @@ extern const struct proc_ns_operations utsns_operations;
* Initial namespaces:
* Boot-time namespaces (init_net, init_pid_ns, etc.) start with
* __ns_ref_active = 1 and remain active forever.
+ *
+ * @ns_type: type of namespace (e.g., CLONE_NEWNET)
+ * @stashed: cached dentry to be used by the vfs
+ * @ops: namespace operations
+ * @inum: namespace inode number (quickly recycled for non-initial namespaces)
+ * @__ns_ref: main reference count (do not use directly)
+ * @ns_tree: namespace tree nodes and active reference count
*/
struct ns_common {
u32 ns_type;
@@ -106,24 +114,7 @@ struct ns_common {
unsigned int inum;
refcount_t __ns_ref; /* do not use directly */
union {
- struct {
- u64 ns_id;
- struct /* global namespace rbtree and list */ {
- struct rb_node ns_unified_tree_node;
- struct list_head ns_unified_list_node;
- };
- struct /* per type rbtree and list */ {
- struct rb_node ns_tree_node;
- struct list_head ns_list_node;
- };
- struct /* namespace ownership rbtree and list */ {
- struct rb_root ns_owner_tree; /* rbtree of namespaces owned by this namespace */
- struct list_head ns_owner; /* list of namespaces owned by this namespace */
- struct rb_node ns_owner_tree_node; /* node in the owner namespace's rbtree */
- struct list_head ns_owner_entry; /* node in the owner namespace's ns_owned list */
- };
- atomic_t __ns_ref_active; /* do not use directly */
- };
+ struct ns_tree;
struct rcu_head ns_rcu;
};
};
diff --git a/include/linux/ns/nstree_types.h b/include/linux/ns/nstree_types.h
index 6ee0c39686f8..2fb28ee31efb 100644
--- a/include/linux/ns/nstree_types.h
+++ b/include/linux/ns/nstree_types.h
@@ -33,4 +33,23 @@ struct ns_tree_node {
struct list_head ns_list_entry;
};
+/**
+ * struct ns_tree - Namespace tree nodes and active reference count
+ * @ns_id: Unique namespace identifier
+ * @__ns_ref_active: Active reference count (do not use directly)
+ * @ns_unified_node: Node in the global namespace tree
+ * @ns_tree_node: Node in the per-type namespace tree
+ * @ns_owner_node: Node in the owner namespace's tree of owned namespaces
+ * @ns_owner_root: Root of the tree of namespaces owned by this namespace
+ * (only used when this namespace is an owner)
+ */
+struct ns_tree {
+ u64 ns_id;
+ atomic_t __ns_ref_active;
+ struct ns_tree_node ns_unified_node;
+ struct ns_tree_node ns_tree_node;
+ struct ns_tree_node ns_owner_node;
+ struct ns_tree_root ns_owner_root;
+};
+
#endif /* _LINUX_NSTREE_TYPES_H */