Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

dnotify: move dnotify sysctl to dnotify.c

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 dnotify sysctls to dnotify.c and use the new
register_sysctl_init() to register the sysctl interface.

[mcgrof@kernel.org: adjust the commit log to justify the move]

Link: https://lkml.kernel.org/r/20211123202347.818157-10-mcgrof@kernel.org
Signed-off-by: Xiaoming Ni <nixiaoming@huawei.com>
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
Acked-by: Jan Kara <jack@suse.cz>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Amir Goldstein <amir73il@gmail.com>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Benjamin LaHaise <bcrl@kvack.org>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Iurii Zaikin <yzaikin@google.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Paul Turner <pjt@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Petr Mladek <pmladek@suse.com>
Cc: Qing Wang <wangqing@vivo.com>
Cc: Sebastian Reichel <sre@kernel.org>
Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
Cc: Stephen Kitt <steve@sk2.org>
Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Cc: Antti Palosaari <crope@iki.fi>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Clemens Ladisch <clemens@ladisch.de>
Cc: David Airlie <airlied@linux.ie>
Cc: Jani Nikula <jani.nikula@linux.intel.com>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Joseph Qi <joseph.qi@linux.alibaba.com>
Cc: Julia Lawall <julia.lawall@inria.fr>
Cc: Lukas Middendorf <kernel@tuxforce.de>
Cc: Mark Fasheh <mark@fasheh.com>
Cc: Phillip Potter <phil@philpotter.co.uk>
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Cc: Douglas Gilbert <dgilbert@interlog.com>
Cc: James E.J. Bottomley <jejb@linux.ibm.com>
Cc: Jani Nikula <jani.nikula@intel.com>
Cc: John Ogness <john.ogness@linutronix.de>
Cc: Martin K. Petersen <martin.petersen@oracle.com>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: "Theodore Ts'o" <tytso@mit.edu>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Xiaoming Ni and committed by
Linus Torvalds
49a4de75 86b12b6c

+20 -12
+20 -1
fs/notify/dnotify/dnotify.c
··· 19 19 #include <linux/fdtable.h> 20 20 #include <linux/fsnotify_backend.h> 21 21 22 - int dir_notify_enable __read_mostly = 1; 22 + static int dir_notify_enable __read_mostly = 1; 23 + #ifdef CONFIG_SYSCTL 24 + static struct ctl_table dnotify_sysctls[] = { 25 + { 26 + .procname = "dir-notify-enable", 27 + .data = &dir_notify_enable, 28 + .maxlen = sizeof(int), 29 + .mode = 0644, 30 + .proc_handler = proc_dointvec, 31 + }, 32 + {} 33 + }; 34 + static void __init dnotify_sysctl_init(void) 35 + { 36 + register_sysctl_init("fs", dnotify_sysctls); 37 + } 38 + #else 39 + #define dnotify_sysctl_init() do { } while (0) 40 + #endif 23 41 24 42 static struct kmem_cache *dnotify_struct_cache __read_mostly; 25 43 static struct kmem_cache *dnotify_mark_cache __read_mostly; ··· 404 386 dnotify_group = fsnotify_alloc_group(&dnotify_fsnotify_ops); 405 387 if (IS_ERR(dnotify_group)) 406 388 panic("unable to allocate fsnotify group for dnotify\n"); 389 + dnotify_sysctl_init(); 407 390 return 0; 408 391 } 409 392
-1
include/linux/dnotify.h
··· 29 29 FS_CREATE | FS_RENAME |\ 30 30 FS_MOVED_FROM | FS_MOVED_TO) 31 31 32 - extern int dir_notify_enable; 33 32 extern void dnotify_flush(struct file *, fl_owner_t); 34 33 extern int fcntl_dirnotify(int, struct file *, unsigned long); 35 34
-10
kernel/sysctl.c
··· 49 49 #include <linux/times.h> 50 50 #include <linux/limits.h> 51 51 #include <linux/dcache.h> 52 - #include <linux/dnotify.h> 53 52 #include <linux/syscalls.h> 54 53 #include <linux/vmstat.h> 55 54 #include <linux/nfs_fs.h> ··· 3085 3086 { 3086 3087 .procname = "leases-enable", 3087 3088 .data = &leases_enable, 3088 - .maxlen = sizeof(int), 3089 - .mode = 0644, 3090 - .proc_handler = proc_dointvec, 3091 - }, 3092 - #endif 3093 - #ifdef CONFIG_DNOTIFY 3094 - { 3095 - .procname = "dir-notify-enable", 3096 - .data = &dir_notify_enable, 3097 3089 .maxlen = sizeof(int), 3098 3090 .mode = 0644, 3099 3091 .proc_handler = proc_dointvec,