misc filesystems: simplify sysctl registration
Subsystems (5)
cover misc filesystems: simplify sysctl registration
This simplifies syctl registration for a few misc filesystems according to our latest preference / guidance [0]. register_sysctl_table() incurs possible recursion and we can avoid that by dealing with flat directories with files in them, and having the subdirectories explicitly named with register_sysctl().
As we phase these callers out we can deprecate / remove register_sysctl_table() eventually.
If you're a maintainer feel free to pick up the patch or I'm also happy to take it through sysctl-next if you like. These don't create conflicts so there is no requirement they go throug sysclt-next at all.
I can pick up stragglers later.
[0] https://lore.kernel.org/all/[email protected]/T/#u
Luis Chamberlain (5):
fs/cachefiles: simplify one-level sysctl registration for
cachefiles_sysctls
devpts: simplify two-level sysctl registration for pty_kern_table
quota: simplify two-level sysctl registration for fs_dqstats_table
coda: simplify one-level sysctl registration for coda_table
ntfs: simplfy one-level sysctl registration for ntfs_sysctls
fs/cachefiles/error_inject.c | 11 +---------- fs/coda/sysctl.c | 11 +---------- fs/devpts/inode.c | 20 +------------------- fs/ntfs/sysctl.c | 12 +----------- fs/quota/dquot.c | 20 +------------------- 5 files changed, 5 insertions(+), 69 deletions(-)
Signature · 1 line
2.39.1
PATCH 1/5 fs/cachefiles: simplify one-level sysctl registration for cachefiles_sysctls
There is no need to declare an extra tables to just create directory, this can be easily be done with a prefix path with register_sysctl().
Simplify this registration.
--- fs/cachefiles/error_inject.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-)
fs/cachefiles/error_inject.c +1 -10
@@ -22,18 +22,9 @@ static struct ctl_table cachefiles_sysctls[] = { {} }; -static struct ctl_table cachefiles_sysctls_root[] = { - { - .procname ="cachefiles" , - .mode =0555 , - .child = cachefiles_sysctls, - }, - {} -}; -int __init cachefiles_register_error_injection (void ) { - cachefiles_sysctl =register_sysctl_table (cachefiles_sysctls_root); + cachefiles_sysctl =register_sysctl ("cachefiles" , cachefiles_sysctls);if (!cachefiles_sysctl)return -ENOMEM ;return 0 ;
Signature · 1 line
2.39.1
PATCH 2/5 devpts: simplify two-level sysctl registration for pty_kern_table
In reply to Luis ChamberlainThere is no need to declare two tables to just create directories, this can be easily be done with a prefix path with register_sysctl().
Simplify this registration.
--- fs/devpts/inode.c | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-)
fs/devpts/inode.c +1 -19
@@ -72,24 +72,6 @@ static struct ctl_table pty_table[] = { {} }; -static struct ctl_table pty_kern_table[] = { - { - .procname ="pty" , - .mode =0555 , - .child = pty_table, - }, - {} -}; - -static struct ctl_table pty_root_table[] = { - { - .procname ="kernel" , - .mode =0555 , - .child = pty_kern_table, - }, - {} -}; -struct pts_mount_opts {int setuid;int setgid;
@@ -630,7 +612,7 @@ static int __init init_devpts_fs(void) {int err =register_filesystem (&devpts_fs_type);if (!err) { -register_sysctl_table (pty_root_table); +register_sysctl ("kernel/pty" , pty_table); }return err; }
Signature · 1 line
2.39.1
Christian Brauner
maintainerRe: [PATCH 2/5] devpts: simplify two-level sysctl registration for pty_kern_table
Quoted 7 lines · Luis Chamberlain
There is no need to declare two tables to just create directories, this can be easily be done with a prefix path with
register_sysctl().Simplify this registration.
Signed-off-by Luis Chamberlain <[email protected]>---
I can take this one, Luis. Thanks!
PATCH 3/5 quota: simplify two-level sysctl registration for fs_dqstats_table
In reply to Luis ChamberlainThere is no need to declare two tables to just create directories, this can be easily be done with a prefix path with register_sysctl().
Simplify this registration.
--- fs/quota/dquot.c | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-)
fs/quota/dquot.c +1 -19
@@ -2948,24 +2948,6 @@ static struct ctl_table fs_dqstats_table[] = { { }, }; -static struct ctl_table fs_table[] = { - { - .procname ="quota" , - .mode =0555 , - .child = fs_dqstats_table, - }, - { }, -}; - -static struct ctl_table sys_table[] = { - { - .procname ="fs" , - .mode =0555 , - .child = fs_table, - }, - { }, -}; -static int __init dquot_init (void ) {int i, ret;
@@ -2973,7 +2955,7 @@ static int __init dquot_init(void)printk (KERN_NOTICE "VFS: Disk quotas %s\n" , __DQUOT_VERSION__); -register_sysctl_table (sys_table); +register_sysctl ("fs/quota" , fs_dqstats_table); dquot_cachep = kmem_cache_create("dquot", sizeof(struct dquot), sizeof(unsigned long) * 4,
Signature · 1 line
2.39.1
Jan Kara
reviewerRe: [PATCH 3/5] quota: simplify two-level sysctl registration for fs_dqstats_table
Quoted 6 lines · Luis Chamberlain
There is no need to declare two tables to just create directories, this can be easily be done with a prefix path with
register_sysctl().Simplify this registration.
Signed-off-by Luis Chamberlain <[email protected]>
Thanks. I've taken the patch into my tree.
Honza
Quoted 45 lines
--- fs/quota/dquot.c | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-)fs/quota/dquot.c +1
-19@@ -2948,24 +2948,6 @@ static struct ctl_table fs_dqstats_table[] = { { }, }; -static struct ctl_table fs_table[] = { - { - .procname ="quota" , - .mode =0555 , - .child = fs_dqstats_table, - }, - { }, -}; - -static struct ctl_table sys_table[] = { - { - .procname ="fs" , - .mode =0555 , - .child = fs_table, - }, - { }, -}; -static int __init dquot_init (void ) {int i, ret;@@ -2973,7 +2955,7 @@ static int __init dquot_init(void)printk (KERN_NOTICE "VFS: Disk quotas %s\n" , __DQUOT_VERSION__); -register_sysctl_table (sys_table); +register_sysctl ("fs/quota" , fs_dqstats_table); dquot_cachep = kmem_cache_create("dquot", sizeof(struct dquot), sizeof(unsigned long) * 4,Signature · 1 line
2.39.1
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
PATCH 4/5 coda: simplify one-level sysctl registration for coda_table
In reply to Luis ChamberlainThere is no need to declare an extra tables to just create directory, this can be easily be done with a prefix path with register_sysctl().
Simplify this registration.
--- fs/coda/sysctl.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-)
fs/coda/sysctl.c +1 -10
@@ -39,19 +39,10 @@ static struct ctl_table coda_table[] = { {} }; -static struct ctl_table fs_table[] = { - { - .procname ="coda" , - .mode =0555 , - .child = coda_table - }, - {} -}; -void coda_sysctl_init (void ) {if ( !fs_table_header ) - fs_table_header =register_sysctl_table (fs_table); + fs_table_header =register_sysctl ("coda" , coda_table); }void coda_sysctl_clean (void )
Signature · 1 line
2.39.1
Re: [PATCH 4/5] coda: simplify one-level sysctl registration for coda_table
Looks good to me, nice little cleanup.
Jan
Quoted 6 lines · Luis Chamberlain
There is no need to declare an extra tables to just create directory, this can be easily be done with a prefix path with
register_sysctl().Simplify this registration.
Signed-off-by Luis Chamberlain <[email protected]>
Quoted 33 lines
--- fs/coda/sysctl.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-)fs/coda/sysctl.c +1
-10@@ -39,19 +39,10 @@ static struct ctl_table coda_table[] = { {} }; -static struct ctl_table fs_table[] = { - { - .procname ="coda" , - .mode =0555 , - .child = coda_table - }, - {} -}; -void coda_sysctl_init (void ) {if ( !fs_table_header ) - fs_table_header =register_sysctl_table (fs_table); + fs_table_header =register_sysctl ("coda" , coda_table); }void coda_sysctl_clean (void )Signature · 1 line
2.39.1
PATCH 5/5 ntfs: simplfy one-level sysctl registration for ntfs_sysctls
In reply to Luis ChamberlainThere is no need to declare an extra tables to just create directory, this can be easily be done with a prefix path with register_sysctl().
Simplify this registration.
--- fs/ntfs/sysctl.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-)
fs/ntfs/sysctl.c +1 -11
@@ -31,16 +31,6 @@ static struct ctl_table ntfs_sysctls[] = { {} }; -/* Define the parent directory /proc/sys/fs. */ -static struct ctl_table sysctls_root[] = { - { - .procname ="fs" , - .mode =0555 , - .child = ntfs_sysctls - }, - {} -}; -/* Storage for the sysctls header. */ static struct ctl_table_header *sysctls_root_table;
@@ -54,7 +44,7 @@ int ntfs_sysctl(int add) {if (add) {BUG_ON (sysctls_root_table); - sysctls_root_table =register_sysctl_table (sysctls_root); + sysctls_root_table =register_sysctl ("fs" , ntfs_sysctls);if (!sysctls_root_table)return -ENOMEM ; }else {
Signature · 1 line
2.39.1