Skip to content

Commit 52e6682

Browse files
yukaixiongJoelgranados
authored andcommitted
fs: dcache: move the sysctl to fs/dcache.c
The sysctl_vfs_cache_pressure belongs to fs/dcache.c, move it to fs/dcache.c from kernel/sysctl.c. As a part of fs/dcache.c cleaning, sysctl_vfs_cache_pressure is changed to a static variable, and change the inline-type function vfs_pressure_ratio() to out-of-inline type, export vfs_pressure_ratio() with EXPORT_SYMBOL_GPL to be used by other files. Move the unneeded include(linux/dcache.h). Signed-off-by: Kaixiong Yu <[email protected]> Reviewed-by: Kees Cook <[email protected]> Reviewed-by: Jan Kara <[email protected]> Reviewed-by: Christian Brauner <[email protected]> Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Joel Granados <[email protected]>
1 parent c8c3fd1 commit 52e6682

File tree

3 files changed

+20
-17
lines changed

3 files changed

+20
-17
lines changed

fs/dcache.c

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,13 @@
7373
* If no ancestor relationship:
7474
* arbitrary, since it's serialized on rename_lock
7575
*/
76-
int sysctl_vfs_cache_pressure __read_mostly = 100;
77-
EXPORT_SYMBOL_GPL(sysctl_vfs_cache_pressure);
76+
static int sysctl_vfs_cache_pressure __read_mostly = 100;
77+
78+
unsigned long vfs_pressure_ratio(unsigned long val)
79+
{
80+
return mult_frac(val, sysctl_vfs_cache_pressure, 100);
81+
}
82+
EXPORT_SYMBOL_GPL(vfs_pressure_ratio);
7883

7984
__cacheline_aligned_in_smp DEFINE_SEQLOCK(rename_lock);
8085

@@ -211,8 +216,20 @@ static const struct ctl_table fs_dcache_sysctls[] = {
211216
},
212217
};
213218

219+
static const struct ctl_table vm_dcache_sysctls[] = {
220+
{
221+
.procname = "vfs_cache_pressure",
222+
.data = &sysctl_vfs_cache_pressure,
223+
.maxlen = sizeof(sysctl_vfs_cache_pressure),
224+
.mode = 0644,
225+
.proc_handler = proc_dointvec_minmax,
226+
.extra1 = SYSCTL_ZERO,
227+
},
228+
};
229+
214230
static int __init init_fs_dcache_sysctls(void)
215231
{
232+
register_sysctl_init("vm", vm_dcache_sysctls);
216233
register_sysctl_init("fs", fs_dcache_sysctls);
217234
return 0;
218235
}

include/linux/dcache.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -520,12 +520,7 @@ static inline int simple_positive(const struct dentry *dentry)
520520
return d_really_is_positive(dentry) && !d_unhashed(dentry);
521521
}
522522

523-
extern int sysctl_vfs_cache_pressure;
524-
525-
static inline unsigned long vfs_pressure_ratio(unsigned long val)
526-
{
527-
return mult_frac(val, sysctl_vfs_cache_pressure, 100);
528-
}
523+
unsigned long vfs_pressure_ratio(unsigned long val);
529524

530525
/**
531526
* d_inode - Get the actual inode of this dentry

kernel/sysctl.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646
#include <linux/key.h>
4747
#include <linux/times.h>
4848
#include <linux/limits.h>
49-
#include <linux/dcache.h>
5049
#include <linux/syscalls.h>
5150
#include <linux/nfs_fs.h>
5251
#include <linux/acpi.h>
@@ -2014,14 +2013,6 @@ static const struct ctl_table kern_table[] = {
20142013
};
20152014

20162015
static const struct ctl_table vm_table[] = {
2017-
{
2018-
.procname = "vfs_cache_pressure",
2019-
.data = &sysctl_vfs_cache_pressure,
2020-
.maxlen = sizeof(sysctl_vfs_cache_pressure),
2021-
.mode = 0644,
2022-
.proc_handler = proc_dointvec_minmax,
2023-
.extra1 = SYSCTL_ZERO,
2024-
},
20252016
#if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
20262017
(defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
20272018
{

0 commit comments

Comments
 (0)