Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Trond Myklebust | a72b442 | 2006-01-03 09:55:41 +0100 | [diff] [blame] | 2 | /* |
| 3 | * linux/fs/nfs/sysctl.c |
| 4 | * |
| 5 | * Sysctl interface to NFS parameters |
| 6 | */ |
Trond Myklebust | a72b442 | 2006-01-03 09:55:41 +0100 | [diff] [blame] | 7 | #include <linux/types.h> |
| 8 | #include <linux/linkage.h> |
| 9 | #include <linux/ctype.h> |
| 10 | #include <linux/fs.h> |
| 11 | #include <linux/sysctl.h> |
| 12 | #include <linux/module.h> |
Trond Myklebust | 51d8fa6 | 2006-06-09 09:34:20 -0400 | [diff] [blame] | 13 | #include <linux/nfs_fs.h> |
Trond Myklebust | a72b442 | 2006-01-03 09:55:41 +0100 | [diff] [blame] | 14 | |
Trond Myklebust | a72b442 | 2006-01-03 09:55:41 +0100 | [diff] [blame] | 15 | static struct ctl_table_header *nfs_callback_sysctl_table; |
Trond Myklebust | a72b442 | 2006-01-03 09:55:41 +0100 | [diff] [blame] | 16 | |
Joe Perches | f5102e5 | 2014-06-06 14:38:03 -0700 | [diff] [blame] | 17 | static struct ctl_table nfs_cb_sysctls[] = { |
Trond Myklebust | 51d8fa6 | 2006-06-09 09:34:20 -0400 | [diff] [blame] | 18 | { |
Trond Myklebust | 51d8fa6 | 2006-06-09 09:34:20 -0400 | [diff] [blame] | 19 | .procname = "nfs_mountpoint_timeout", |
| 20 | .data = &nfs_mountpoint_expiry_timeout, |
| 21 | .maxlen = sizeof(nfs_mountpoint_expiry_timeout), |
| 22 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 23 | .proc_handler = proc_dointvec_jiffies, |
Trond Myklebust | 51d8fa6 | 2006-06-09 09:34:20 -0400 | [diff] [blame] | 24 | }, |
Peter Zijlstra | 89a0914 | 2007-03-16 13:38:26 -0800 | [diff] [blame] | 25 | { |
Peter Zijlstra | 89a0914 | 2007-03-16 13:38:26 -0800 | [diff] [blame] | 26 | .procname = "nfs_congestion_kb", |
| 27 | .data = &nfs_congestion_kb, |
| 28 | .maxlen = sizeof(nfs_congestion_kb), |
| 29 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 30 | .proc_handler = proc_dointvec, |
Peter Zijlstra | 89a0914 | 2007-03-16 13:38:26 -0800 | [diff] [blame] | 31 | }, |
Eric W. Biederman | ab09203 | 2009-11-05 14:25:10 -0800 | [diff] [blame] | 32 | { } |
Trond Myklebust | a72b442 | 2006-01-03 09:55:41 +0100 | [diff] [blame] | 33 | }; |
| 34 | |
Joe Perches | f5102e5 | 2014-06-06 14:38:03 -0700 | [diff] [blame] | 35 | static struct ctl_table nfs_cb_sysctl_dir[] = { |
Trond Myklebust | a72b442 | 2006-01-03 09:55:41 +0100 | [diff] [blame] | 36 | { |
Trond Myklebust | a72b442 | 2006-01-03 09:55:41 +0100 | [diff] [blame] | 37 | .procname = "nfs", |
| 38 | .mode = 0555, |
| 39 | .child = nfs_cb_sysctls, |
| 40 | }, |
Eric W. Biederman | ab09203 | 2009-11-05 14:25:10 -0800 | [diff] [blame] | 41 | { } |
Trond Myklebust | a72b442 | 2006-01-03 09:55:41 +0100 | [diff] [blame] | 42 | }; |
| 43 | |
Joe Perches | f5102e5 | 2014-06-06 14:38:03 -0700 | [diff] [blame] | 44 | static struct ctl_table nfs_cb_sysctl_root[] = { |
Trond Myklebust | a72b442 | 2006-01-03 09:55:41 +0100 | [diff] [blame] | 45 | { |
Trond Myklebust | a72b442 | 2006-01-03 09:55:41 +0100 | [diff] [blame] | 46 | .procname = "fs", |
| 47 | .mode = 0555, |
| 48 | .child = nfs_cb_sysctl_dir, |
| 49 | }, |
Eric W. Biederman | ab09203 | 2009-11-05 14:25:10 -0800 | [diff] [blame] | 50 | { } |
Trond Myklebust | a72b442 | 2006-01-03 09:55:41 +0100 | [diff] [blame] | 51 | }; |
| 52 | |
| 53 | int nfs_register_sysctl(void) |
| 54 | { |
Eric W. Biederman | 0b4d414 | 2007-02-14 00:34:09 -0800 | [diff] [blame] | 55 | nfs_callback_sysctl_table = register_sysctl_table(nfs_cb_sysctl_root); |
Trond Myklebust | a72b442 | 2006-01-03 09:55:41 +0100 | [diff] [blame] | 56 | if (nfs_callback_sysctl_table == NULL) |
| 57 | return -ENOMEM; |
| 58 | return 0; |
| 59 | } |
| 60 | |
| 61 | void nfs_unregister_sysctl(void) |
| 62 | { |
| 63 | unregister_sysctl_table(nfs_callback_sysctl_table); |
| 64 | nfs_callback_sysctl_table = NULL; |
| 65 | } |