From: Luis Chamberlain <mcgrof@kernel.org>
To: akpm@linux-foundation.org, viro@zeniv.linux.org.uk,
keescook@chromium.org, yzaikin@google.com, nixiaoming@huawei.com,
ebiederm@xmission.com, steve@sk2.org,
mcgrof@bombadil.infradead.org, mcgrof@kernel.org,
christian.brauner@ubuntu.com, ebiggers@google.com,
naveen.n.rao@linux.ibm.com, davem@davemloft.net,
mhiramat@kernel.org, anil.s.keshavamurthy@intel.com
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 2/6] fs: move namespace sysctls and declare fs base directory
Date: Mon, 29 Nov 2021 13:19:39 -0800 [thread overview]
Message-ID: <20211129211943.640266-3-mcgrof@kernel.org> (raw)
In-Reply-To: <20211129211943.640266-1-mcgrof@kernel.org>
This moves the namespace sysctls to its own file as part of the
kernel/sysctl.c spring cleaning
Since we have now removed all sysctls for "fs", we now have to
declare it on the filesystem code, we do that using the new helper,
which reduces boiler plate code.
We rename init_fs_shared_sysctls() to init_fs_sysctls() to reflect
that now fs/sysctls.c is taking on the burden of being the first
to register the base directory as well.
Lastly, since init code will load in the order in which we link it
we have to move the sysctl code to be linked in early, so that its
early init routine runs prior to other fs code. This way, other
filesystem code can register their own sysctls using the helpers
after this:
* register_sysctl_init()
* register_sysctl()
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
fs/Makefile | 3 ++-
fs/namespace.c | 24 +++++++++++++++++++++++-
fs/sysctls.c | 9 +++++----
include/linux/mount.h | 3 ---
kernel/sysctl.c | 14 --------------
5 files changed, 30 insertions(+), 23 deletions(-)
diff --git a/fs/Makefile b/fs/Makefile
index ea8770d124da..dab324aea08f 100644
--- a/fs/Makefile
+++ b/fs/Makefile
@@ -6,6 +6,8 @@
# Rewritten to use lists instead of if-statements.
#
+obj-$(CONFIG_SYSCTL) += sysctls.o
+
obj-y := open.o read_write.o file_table.o super.o \
char_dev.o stat.o exec.o pipe.o namei.o fcntl.o \
ioctl.o readdir.o select.o dcache.o inode.o \
@@ -28,7 +30,6 @@ obj-y += notify/
obj-$(CONFIG_EPOLL) += eventpoll.o
obj-y += anon_inodes.o
obj-$(CONFIG_SIGNALFD) += signalfd.o
-obj-$(CONFIG_SYSCTL) += sysctls.o
obj-$(CONFIG_TIMERFD) += timerfd.o
obj-$(CONFIG_EVENTFD) += eventfd.o
obj-$(CONFIG_USERFAULTFD) += userfaultfd.o
diff --git a/fs/namespace.c b/fs/namespace.c
index 3ab45b47b286..647af66f313d 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -36,7 +36,7 @@
#include "internal.h"
/* Maximum number of mounts in a mount namespace */
-unsigned int sysctl_mount_max __read_mostly = 100000;
+static unsigned int sysctl_mount_max __read_mostly = 100000;
static unsigned int m_hash_mask __read_mostly;
static unsigned int m_hash_shift __read_mostly;
@@ -4612,3 +4612,25 @@ const struct proc_ns_operations mntns_operations = {
.install = mntns_install,
.owner = mntns_owner,
};
+
+#ifdef CONFIG_SYSCTL
+static struct ctl_table fs_namespace_sysctls[] = {
+ {
+ .procname = "mount-max",
+ .data = &sysctl_mount_max,
+ .maxlen = sizeof(unsigned int),
+ .mode = 0644,
+ .proc_handler = proc_dointvec_minmax,
+ .extra1 = SYSCTL_ONE,
+ },
+ { }
+};
+
+static int __init init_fs_namespace_sysctls(void)
+{
+ register_sysctl_init("fs", fs_namespace_sysctls);
+ return 0;
+}
+fs_initcall(init_fs_namespace_sysctls);
+
+#endif /* CONFIG_SYSCTL */
diff --git a/fs/sysctls.c b/fs/sysctls.c
index 54216cd1ecd7..c701273c9432 100644
--- a/fs/sysctls.c
+++ b/fs/sysctls.c
@@ -29,10 +29,11 @@ static struct ctl_table fs_shared_sysctls[] = {
{ }
};
-static int __init init_fs_shared_sysctls(void)
+DECLARE_SYSCTL_BASE(fs, fs_shared_sysctls);
+
+static int __init init_fs_sysctls(void)
{
- register_sysctl_init("fs", fs_shared_sysctls);
- return 0;
+ return register_sysctl_base(fs);
}
-early_initcall(init_fs_shared_sysctls);
+early_initcall(init_fs_sysctls);
diff --git a/include/linux/mount.h b/include/linux/mount.h
index 5d92a7e1a742..7f18a7555dff 100644
--- a/include/linux/mount.h
+++ b/include/linux/mount.h
@@ -113,9 +113,6 @@ extern void mnt_set_expiry(struct vfsmount *mnt, struct list_head *expiry_list);
extern void mark_mounts_for_expiry(struct list_head *mounts);
extern dev_t name_to_dev_t(const char *name);
-
-extern unsigned int sysctl_mount_max;
-
extern bool path_is_mountpoint(const struct path *path);
extern void kern_unmount_array(struct vfsmount *mnt[], unsigned int num);
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index bbbafe545723..8d4cab1fbe9f 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -2810,18 +2810,6 @@ static struct ctl_table vm_table[] = {
{ }
};
-static struct ctl_table fs_table[] = {
- {
- .procname = "mount-max",
- .data = &sysctl_mount_max,
- .maxlen = sizeof(unsigned int),
- .mode = 0644,
- .proc_handler = proc_dointvec_minmax,
- .extra1 = SYSCTL_ONE,
- },
- { }
-};
-
static struct ctl_table debug_table[] = {
#ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
{
@@ -2852,7 +2840,6 @@ static struct ctl_table dev_table[] = {
DECLARE_SYSCTL_BASE(kernel, kern_table);
DECLARE_SYSCTL_BASE(vm, vm_table);
-DECLARE_SYSCTL_BASE(fs, fs_table);
DECLARE_SYSCTL_BASE(debug, debug_table);
DECLARE_SYSCTL_BASE(dev, dev_table);
@@ -2860,7 +2847,6 @@ int __init sysctl_init(void)
{
register_sysctl_base(kernel);
register_sysctl_base(vm);
- register_sysctl_base(fs);
register_sysctl_base(debug);
register_sysctl_base(dev);
--
2.33.0
next prev parent reply other threads:[~2021-11-29 23:06 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-29 21:19 [PATCH 0/6] sysctl: 5th set of kernel/sysctl cleanups Luis Chamberlain
2021-11-29 21:19 ` [PATCH 1/6] sysctl: add and use base directory declarer and registration helper Luis Chamberlain
2021-11-29 21:19 ` Luis Chamberlain [this message]
2021-11-29 21:19 ` [PATCH 3/6] kernel/sysctl.c: rename sysctl_init() to sysctl_init_bases() Luis Chamberlain
2021-11-29 21:19 ` [PATCH 4/6] printk: fix build warning when CONFIG_PRINTK=n Luis Chamberlain
2021-11-29 21:19 ` [PATCH 5/6] fs/coredump: move coredump sysctls into its own file Luis Chamberlain
2021-11-29 21:19 ` [PATCH 6/6] kprobe: move sysctl_kprobes_optimization to kprobes.c Luis Chamberlain
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=20211129211943.640266-3-mcgrof@kernel.org \
--to=mcgrof@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=anil.s.keshavamurthy@intel.com \
--cc=christian.brauner@ubuntu.com \
--cc=davem@davemloft.net \
--cc=ebiederm@xmission.com \
--cc=ebiggers@google.com \
--cc=keescook@chromium.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mcgrof@bombadil.infradead.org \
--cc=mhiramat@kernel.org \
--cc=naveen.n.rao@linux.ibm.com \
--cc=nixiaoming@huawei.com \
--cc=steve@sk2.org \
--cc=viro@zeniv.linux.org.uk \
--cc=yzaikin@google.com \
/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).