From: Christian Brauner <brauner@kernel.org>
To: linux-fsdevel@vger.kernel.org
Cc: "Amir Goldstein" <amir73il@gmail.com>,
"Josef Bacik" <josef@toxicpanda.com>,
"Jeff Layton" <jlayton@kernel.org>, "Mike Yuan" <me@yhndnzj.com>,
"Zbigniew Jędrzejewski-Szmek" <zbyszek@in.waw.pl>,
"Lennart Poettering" <mzxreary@0pointer.de>,
"Daan De Meyer" <daan.j.demeyer@gmail.com>,
"Aleksa Sarai" <cyphar@cyphar.com>,
"Alexander Viro" <viro@zeniv.linux.org.uk>,
"Jan Kara" <jack@suse.cz>, "Tejun Heo" <tj@kernel.org>,
"Johannes Weiner" <hannes@cmpxchg.org>,
"Michal Koutný" <mkoutny@suse.com>,
"Jakub Kicinski" <kuba@kernel.org>,
"Anna-Maria Behnsen" <anna-maria@linutronix.de>,
"Frederic Weisbecker" <frederic@kernel.org>,
"Thomas Gleixner" <tglx@linutronix.de>,
cgroups@vger.kernel.org, linux-kernel@vger.kernel.org,
netdev@vger.kernel.org, "Christian Brauner" <brauner@kernel.org>
Subject: [PATCH 3/9] nscommon: move to separate file
Date: Wed, 17 Sep 2025 12:28:02 +0200 [thread overview]
Message-ID: <20250917-work-namespace-ns_common-v1-3-1b3bda8ef8f2@kernel.org> (raw)
In-Reply-To: <20250917-work-namespace-ns_common-v1-0-1b3bda8ef8f2@kernel.org>
It's really awkward spilling the ns common infrastructure into multiple
headers. Move it to a separate file.
Signed-off-by: Christian Brauner <brauner@kernel.org>
---
include/linux/ns_common.h | 3 +++
include/linux/proc_ns.h | 19 -------------------
kernel/Makefile | 2 +-
kernel/nscommon.c | 21 +++++++++++++++++++++
4 files changed, 25 insertions(+), 20 deletions(-)
diff --git a/include/linux/ns_common.h b/include/linux/ns_common.h
index 7224072cccc5..78b17fe80b62 100644
--- a/include/linux/ns_common.h
+++ b/include/linux/ns_common.h
@@ -31,6 +31,9 @@ struct ns_common {
};
};
+int ns_common_init(struct ns_common *ns, const struct proc_ns_operations *ops,
+ bool alloc_inum);
+
#define to_ns_common(__ns) \
_Generic((__ns), \
struct cgroup_namespace *: &(__ns)->ns, \
diff --git a/include/linux/proc_ns.h b/include/linux/proc_ns.h
index 7f89f0829e60..9f21670b5824 100644
--- a/include/linux/proc_ns.h
+++ b/include/linux/proc_ns.h
@@ -66,25 +66,6 @@ static inline void proc_free_inum(unsigned int inum) {}
#endif /* CONFIG_PROC_FS */
-static inline int ns_common_init(struct ns_common *ns,
- const struct proc_ns_operations *ops,
- bool alloc_inum)
-{
- if (alloc_inum) {
- int ret;
- ret = proc_alloc_inum(&ns->inum);
- if (ret)
- return ret;
- }
- refcount_set(&ns->count, 1);
- ns->stashed = NULL;
- ns->ops = ops;
- ns->ns_id = 0;
- RB_CLEAR_NODE(&ns->ns_tree_node);
- INIT_LIST_HEAD(&ns->ns_list_node);
- return 0;
-}
-
#define ns_free_inum(ns) proc_free_inum((ns)->inum)
#define get_proc_ns(inode) ((struct ns_common *)(inode)->i_private)
diff --git a/kernel/Makefile b/kernel/Makefile
index b807516a1b43..1f48f7cd2d7b 100644
--- a/kernel/Makefile
+++ b/kernel/Makefile
@@ -8,7 +8,7 @@ obj-y = fork.o exec_domain.o panic.o \
sysctl.o capability.o ptrace.o user.o \
signal.o sys.o umh.o workqueue.o pid.o task_work.o \
extable.o params.o \
- kthread.o sys_ni.o nsproxy.o nstree.o \
+ kthread.o sys_ni.o nsproxy.o nstree.o nscommon.o \
notifier.o ksysfs.o cred.o reboot.o \
async.o range.o smpboot.o ucount.o regset.o ksyms_common.o
diff --git a/kernel/nscommon.c b/kernel/nscommon.c
new file mode 100644
index 000000000000..ebf4783d0505
--- /dev/null
+++ b/kernel/nscommon.c
@@ -0,0 +1,21 @@
+// SPDX-License-Identifier: GPL-2.0-only
+
+#include <linux/ns_common.h>
+
+int ns_common_init(struct ns_common *ns, const struct proc_ns_operations *ops,
+ bool alloc_inum)
+{
+ if (alloc_inum) {
+ int ret;
+ ret = proc_alloc_inum(&ns->inum);
+ if (ret)
+ return ret;
+ }
+ refcount_set(&ns->count, 1);
+ ns->stashed = NULL;
+ ns->ops = ops;
+ ns->ns_id = 0;
+ RB_CLEAR_NODE(&ns->ns_tree_node);
+ INIT_LIST_HEAD(&ns->ns_list_node);
+ return 0;
+}
--
2.47.3
next prev parent reply other threads:[~2025-09-17 10:28 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-17 10:27 [PATCH 0/9] ns: rework common initialization Christian Brauner
2025-09-17 10:28 ` [PATCH 1/9] uts: split namespace into separate header Christian Brauner
2025-09-17 16:28 ` Jan Kara
2025-09-17 10:28 ` [PATCH 2/9] mnt: expose pointer to init_mnt_ns Christian Brauner
2025-09-17 16:28 ` Jan Kara
2025-09-19 10:05 ` Christian Brauner
2025-09-22 10:19 ` Jan Kara
2025-09-23 10:44 ` Christian Brauner
2025-09-17 10:28 ` Christian Brauner [this message]
2025-09-17 16:30 ` [PATCH 3/9] nscommon: move to separate file Jan Kara
2025-09-17 10:28 ` [PATCH 4/9] cgroup: split namespace into separate header Christian Brauner
2025-09-17 16:30 ` Tejun Heo
2025-09-17 16:30 ` Jan Kara
2025-09-17 10:28 ` [PATCH 5/9] nsfs: add inode number for anon namespace Christian Brauner
2025-09-17 16:31 ` Jan Kara
2025-09-17 10:28 ` [PATCH 6/9] mnt: simplify ns_common_init() handling Christian Brauner
2025-09-17 16:45 ` Jan Kara
2025-09-18 8:15 ` Christian Brauner
2025-09-18 9:12 ` Jan Kara
2025-09-17 10:28 ` [PATCH 7/9] net: centralize ns_common initialization Christian Brauner
2025-09-18 9:42 ` Jan Kara
2025-09-19 8:08 ` Christian Brauner
2025-09-22 10:19 ` Jan Kara
2025-09-17 10:28 ` [PATCH 8/9] nscommon: simplify initialization Christian Brauner
2025-09-18 9:45 ` Jan Kara
2025-09-17 10:28 ` [PATCH 9/9] ns: add ns_common_free() Christian Brauner
2025-09-18 9:11 ` Jan Kara
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250917-work-namespace-ns_common-v1-3-1b3bda8ef8f2@kernel.org \
--to=brauner@kernel.org \
--cc=amir73il@gmail.com \
--cc=anna-maria@linutronix.de \
--cc=cgroups@vger.kernel.org \
--cc=cyphar@cyphar.com \
--cc=daan.j.demeyer@gmail.com \
--cc=frederic@kernel.org \
--cc=hannes@cmpxchg.org \
--cc=jack@suse.cz \
--cc=jlayton@kernel.org \
--cc=josef@toxicpanda.com \
--cc=kuba@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=me@yhndnzj.com \
--cc=mkoutny@suse.com \
--cc=mzxreary@0pointer.de \
--cc=netdev@vger.kernel.org \
--cc=tglx@linutronix.de \
--cc=tj@kernel.org \
--cc=viro@zeniv.linux.org.uk \
--cc=zbyszek@in.waw.pl \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).