aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuis Chamberlain <mcgrof@kernel.org>2021-11-17 15:43:23 -0800
committerLuis Chamberlain <mcgrof@kernel.org>2021-11-18 12:41:13 -0800
commit55db5cb7387c09fbdfc731a9ab1573f69d8f1d6d (patch)
treeead46b157bc57eef11ad481bd3083d12c7435bcd
parent47adfac265f63db4f68748497fd11f2fee1e45b7 (diff)
downloadlinux-next-55db5cb7387c09fbdfc731a9ab1573f69d8f1d6d.tar.gz
fs: move dcache sysctls to its own file
The kernel/sysctl.c is a kitchen sink where everyone leaves their dirty dishes, this makes it very difficult to maintain. To help with this maintenance let's start by moving sysctls to places where they actually belong. The proc sysctl maintainers do not want to know what sysctl knobs you wish to add for your own piece of code, we just care about the core logic. So move the dcache sysctl clutter out of kernel/sysctl.c. This is a small one-off entry, perhaps later we can simplify this representation, but for now we use the helpers we have. We won't know how we can simplify this further untl we're fully done with the cleanup. Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
-rw-r--r--fs/dcache.c22
-rw-r--r--include/linux/fs.h2
-rw-r--r--kernel/sysctl.c7
3 files changed, 20 insertions, 11 deletions
diff --git a/fs/dcache.c b/fs/dcache.c
index cf871a81f4fdc..f805aebc788e2 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -167,14 +167,32 @@ static long get_nr_dentry_negative(void)
return sum < 0 ? 0 : sum;
}
-int proc_nr_dentry(struct ctl_table *table, int write, void *buffer,
- size_t *lenp, loff_t *ppos)
+static int proc_nr_dentry(struct ctl_table *table, int write, void *buffer,
+ size_t *lenp, loff_t *ppos)
{
dentry_stat.nr_dentry = get_nr_dentry();
dentry_stat.nr_unused = get_nr_dentry_unused();
dentry_stat.nr_negative = get_nr_dentry_negative();
return proc_doulongvec_minmax(table, write, buffer, lenp, ppos);
}
+
+static struct ctl_table fs_dcache_sysctls[] = {
+ {
+ .procname = "dentry-state",
+ .data = &dentry_stat,
+ .maxlen = 6*sizeof(long),
+ .mode = 0444,
+ .proc_handler = proc_nr_dentry,
+ },
+ { }
+};
+
+static int __init init_fs_dcache_sysctls(void)
+{
+ register_sysctl_init("fs", fs_dcache_sysctls, "dcache");
+ return 0;
+}
+early_initcall(init_fs_dcache_sysctls);
#endif
/*
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 91954eda79fc9..03a1afc767d77 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -3590,8 +3590,6 @@ ssize_t simple_attr_write(struct file *file, const char __user *buf,
size_t len, loff_t *ppos);
struct ctl_table;
-int proc_nr_dentry(struct ctl_table *table, int write,
- void *buffer, size_t *lenp, loff_t *ppos);
int __init list_bdev_fs_names(char *buf, size_t size);
int __init get_filesystem_list(char *buf);
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 517bf81f4f4a2..22401525b090b 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -2901,13 +2901,6 @@ static struct ctl_table vm_table[] = {
static struct ctl_table fs_table[] = {
{
- .procname = "dentry-state",
- .data = &dentry_stat,
- .maxlen = 6*sizeof(long),
- .mode = 0444,
- .proc_handler = proc_nr_dentry,
- },
- {
.procname = "overflowuid",
.data = &fs_overflowuid,
.maxlen = sizeof(int),