Merge to Fedora kernel-2.6.18-1.2224_FC5 patched with stable patch-2.6.18.1-vs2.0...
[linux-2.6.git] / fs / nfs / sysctl.c
1 /*
2  * linux/fs/nfs/sysctl.c
3  *
4  * Sysctl interface to NFS parameters
5  */
6 #include <linux/types.h>
7 #include <linux/linkage.h>
8 #include <linux/ctype.h>
9 #include <linux/fs.h>
10 #include <linux/sysctl.h>
11 #include <linux/module.h>
12 #include <linux/nfs4.h>
13 #include <linux/nfs_idmap.h>
14 #include <linux/nfs_fs.h>
15
16 #include "callback.h"
17 #include "internal.h"
18
19 static const int nfs_set_port_min = 0;
20 static const int nfs_set_port_max = 65535;
21 static struct ctl_table_header *nfs_callback_sysctl_table;
22 /*
23  * Something that isn't CTL_ANY, CTL_NONE or a value that may clash.
24  * Use the same values as fs/lockd/svc.c
25  */
26 #define CTL_UNNUMBERED -2
27
28 static ctl_table nfs_cb_sysctls[] = {
29 #ifdef CONFIG_NFS_V4
30         {
31                 .ctl_name = CTL_UNNUMBERED,
32                 .procname = "nfs_callback_tcpport",
33                 .data = &nfs_callback_set_tcpport,
34                 .maxlen = sizeof(int),
35                 .mode = 0644,
36                 .proc_handler = &proc_dointvec_minmax,
37                 .extra1 = (int *)&nfs_set_port_min,
38                 .extra2 = (int *)&nfs_set_port_max,
39         },
40         {
41                 .ctl_name = CTL_UNNUMBERED,
42                 .procname = "idmap_cache_timeout",
43                 .data = &nfs_idmap_cache_timeout,
44                 .maxlen = sizeof(int),
45                 .mode = 0644,
46                 .proc_handler = &proc_dointvec_jiffies,
47                 .strategy = &sysctl_jiffies,
48         },
49 #endif
50         {
51                 .ctl_name       = CTL_UNNUMBERED,
52                 .procname       = "nfs_mountpoint_timeout",
53                 .data           = &nfs_mountpoint_expiry_timeout,
54                 .maxlen         = sizeof(nfs_mountpoint_expiry_timeout),
55                 .mode           = 0644,
56                 .proc_handler   = &proc_dointvec_jiffies,
57                 .strategy       = &sysctl_jiffies,
58         },
59 #ifdef CONFIG_NFS_FSCACHE
60         {
61                 .ctl_name = CTL_UNNUMBERED,
62                 .procname = "fscache_from_error",
63                 .data = &nfs_fscache_from_error,
64                 .maxlen = sizeof(int),
65                 .mode = 0644,
66                 .proc_handler = &proc_dointvec,
67         },
68         {
69                 .ctl_name = CTL_UNNUMBERED,
70                 .procname = "fscache_to_error",
71                 .data = &nfs_fscache_to_error,
72                 .maxlen = sizeof(int),
73                 .mode = 0644,
74                 .proc_handler = &proc_dointvec,
75         },
76         {
77                 .ctl_name = CTL_UNNUMBERED,
78                 .procname = "fscache_uncache_page",
79                 .data = &nfs_fscache_uncache_page,
80                 .maxlen = sizeof(int),
81                 .mode = 0644,
82                 .proc_handler = &proc_dointvec,
83         },
84         {
85                 .ctl_name = CTL_UNNUMBERED,
86                 .procname = "fscache_to_pages",
87                 .data = &nfs_fscache_to_pages,
88                 .maxlen = sizeof(int),
89                 .mode = 0644,
90                 .proc_handler = &proc_dointvec_minmax,
91         },
92         {
93                 .ctl_name = CTL_UNNUMBERED,
94                 .procname = "fscache_from_pages",
95                 .data = &nfs_fscache_from_pages,
96                 .maxlen = sizeof(int),
97                 .mode = 0644,
98                 .proc_handler = &proc_dointvec,
99         },
100 #endif
101         { .ctl_name = 0 }
102 };
103
104 static ctl_table nfs_cb_sysctl_dir[] = {
105         {
106                 .ctl_name = CTL_UNNUMBERED,
107                 .procname = "nfs",
108                 .mode = 0555,
109                 .child = nfs_cb_sysctls,
110         },
111         { .ctl_name = 0 }
112 };
113
114 static ctl_table nfs_cb_sysctl_root[] = {
115         {
116                 .ctl_name = CTL_FS,
117                 .procname = "fs",
118                 .mode = 0555,
119                 .child = nfs_cb_sysctl_dir,
120         },
121         { .ctl_name = 0 }
122 };
123
124 int nfs_register_sysctl(void)
125 {
126         nfs_callback_sysctl_table = register_sysctl_table(nfs_cb_sysctl_root, 0);
127         if (nfs_callback_sysctl_table == NULL)
128                 return -ENOMEM;
129         return 0;
130 }
131
132 void nfs_unregister_sysctl(void)
133 {
134         unregister_sysctl_table(nfs_callback_sysctl_table);
135         nfs_callback_sysctl_table = NULL;
136 }