fs: move namespace sysctls and declare fs base directory
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() Link: https://lkml.kernel.org/r/20211129211943.640266-3-mcgrof@kernel.org Signed-off-by: Luis Chamberlain <mcgrof@kernel.org> Cc: Al Viro <viro@zeniv.linux.org.uk> Cc: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com> Cc: Antti Palosaari <crope@iki.fi> Cc: Christian Brauner <christian.brauner@ubuntu.com> Cc: "David S. Miller" <davem@davemloft.net> Cc: Eric Biederman <ebiederm@xmission.com> Cc: Eric Biggers <ebiggers@google.com> Cc: Iurii Zaikin <yzaikin@google.com> Cc: Kees Cook <keescook@chromium.org> Cc: Lukas Middendorf <kernel@tuxforce.de> Cc: Masami Hiramatsu <mhiramat@kernel.org> Cc: "Naveen N. Rao" <naveen.n.rao@linux.ibm.com> Cc: Stephen Kitt <steve@sk2.org> Cc: Xiaoming Ni <nixiaoming@huawei.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
51cb8dfc5a
commit
ab171b952c
|
@ -6,6 +6,8 @@
|
||||||
# Rewritten to use lists instead of if-statements.
|
# 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 \
|
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 \
|
char_dev.o stat.o exec.o pipe.o namei.o fcntl.o \
|
||||||
ioctl.o readdir.o select.o dcache.o inode.o \
|
ioctl.o readdir.o select.o dcache.o inode.o \
|
||||||
|
@ -28,7 +30,6 @@ obj-y += notify/
|
||||||
obj-$(CONFIG_EPOLL) += eventpoll.o
|
obj-$(CONFIG_EPOLL) += eventpoll.o
|
||||||
obj-y += anon_inodes.o
|
obj-y += anon_inodes.o
|
||||||
obj-$(CONFIG_SIGNALFD) += signalfd.o
|
obj-$(CONFIG_SIGNALFD) += signalfd.o
|
||||||
obj-$(CONFIG_SYSCTL) += sysctls.o
|
|
||||||
obj-$(CONFIG_TIMERFD) += timerfd.o
|
obj-$(CONFIG_TIMERFD) += timerfd.o
|
||||||
obj-$(CONFIG_EVENTFD) += eventfd.o
|
obj-$(CONFIG_EVENTFD) += eventfd.o
|
||||||
obj-$(CONFIG_USERFAULTFD) += userfaultfd.o
|
obj-$(CONFIG_USERFAULTFD) += userfaultfd.o
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
/* Maximum number of mounts in a mount namespace */
|
/* 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_mask __read_mostly;
|
||||||
static unsigned int m_hash_shift __read_mostly;
|
static unsigned int m_hash_shift __read_mostly;
|
||||||
|
@ -4620,3 +4620,25 @@ const struct proc_ns_operations mntns_operations = {
|
||||||
.install = mntns_install,
|
.install = mntns_install,
|
||||||
.owner = mntns_owner,
|
.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 */
|
||||||
|
|
|
@ -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 register_sysctl_base(fs);
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
early_initcall(init_fs_shared_sysctls);
|
early_initcall(init_fs_sysctls);
|
||||||
|
|
|
@ -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 void mark_mounts_for_expiry(struct list_head *mounts);
|
||||||
|
|
||||||
extern dev_t name_to_dev_t(const char *name);
|
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 bool path_is_mountpoint(const struct path *path);
|
||||||
|
|
||||||
extern void kern_unmount_array(struct vfsmount *mnt[], unsigned int num);
|
extern void kern_unmount_array(struct vfsmount *mnt[], unsigned int num);
|
||||||
|
|
|
@ -2811,18 +2811,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[] = {
|
static struct ctl_table debug_table[] = {
|
||||||
#ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
|
#ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
|
||||||
{
|
{
|
||||||
|
@ -2853,7 +2841,6 @@ static struct ctl_table dev_table[] = {
|
||||||
|
|
||||||
DECLARE_SYSCTL_BASE(kernel, kern_table);
|
DECLARE_SYSCTL_BASE(kernel, kern_table);
|
||||||
DECLARE_SYSCTL_BASE(vm, vm_table);
|
DECLARE_SYSCTL_BASE(vm, vm_table);
|
||||||
DECLARE_SYSCTL_BASE(fs, fs_table);
|
|
||||||
DECLARE_SYSCTL_BASE(debug, debug_table);
|
DECLARE_SYSCTL_BASE(debug, debug_table);
|
||||||
DECLARE_SYSCTL_BASE(dev, dev_table);
|
DECLARE_SYSCTL_BASE(dev, dev_table);
|
||||||
|
|
||||||
|
@ -2861,7 +2848,6 @@ int __init sysctl_init(void)
|
||||||
{
|
{
|
||||||
register_sysctl_base(kernel);
|
register_sysctl_base(kernel);
|
||||||
register_sysctl_base(vm);
|
register_sysctl_base(vm);
|
||||||
register_sysctl_base(fs);
|
|
||||||
register_sysctl_base(debug);
|
register_sysctl_base(debug);
|
||||||
register_sysctl_base(dev);
|
register_sysctl_base(dev);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue