Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | * Syscall interface to knfsd. |
| 3 | * |
| 4 | * Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de> |
| 5 | */ |
| 6 | |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 7 | #include <linux/slab.h> |
Al Viro | 3f8206d | 2008-07-26 03:46:43 -0400 | [diff] [blame] | 8 | #include <linux/namei.h> |
NeilBrown | b41b66d | 2006-10-02 02:17:48 -0700 | [diff] [blame] | 9 | #include <linux/ctype.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | #include <linux/nfsd_idmap.h> |
NeilBrown | 80212d5 | 2006-10-02 02:17:47 -0700 | [diff] [blame] | 12 | #include <linux/sunrpc/svcsock.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | #include <linux/nfsd/syscall.h> |
Wendy Cheng | 4373ea8 | 2008-01-17 11:10:12 -0500 | [diff] [blame] | 14 | #include <linux/lockd/lockd.h> |
Chuck Lever | 4116092 | 2009-08-09 15:09:40 -0400 | [diff] [blame] | 15 | #include <linux/sunrpc/clnt.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | |
Boaz Harrosh | 9a74af2 | 2009-12-03 20:30:56 +0200 | [diff] [blame] | 17 | #include "nfsd.h" |
| 18 | #include "cache.h" |
| 19 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | /* |
| 21 | * We have a single directory with 9 nodes in it. |
| 22 | */ |
| 23 | enum { |
| 24 | NFSD_Root = 1, |
| 25 | NFSD_Svc, |
| 26 | NFSD_Add, |
| 27 | NFSD_Del, |
| 28 | NFSD_Export, |
| 29 | NFSD_Unexport, |
| 30 | NFSD_Getfd, |
| 31 | NFSD_Getfs, |
| 32 | NFSD_List, |
J. Bruce Fields | e8e8753 | 2009-12-14 12:53:32 -0500 | [diff] [blame] | 33 | NFSD_Export_features, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | NFSD_Fh, |
Wendy Cheng | 4373ea8 | 2008-01-17 11:10:12 -0500 | [diff] [blame] | 35 | NFSD_FO_UnlockIP, |
Wendy Cheng | 17efa37 | 2008-01-17 11:10:12 -0500 | [diff] [blame] | 36 | NFSD_FO_UnlockFS, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | NFSD_Threads, |
Greg Banks | eed2965 | 2006-10-02 02:18:02 -0700 | [diff] [blame] | 38 | NFSD_Pool_Threads, |
Greg Banks | 03cf6c9 | 2009-01-13 21:26:36 +1100 | [diff] [blame] | 39 | NFSD_Pool_Stats, |
NeilBrown | 70c3b76 | 2005-11-07 01:00:25 -0800 | [diff] [blame] | 40 | NFSD_Versions, |
NeilBrown | 80212d5 | 2006-10-02 02:17:47 -0700 | [diff] [blame] | 41 | NFSD_Ports, |
NeilBrown | 596bbe5 | 2006-10-04 02:15:48 -0700 | [diff] [blame] | 42 | NFSD_MaxBlkSize, |
NeilBrown | 70c3b76 | 2005-11-07 01:00:25 -0800 | [diff] [blame] | 43 | /* |
| 44 | * The below MUST come last. Otherwise we leave a hole in nfsd_files[] |
| 45 | * with !CONFIG_NFSD_V4 and simple_fill_super() goes oops |
| 46 | */ |
| 47 | #ifdef CONFIG_NFSD_V4 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | NFSD_Leasetime, |
J. Bruce Fields | efc4bb4f | 2010-03-02 11:04:06 -0500 | [diff] [blame] | 49 | NFSD_Gracetime, |
NeilBrown | 0964a3d | 2005-06-23 22:04:32 -0700 | [diff] [blame] | 50 | NFSD_RecoveryDir, |
NeilBrown | 70c3b76 | 2005-11-07 01:00:25 -0800 | [diff] [blame] | 51 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | }; |
| 53 | |
| 54 | /* |
| 55 | * write() for these nodes. |
| 56 | */ |
| 57 | static ssize_t write_svc(struct file *file, char *buf, size_t size); |
| 58 | static ssize_t write_add(struct file *file, char *buf, size_t size); |
| 59 | static ssize_t write_del(struct file *file, char *buf, size_t size); |
| 60 | static ssize_t write_export(struct file *file, char *buf, size_t size); |
| 61 | static ssize_t write_unexport(struct file *file, char *buf, size_t size); |
| 62 | static ssize_t write_getfd(struct file *file, char *buf, size_t size); |
| 63 | static ssize_t write_getfs(struct file *file, char *buf, size_t size); |
| 64 | static ssize_t write_filehandle(struct file *file, char *buf, size_t size); |
Chuck Lever | b046ccd | 2008-12-12 16:57:13 -0500 | [diff] [blame] | 65 | static ssize_t write_unlock_ip(struct file *file, char *buf, size_t size); |
| 66 | static ssize_t write_unlock_fs(struct file *file, char *buf, size_t size); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 | static ssize_t write_threads(struct file *file, char *buf, size_t size); |
Greg Banks | eed2965 | 2006-10-02 02:18:02 -0700 | [diff] [blame] | 68 | static ssize_t write_pool_threads(struct file *file, char *buf, size_t size); |
NeilBrown | 70c3b76 | 2005-11-07 01:00:25 -0800 | [diff] [blame] | 69 | static ssize_t write_versions(struct file *file, char *buf, size_t size); |
NeilBrown | 80212d5 | 2006-10-02 02:17:47 -0700 | [diff] [blame] | 70 | static ssize_t write_ports(struct file *file, char *buf, size_t size); |
NeilBrown | 596bbe5 | 2006-10-04 02:15:48 -0700 | [diff] [blame] | 71 | static ssize_t write_maxblksize(struct file *file, char *buf, size_t size); |
NeilBrown | 70c3b76 | 2005-11-07 01:00:25 -0800 | [diff] [blame] | 72 | #ifdef CONFIG_NFSD_V4 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 73 | static ssize_t write_leasetime(struct file *file, char *buf, size_t size); |
J. Bruce Fields | efc4bb4f | 2010-03-02 11:04:06 -0500 | [diff] [blame] | 74 | static ssize_t write_gracetime(struct file *file, char *buf, size_t size); |
NeilBrown | 0964a3d | 2005-06-23 22:04:32 -0700 | [diff] [blame] | 75 | static ssize_t write_recoverydir(struct file *file, char *buf, size_t size); |
NeilBrown | 70c3b76 | 2005-11-07 01:00:25 -0800 | [diff] [blame] | 76 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 77 | |
| 78 | static ssize_t (*write_op[])(struct file *, char *, size_t) = { |
| 79 | [NFSD_Svc] = write_svc, |
| 80 | [NFSD_Add] = write_add, |
| 81 | [NFSD_Del] = write_del, |
| 82 | [NFSD_Export] = write_export, |
| 83 | [NFSD_Unexport] = write_unexport, |
| 84 | [NFSD_Getfd] = write_getfd, |
| 85 | [NFSD_Getfs] = write_getfs, |
| 86 | [NFSD_Fh] = write_filehandle, |
Chuck Lever | b046ccd | 2008-12-12 16:57:13 -0500 | [diff] [blame] | 87 | [NFSD_FO_UnlockIP] = write_unlock_ip, |
| 88 | [NFSD_FO_UnlockFS] = write_unlock_fs, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 89 | [NFSD_Threads] = write_threads, |
Greg Banks | eed2965 | 2006-10-02 02:18:02 -0700 | [diff] [blame] | 90 | [NFSD_Pool_Threads] = write_pool_threads, |
NeilBrown | 70c3b76 | 2005-11-07 01:00:25 -0800 | [diff] [blame] | 91 | [NFSD_Versions] = write_versions, |
NeilBrown | 80212d5 | 2006-10-02 02:17:47 -0700 | [diff] [blame] | 92 | [NFSD_Ports] = write_ports, |
NeilBrown | 596bbe5 | 2006-10-04 02:15:48 -0700 | [diff] [blame] | 93 | [NFSD_MaxBlkSize] = write_maxblksize, |
NeilBrown | 70c3b76 | 2005-11-07 01:00:25 -0800 | [diff] [blame] | 94 | #ifdef CONFIG_NFSD_V4 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 95 | [NFSD_Leasetime] = write_leasetime, |
J. Bruce Fields | efc4bb4f | 2010-03-02 11:04:06 -0500 | [diff] [blame] | 96 | [NFSD_Gracetime] = write_gracetime, |
NeilBrown | 0964a3d | 2005-06-23 22:04:32 -0700 | [diff] [blame] | 97 | [NFSD_RecoveryDir] = write_recoverydir, |
NeilBrown | 70c3b76 | 2005-11-07 01:00:25 -0800 | [diff] [blame] | 98 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 99 | }; |
| 100 | |
| 101 | static ssize_t nfsctl_transaction_write(struct file *file, const char __user *buf, size_t size, loff_t *pos) |
| 102 | { |
Josef "Jeff" Sipek | 7eaa36e | 2006-12-08 02:36:41 -0800 | [diff] [blame] | 103 | ino_t ino = file->f_path.dentry->d_inode->i_ino; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 104 | char *data; |
| 105 | ssize_t rv; |
| 106 | |
Tobias Klauser | e8c96f8 | 2006-03-24 03:15:34 -0800 | [diff] [blame] | 107 | if (ino >= ARRAY_SIZE(write_op) || !write_op[ino]) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 108 | return -EINVAL; |
| 109 | |
| 110 | data = simple_transaction_get(file, buf, size); |
| 111 | if (IS_ERR(data)) |
| 112 | return PTR_ERR(data); |
| 113 | |
| 114 | rv = write_op[ino](file, data, size); |
NeilBrown | 8971a10 | 2007-02-14 00:33:11 -0800 | [diff] [blame] | 115 | if (rv >= 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 116 | simple_transaction_set(file, rv); |
| 117 | rv = size; |
| 118 | } |
| 119 | return rv; |
| 120 | } |
| 121 | |
NeilBrown | 7390022 | 2005-11-07 01:00:24 -0800 | [diff] [blame] | 122 | static ssize_t nfsctl_transaction_read(struct file *file, char __user *buf, size_t size, loff_t *pos) |
| 123 | { |
| 124 | if (! file->private_data) { |
| 125 | /* An attempt to read a transaction file without writing |
| 126 | * causes a 0-byte write so that the file can return |
| 127 | * state information |
| 128 | */ |
| 129 | ssize_t rv = nfsctl_transaction_write(file, buf, 0, pos); |
| 130 | if (rv < 0) |
| 131 | return rv; |
| 132 | } |
| 133 | return simple_transaction_read(file, buf, size, pos); |
| 134 | } |
| 135 | |
Arjan van de Ven | 4b6f5d2 | 2006-03-28 01:56:42 -0800 | [diff] [blame] | 136 | static const struct file_operations transaction_ops = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 137 | .write = nfsctl_transaction_write, |
NeilBrown | 7390022 | 2005-11-07 01:00:24 -0800 | [diff] [blame] | 138 | .read = nfsctl_transaction_read, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 139 | .release = simple_transaction_release, |
| 140 | }; |
| 141 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 142 | static int exports_open(struct inode *inode, struct file *file) |
| 143 | { |
| 144 | return seq_open(file, &nfs_exports_op); |
| 145 | } |
| 146 | |
Arjan van de Ven | 4b6f5d2 | 2006-03-28 01:56:42 -0800 | [diff] [blame] | 147 | static const struct file_operations exports_operations = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 148 | .open = exports_open, |
| 149 | .read = seq_read, |
| 150 | .llseek = seq_lseek, |
| 151 | .release = seq_release, |
Denis V. Lunev | 9ef2db2 | 2008-04-29 01:02:04 -0700 | [diff] [blame] | 152 | .owner = THIS_MODULE, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 153 | }; |
| 154 | |
J. Bruce Fields | e8e8753 | 2009-12-14 12:53:32 -0500 | [diff] [blame] | 155 | static int export_features_show(struct seq_file *m, void *v) |
| 156 | { |
| 157 | seq_printf(m, "0x%x 0x%x\n", NFSEXP_ALLFLAGS, NFSEXP_SECINFO_FLAGS); |
| 158 | return 0; |
| 159 | } |
| 160 | |
| 161 | static int export_features_open(struct inode *inode, struct file *file) |
| 162 | { |
| 163 | return single_open(file, export_features_show, NULL); |
| 164 | } |
| 165 | |
| 166 | static struct file_operations export_features_operations = { |
| 167 | .open = export_features_open, |
| 168 | .read = seq_read, |
| 169 | .llseek = seq_lseek, |
| 170 | .release = single_release, |
| 171 | }; |
| 172 | |
Greg Banks | 03cf6c9 | 2009-01-13 21:26:36 +1100 | [diff] [blame] | 173 | extern int nfsd_pool_stats_open(struct inode *inode, struct file *file); |
Ryusei Yamaguchi | ed2d8ae | 2009-08-16 00:54:41 +0900 | [diff] [blame] | 174 | extern int nfsd_pool_stats_release(struct inode *inode, struct file *file); |
Greg Banks | 03cf6c9 | 2009-01-13 21:26:36 +1100 | [diff] [blame] | 175 | |
Alexey Dobriyan | 828c095 | 2009-10-01 15:43:56 -0700 | [diff] [blame] | 176 | static const struct file_operations pool_stats_operations = { |
Greg Banks | 03cf6c9 | 2009-01-13 21:26:36 +1100 | [diff] [blame] | 177 | .open = nfsd_pool_stats_open, |
| 178 | .read = seq_read, |
| 179 | .llseek = seq_lseek, |
Ryusei Yamaguchi | ed2d8ae | 2009-08-16 00:54:41 +0900 | [diff] [blame] | 180 | .release = nfsd_pool_stats_release, |
Greg Banks | 03cf6c9 | 2009-01-13 21:26:36 +1100 | [diff] [blame] | 181 | .owner = THIS_MODULE, |
| 182 | }; |
| 183 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 184 | /*----------------------------------------------------------------------------*/ |
| 185 | /* |
| 186 | * payload - write methods |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 187 | */ |
| 188 | |
Chuck Lever | 262a098 | 2008-12-12 16:57:35 -0500 | [diff] [blame] | 189 | /** |
| 190 | * write_svc - Start kernel's NFSD server |
| 191 | * |
| 192 | * Deprecated. /proc/fs/nfsd/threads is preferred. |
| 193 | * Function remains to support old versions of nfs-utils. |
| 194 | * |
| 195 | * Input: |
| 196 | * buf: struct nfsctl_svc |
| 197 | * svc_port: port number of this |
| 198 | * server's listener |
| 199 | * svc_nthreads: number of threads to start |
| 200 | * size: size in bytes of passed in nfsctl_svc |
| 201 | * Output: |
| 202 | * On success: returns zero |
| 203 | * On error: return code is negative errno value |
| 204 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 205 | static ssize_t write_svc(struct file *file, char *buf, size_t size) |
| 206 | { |
| 207 | struct nfsctl_svc *data; |
NeilBrown | 82e12fe | 2009-06-16 11:03:07 +1000 | [diff] [blame] | 208 | int err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 209 | if (size < sizeof(*data)) |
| 210 | return -EINVAL; |
| 211 | data = (struct nfsctl_svc*) buf; |
NeilBrown | 82e12fe | 2009-06-16 11:03:07 +1000 | [diff] [blame] | 212 | err = nfsd_svc(data->svc_port, data->svc_nthreads); |
| 213 | if (err < 0) |
| 214 | return err; |
| 215 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 216 | } |
| 217 | |
Chuck Lever | 262a098 | 2008-12-12 16:57:35 -0500 | [diff] [blame] | 218 | /** |
| 219 | * write_add - Add or modify client entry in auth unix cache |
| 220 | * |
| 221 | * Deprecated. /proc/net/rpc/auth.unix.ip is preferred. |
| 222 | * Function remains to support old versions of nfs-utils. |
| 223 | * |
| 224 | * Input: |
| 225 | * buf: struct nfsctl_client |
| 226 | * cl_ident: '\0'-terminated C string |
| 227 | * containing domain name |
| 228 | * of client |
| 229 | * cl_naddr: no. of items in cl_addrlist |
| 230 | * cl_addrlist: array of client addresses |
| 231 | * cl_fhkeytype: ignored |
| 232 | * cl_fhkeylen: ignored |
| 233 | * cl_fhkey: ignored |
| 234 | * size: size in bytes of passed in nfsctl_client |
| 235 | * Output: |
| 236 | * On success: returns zero |
| 237 | * On error: return code is negative errno value |
| 238 | * |
| 239 | * Note: Only AF_INET client addresses are passed in, since |
| 240 | * nfsctl_client.cl_addrlist contains only in_addr fields for addresses. |
| 241 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 242 | static ssize_t write_add(struct file *file, char *buf, size_t size) |
| 243 | { |
| 244 | struct nfsctl_client *data; |
| 245 | if (size < sizeof(*data)) |
| 246 | return -EINVAL; |
| 247 | data = (struct nfsctl_client *)buf; |
| 248 | return exp_addclient(data); |
| 249 | } |
| 250 | |
Chuck Lever | 262a098 | 2008-12-12 16:57:35 -0500 | [diff] [blame] | 251 | /** |
| 252 | * write_del - Remove client from auth unix cache |
| 253 | * |
| 254 | * Deprecated. /proc/net/rpc/auth.unix.ip is preferred. |
| 255 | * Function remains to support old versions of nfs-utils. |
| 256 | * |
| 257 | * Input: |
| 258 | * buf: struct nfsctl_client |
| 259 | * cl_ident: '\0'-terminated C string |
| 260 | * containing domain name |
| 261 | * of client |
| 262 | * cl_naddr: ignored |
| 263 | * cl_addrlist: ignored |
| 264 | * cl_fhkeytype: ignored |
| 265 | * cl_fhkeylen: ignored |
| 266 | * cl_fhkey: ignored |
| 267 | * size: size in bytes of passed in nfsctl_client |
| 268 | * Output: |
| 269 | * On success: returns zero |
| 270 | * On error: return code is negative errno value |
| 271 | * |
| 272 | * Note: Only AF_INET client addresses are passed in, since |
| 273 | * nfsctl_client.cl_addrlist contains only in_addr fields for addresses. |
| 274 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 275 | static ssize_t write_del(struct file *file, char *buf, size_t size) |
| 276 | { |
| 277 | struct nfsctl_client *data; |
| 278 | if (size < sizeof(*data)) |
| 279 | return -EINVAL; |
| 280 | data = (struct nfsctl_client *)buf; |
| 281 | return exp_delclient(data); |
| 282 | } |
| 283 | |
Chuck Lever | 262a098 | 2008-12-12 16:57:35 -0500 | [diff] [blame] | 284 | /** |
| 285 | * write_export - Export part or all of a local file system |
| 286 | * |
| 287 | * Deprecated. /proc/net/rpc/{nfsd.export,nfsd.fh} are preferred. |
| 288 | * Function remains to support old versions of nfs-utils. |
| 289 | * |
| 290 | * Input: |
| 291 | * buf: struct nfsctl_export |
| 292 | * ex_client: '\0'-terminated C string |
| 293 | * containing domain name |
| 294 | * of client allowed to access |
| 295 | * this export |
| 296 | * ex_path: '\0'-terminated C string |
| 297 | * containing pathname of |
| 298 | * directory in local file system |
| 299 | * ex_dev: fsid to use for this export |
| 300 | * ex_ino: ignored |
| 301 | * ex_flags: export flags for this export |
| 302 | * ex_anon_uid: UID to use for anonymous |
| 303 | * requests |
| 304 | * ex_anon_gid: GID to use for anonymous |
| 305 | * requests |
| 306 | * size: size in bytes of passed in nfsctl_export |
| 307 | * Output: |
| 308 | * On success: returns zero |
| 309 | * On error: return code is negative errno value |
| 310 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 311 | static ssize_t write_export(struct file *file, char *buf, size_t size) |
| 312 | { |
| 313 | struct nfsctl_export *data; |
| 314 | if (size < sizeof(*data)) |
| 315 | return -EINVAL; |
| 316 | data = (struct nfsctl_export*)buf; |
| 317 | return exp_export(data); |
| 318 | } |
| 319 | |
Chuck Lever | 262a098 | 2008-12-12 16:57:35 -0500 | [diff] [blame] | 320 | /** |
| 321 | * write_unexport - Unexport a previously exported file system |
| 322 | * |
| 323 | * Deprecated. /proc/net/rpc/{nfsd.export,nfsd.fh} are preferred. |
| 324 | * Function remains to support old versions of nfs-utils. |
| 325 | * |
| 326 | * Input: |
| 327 | * buf: struct nfsctl_export |
| 328 | * ex_client: '\0'-terminated C string |
| 329 | * containing domain name |
| 330 | * of client no longer allowed |
| 331 | * to access this export |
| 332 | * ex_path: '\0'-terminated C string |
| 333 | * containing pathname of |
| 334 | * directory in local file system |
| 335 | * ex_dev: ignored |
| 336 | * ex_ino: ignored |
| 337 | * ex_flags: ignored |
| 338 | * ex_anon_uid: ignored |
| 339 | * ex_anon_gid: ignored |
| 340 | * size: size in bytes of passed in nfsctl_export |
| 341 | * Output: |
| 342 | * On success: returns zero |
| 343 | * On error: return code is negative errno value |
| 344 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 345 | static ssize_t write_unexport(struct file *file, char *buf, size_t size) |
| 346 | { |
| 347 | struct nfsctl_export *data; |
| 348 | |
| 349 | if (size < sizeof(*data)) |
| 350 | return -EINVAL; |
| 351 | data = (struct nfsctl_export*)buf; |
| 352 | return exp_unexport(data); |
| 353 | } |
| 354 | |
Chuck Lever | 262a098 | 2008-12-12 16:57:35 -0500 | [diff] [blame] | 355 | /** |
| 356 | * write_getfs - Get a variable-length NFS file handle by path |
| 357 | * |
| 358 | * Deprecated. /proc/fs/nfsd/filehandle is preferred. |
| 359 | * Function remains to support old versions of nfs-utils. |
| 360 | * |
| 361 | * Input: |
| 362 | * buf: struct nfsctl_fsparm |
| 363 | * gd_addr: socket address of client |
| 364 | * gd_path: '\0'-terminated C string |
| 365 | * containing pathname of |
| 366 | * directory in local file system |
| 367 | * gd_maxlen: maximum size of returned file |
| 368 | * handle |
| 369 | * size: size in bytes of passed in nfsctl_fsparm |
| 370 | * Output: |
| 371 | * On success: passed-in buffer filled with a knfsd_fh structure |
| 372 | * (a variable-length raw NFS file handle); |
| 373 | * return code is the size in bytes of the file handle |
| 374 | * On error: return code is negative errno value |
| 375 | * |
| 376 | * Note: Only AF_INET client addresses are passed in, since gd_addr |
| 377 | * is the same size as a struct sockaddr_in. |
| 378 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 379 | static ssize_t write_getfs(struct file *file, char *buf, size_t size) |
| 380 | { |
| 381 | struct nfsctl_fsparm *data; |
| 382 | struct sockaddr_in *sin; |
| 383 | struct auth_domain *clp; |
| 384 | int err = 0; |
| 385 | struct knfsd_fh *res; |
Aurélien Charbon | f15364b | 2008-01-18 15:50:56 +0100 | [diff] [blame] | 386 | struct in6_addr in6; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 387 | |
| 388 | if (size < sizeof(*data)) |
| 389 | return -EINVAL; |
| 390 | data = (struct nfsctl_fsparm*)buf; |
| 391 | err = -EPROTONOSUPPORT; |
| 392 | if (data->gd_addr.sa_family != AF_INET) |
| 393 | goto out; |
| 394 | sin = (struct sockaddr_in *)&data->gd_addr; |
| 395 | if (data->gd_maxlen > NFS3_FHSIZE) |
| 396 | data->gd_maxlen = NFS3_FHSIZE; |
| 397 | |
| 398 | res = (struct knfsd_fh*)buf; |
| 399 | |
| 400 | exp_readlock(); |
Aurélien Charbon | f15364b | 2008-01-18 15:50:56 +0100 | [diff] [blame] | 401 | |
| 402 | ipv6_addr_set_v4mapped(sin->sin_addr.s_addr, &in6); |
| 403 | |
| 404 | clp = auth_unix_lookup(&in6); |
| 405 | if (!clp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 406 | err = -EPERM; |
| 407 | else { |
| 408 | err = exp_rootfh(clp, data->gd_path, res, data->gd_maxlen); |
| 409 | auth_domain_put(clp); |
| 410 | } |
| 411 | exp_readunlock(); |
| 412 | if (err == 0) |
Andrew Morton | 1212749 | 2007-07-17 04:04:34 -0700 | [diff] [blame] | 413 | err = res->fh_size + offsetof(struct knfsd_fh, fh_base); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 414 | out: |
| 415 | return err; |
| 416 | } |
| 417 | |
Chuck Lever | 262a098 | 2008-12-12 16:57:35 -0500 | [diff] [blame] | 418 | /** |
| 419 | * write_getfd - Get a fixed-length NFS file handle by path (used by mountd) |
| 420 | * |
| 421 | * Deprecated. /proc/fs/nfsd/filehandle is preferred. |
| 422 | * Function remains to support old versions of nfs-utils. |
| 423 | * |
| 424 | * Input: |
| 425 | * buf: struct nfsctl_fdparm |
| 426 | * gd_addr: socket address of client |
| 427 | * gd_path: '\0'-terminated C string |
| 428 | * containing pathname of |
| 429 | * directory in local file system |
| 430 | * gd_version: fdparm structure version |
| 431 | * size: size in bytes of passed in nfsctl_fdparm |
| 432 | * Output: |
| 433 | * On success: passed-in buffer filled with nfsctl_res |
| 434 | * (a fixed-length raw NFS file handle); |
| 435 | * return code is the size in bytes of the file handle |
| 436 | * On error: return code is negative errno value |
| 437 | * |
| 438 | * Note: Only AF_INET client addresses are passed in, since gd_addr |
| 439 | * is the same size as a struct sockaddr_in. |
| 440 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 441 | static ssize_t write_getfd(struct file *file, char *buf, size_t size) |
| 442 | { |
| 443 | struct nfsctl_fdparm *data; |
| 444 | struct sockaddr_in *sin; |
| 445 | struct auth_domain *clp; |
| 446 | int err = 0; |
| 447 | struct knfsd_fh fh; |
| 448 | char *res; |
Aurélien Charbon | f15364b | 2008-01-18 15:50:56 +0100 | [diff] [blame] | 449 | struct in6_addr in6; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 450 | |
| 451 | if (size < sizeof(*data)) |
| 452 | return -EINVAL; |
| 453 | data = (struct nfsctl_fdparm*)buf; |
| 454 | err = -EPROTONOSUPPORT; |
| 455 | if (data->gd_addr.sa_family != AF_INET) |
| 456 | goto out; |
| 457 | err = -EINVAL; |
| 458 | if (data->gd_version < 2 || data->gd_version > NFSSVC_MAXVERS) |
| 459 | goto out; |
| 460 | |
| 461 | res = buf; |
| 462 | sin = (struct sockaddr_in *)&data->gd_addr; |
| 463 | exp_readlock(); |
Aurélien Charbon | f15364b | 2008-01-18 15:50:56 +0100 | [diff] [blame] | 464 | |
| 465 | ipv6_addr_set_v4mapped(sin->sin_addr.s_addr, &in6); |
| 466 | |
| 467 | clp = auth_unix_lookup(&in6); |
| 468 | if (!clp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 469 | err = -EPERM; |
| 470 | else { |
| 471 | err = exp_rootfh(clp, data->gd_path, &fh, NFS_FHSIZE); |
| 472 | auth_domain_put(clp); |
| 473 | } |
| 474 | exp_readunlock(); |
| 475 | |
| 476 | if (err == 0) { |
| 477 | memset(res,0, NFS_FHSIZE); |
| 478 | memcpy(res, &fh.fh_base, fh.fh_size); |
| 479 | err = NFS_FHSIZE; |
| 480 | } |
| 481 | out: |
| 482 | return err; |
| 483 | } |
| 484 | |
Chuck Lever | 262a098 | 2008-12-12 16:57:35 -0500 | [diff] [blame] | 485 | /** |
| 486 | * write_unlock_ip - Release all locks used by a client |
| 487 | * |
| 488 | * Experimental. |
| 489 | * |
| 490 | * Input: |
| 491 | * buf: '\n'-terminated C string containing a |
Chuck Lever | 4116092 | 2009-08-09 15:09:40 -0400 | [diff] [blame] | 492 | * presentation format IP address |
Chuck Lever | 262a098 | 2008-12-12 16:57:35 -0500 | [diff] [blame] | 493 | * size: length of C string in @buf |
| 494 | * Output: |
| 495 | * On success: returns zero if all specified locks were released; |
| 496 | * returns one if one or more locks were not released |
| 497 | * On error: return code is negative errno value |
Chuck Lever | 262a098 | 2008-12-12 16:57:35 -0500 | [diff] [blame] | 498 | */ |
Chuck Lever | b046ccd | 2008-12-12 16:57:13 -0500 | [diff] [blame] | 499 | static ssize_t write_unlock_ip(struct file *file, char *buf, size_t size) |
Wendy Cheng | 4373ea8 | 2008-01-17 11:10:12 -0500 | [diff] [blame] | 500 | { |
Chuck Lever | 4116092 | 2009-08-09 15:09:40 -0400 | [diff] [blame] | 501 | struct sockaddr_storage address; |
| 502 | struct sockaddr *sap = (struct sockaddr *)&address; |
| 503 | size_t salen = sizeof(address); |
Chuck Lever | 367c8c7 | 2008-06-30 18:58:14 -0400 | [diff] [blame] | 504 | char *fo_path; |
Wendy Cheng | 4373ea8 | 2008-01-17 11:10:12 -0500 | [diff] [blame] | 505 | |
| 506 | /* sanity check */ |
| 507 | if (size == 0) |
| 508 | return -EINVAL; |
| 509 | |
| 510 | if (buf[size-1] != '\n') |
| 511 | return -EINVAL; |
| 512 | |
| 513 | fo_path = buf; |
| 514 | if (qword_get(&buf, fo_path, size) < 0) |
| 515 | return -EINVAL; |
| 516 | |
Chuck Lever | 4116092 | 2009-08-09 15:09:40 -0400 | [diff] [blame] | 517 | if (rpc_pton(fo_path, size, sap, salen) == 0) |
Wendy Cheng | 4373ea8 | 2008-01-17 11:10:12 -0500 | [diff] [blame] | 518 | return -EINVAL; |
Wendy Cheng | 4373ea8 | 2008-01-17 11:10:12 -0500 | [diff] [blame] | 519 | |
Chuck Lever | 4116092 | 2009-08-09 15:09:40 -0400 | [diff] [blame] | 520 | return nlmsvc_unlock_all_by_ip(sap); |
Wendy Cheng | 4373ea8 | 2008-01-17 11:10:12 -0500 | [diff] [blame] | 521 | } |
| 522 | |
Chuck Lever | 262a098 | 2008-12-12 16:57:35 -0500 | [diff] [blame] | 523 | /** |
| 524 | * write_unlock_fs - Release all locks on a local file system |
| 525 | * |
| 526 | * Experimental. |
| 527 | * |
| 528 | * Input: |
| 529 | * buf: '\n'-terminated C string containing the |
| 530 | * absolute pathname of a local file system |
| 531 | * size: length of C string in @buf |
| 532 | * Output: |
| 533 | * On success: returns zero if all specified locks were released; |
| 534 | * returns one if one or more locks were not released |
| 535 | * On error: return code is negative errno value |
| 536 | */ |
Chuck Lever | b046ccd | 2008-12-12 16:57:13 -0500 | [diff] [blame] | 537 | static ssize_t write_unlock_fs(struct file *file, char *buf, size_t size) |
Wendy Cheng | 17efa37 | 2008-01-17 11:10:12 -0500 | [diff] [blame] | 538 | { |
Al Viro | a63bb99 | 2008-08-02 01:03:36 -0400 | [diff] [blame] | 539 | struct path path; |
Wendy Cheng | 17efa37 | 2008-01-17 11:10:12 -0500 | [diff] [blame] | 540 | char *fo_path; |
| 541 | int error; |
| 542 | |
| 543 | /* sanity check */ |
| 544 | if (size == 0) |
| 545 | return -EINVAL; |
| 546 | |
| 547 | if (buf[size-1] != '\n') |
| 548 | return -EINVAL; |
| 549 | |
| 550 | fo_path = buf; |
| 551 | if (qword_get(&buf, fo_path, size) < 0) |
| 552 | return -EINVAL; |
| 553 | |
Al Viro | a63bb99 | 2008-08-02 01:03:36 -0400 | [diff] [blame] | 554 | error = kern_path(fo_path, 0, &path); |
Wendy Cheng | 17efa37 | 2008-01-17 11:10:12 -0500 | [diff] [blame] | 555 | if (error) |
| 556 | return error; |
| 557 | |
Chuck Lever | 262a098 | 2008-12-12 16:57:35 -0500 | [diff] [blame] | 558 | /* |
| 559 | * XXX: Needs better sanity checking. Otherwise we could end up |
| 560 | * releasing locks on the wrong file system. |
| 561 | * |
| 562 | * For example: |
| 563 | * 1. Does the path refer to a directory? |
| 564 | * 2. Is that directory a mount point, or |
| 565 | * 3. Is that directory the root of an exported file system? |
| 566 | */ |
Al Viro | a63bb99 | 2008-08-02 01:03:36 -0400 | [diff] [blame] | 567 | error = nlmsvc_unlock_all_by_sb(path.mnt->mnt_sb); |
Wendy Cheng | 17efa37 | 2008-01-17 11:10:12 -0500 | [diff] [blame] | 568 | |
Al Viro | a63bb99 | 2008-08-02 01:03:36 -0400 | [diff] [blame] | 569 | path_put(&path); |
Wendy Cheng | 17efa37 | 2008-01-17 11:10:12 -0500 | [diff] [blame] | 570 | return error; |
| 571 | } |
| 572 | |
Chuck Lever | 262a098 | 2008-12-12 16:57:35 -0500 | [diff] [blame] | 573 | /** |
| 574 | * write_filehandle - Get a variable-length NFS file handle by path |
| 575 | * |
| 576 | * On input, the buffer contains a '\n'-terminated C string comprised of |
| 577 | * three alphanumeric words separated by whitespace. The string may |
| 578 | * contain escape sequences. |
| 579 | * |
| 580 | * Input: |
| 581 | * buf: |
| 582 | * domain: client domain name |
| 583 | * path: export pathname |
| 584 | * maxsize: numeric maximum size of |
| 585 | * @buf |
| 586 | * size: length of C string in @buf |
| 587 | * Output: |
| 588 | * On success: passed-in buffer filled with '\n'-terminated C |
| 589 | * string containing a ASCII hex text version |
| 590 | * of the NFS file handle; |
| 591 | * return code is the size in bytes of the string |
| 592 | * On error: return code is negative errno value |
| 593 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 594 | static ssize_t write_filehandle(struct file *file, char *buf, size_t size) |
| 595 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 596 | char *dname, *path; |
Andrew Morton | 246d95b | 2007-08-09 00:53:50 -0700 | [diff] [blame] | 597 | int uninitialized_var(maxsize); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 598 | char *mesg = buf; |
| 599 | int len; |
| 600 | struct auth_domain *dom; |
| 601 | struct knfsd_fh fh; |
| 602 | |
J. Bruce Fields | 87d26ea | 2008-01-22 17:40:42 -0500 | [diff] [blame] | 603 | if (size == 0) |
| 604 | return -EINVAL; |
| 605 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 606 | if (buf[size-1] != '\n') |
| 607 | return -EINVAL; |
| 608 | buf[size-1] = 0; |
| 609 | |
| 610 | dname = mesg; |
| 611 | len = qword_get(&mesg, dname, size); |
Chuck Lever | 54224f0 | 2008-12-12 16:57:20 -0500 | [diff] [blame] | 612 | if (len <= 0) |
| 613 | return -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 614 | |
| 615 | path = dname+len+1; |
| 616 | len = qword_get(&mesg, path, size); |
Chuck Lever | 54224f0 | 2008-12-12 16:57:20 -0500 | [diff] [blame] | 617 | if (len <= 0) |
| 618 | return -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 619 | |
| 620 | len = get_int(&mesg, &maxsize); |
| 621 | if (len) |
| 622 | return len; |
| 623 | |
| 624 | if (maxsize < NFS_FHSIZE) |
| 625 | return -EINVAL; |
| 626 | if (maxsize > NFS3_FHSIZE) |
| 627 | maxsize = NFS3_FHSIZE; |
| 628 | |
| 629 | if (qword_get(&mesg, mesg, size)>0) |
| 630 | return -EINVAL; |
| 631 | |
| 632 | /* we have all the words, they are in buf.. */ |
| 633 | dom = unix_domain_find(dname); |
| 634 | if (!dom) |
| 635 | return -ENOMEM; |
| 636 | |
| 637 | len = exp_rootfh(dom, path, &fh, maxsize); |
| 638 | auth_domain_put(dom); |
| 639 | if (len) |
| 640 | return len; |
| 641 | |
Chuck Lever | 54224f0 | 2008-12-12 16:57:20 -0500 | [diff] [blame] | 642 | mesg = buf; |
| 643 | len = SIMPLE_TRANSACTION_LIMIT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 644 | qword_addhex(&mesg, &len, (char*)&fh.fh_base, fh.fh_size); |
| 645 | mesg[-1] = '\n'; |
| 646 | return mesg - buf; |
| 647 | } |
| 648 | |
Chuck Lever | 262a098 | 2008-12-12 16:57:35 -0500 | [diff] [blame] | 649 | /** |
| 650 | * write_threads - Start NFSD, or report the current number of running threads |
| 651 | * |
| 652 | * Input: |
| 653 | * buf: ignored |
| 654 | * size: zero |
| 655 | * Output: |
| 656 | * On success: passed-in buffer filled with '\n'-terminated C |
| 657 | * string numeric value representing the number of |
| 658 | * running NFSD threads; |
| 659 | * return code is the size in bytes of the string |
| 660 | * On error: return code is zero |
| 661 | * |
| 662 | * OR |
| 663 | * |
| 664 | * Input: |
| 665 | * buf: C string containing an unsigned |
| 666 | * integer value representing the |
| 667 | * number of NFSD threads to start |
| 668 | * size: non-zero length of C string in @buf |
| 669 | * Output: |
| 670 | * On success: NFS service is started; |
| 671 | * passed-in buffer filled with '\n'-terminated C |
| 672 | * string numeric value representing the number of |
| 673 | * running NFSD threads; |
| 674 | * return code is the size in bytes of the string |
| 675 | * On error: return code is zero or a negative errno value |
| 676 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 677 | static ssize_t write_threads(struct file *file, char *buf, size_t size) |
| 678 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 679 | char *mesg = buf; |
| 680 | int rv; |
| 681 | if (size > 0) { |
| 682 | int newthreads; |
| 683 | rv = get_int(&mesg, &newthreads); |
| 684 | if (rv) |
| 685 | return rv; |
Chuck Lever | 9e07485 | 2008-12-12 16:57:27 -0500 | [diff] [blame] | 686 | if (newthreads < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 687 | return -EINVAL; |
Chuck Lever | 9e07485 | 2008-12-12 16:57:27 -0500 | [diff] [blame] | 688 | rv = nfsd_svc(NFS_PORT, newthreads); |
NeilBrown | 82e12fe | 2009-06-16 11:03:07 +1000 | [diff] [blame] | 689 | if (rv < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 690 | return rv; |
NeilBrown | 82e12fe | 2009-06-16 11:03:07 +1000 | [diff] [blame] | 691 | } else |
| 692 | rv = nfsd_nrthreads(); |
Chuck Lever | e06b640 | 2009-04-23 19:33:25 -0400 | [diff] [blame] | 693 | |
NeilBrown | 82e12fe | 2009-06-16 11:03:07 +1000 | [diff] [blame] | 694 | return scnprintf(buf, SIMPLE_TRANSACTION_LIMIT, "%d\n", rv); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 695 | } |
| 696 | |
Chuck Lever | 262a098 | 2008-12-12 16:57:35 -0500 | [diff] [blame] | 697 | /** |
| 698 | * write_pool_threads - Set or report the current number of threads per pool |
| 699 | * |
| 700 | * Input: |
| 701 | * buf: ignored |
| 702 | * size: zero |
| 703 | * |
| 704 | * OR |
| 705 | * |
| 706 | * Input: |
| 707 | * buf: C string containing whitespace- |
| 708 | * separated unsigned integer values |
| 709 | * representing the number of NFSD |
| 710 | * threads to start in each pool |
| 711 | * size: non-zero length of C string in @buf |
| 712 | * Output: |
| 713 | * On success: passed-in buffer filled with '\n'-terminated C |
| 714 | * string containing integer values representing the |
| 715 | * number of NFSD threads in each pool; |
| 716 | * return code is the size in bytes of the string |
| 717 | * On error: return code is zero or a negative errno value |
| 718 | */ |
Greg Banks | eed2965 | 2006-10-02 02:18:02 -0700 | [diff] [blame] | 719 | static ssize_t write_pool_threads(struct file *file, char *buf, size_t size) |
| 720 | { |
| 721 | /* if size > 0, look for an array of number of threads per node |
| 722 | * and apply them then write out number of threads per node as reply |
| 723 | */ |
| 724 | char *mesg = buf; |
| 725 | int i; |
| 726 | int rv; |
| 727 | int len; |
Neil Brown | bedbdd8 | 2008-06-10 08:40:35 -0400 | [diff] [blame] | 728 | int npools; |
Greg Banks | eed2965 | 2006-10-02 02:18:02 -0700 | [diff] [blame] | 729 | int *nthreads; |
| 730 | |
Neil Brown | bedbdd8 | 2008-06-10 08:40:35 -0400 | [diff] [blame] | 731 | mutex_lock(&nfsd_mutex); |
| 732 | npools = nfsd_nrpools(); |
Greg Banks | eed2965 | 2006-10-02 02:18:02 -0700 | [diff] [blame] | 733 | if (npools == 0) { |
| 734 | /* |
| 735 | * NFS is shut down. The admin can start it by |
| 736 | * writing to the threads file but NOT the pool_threads |
| 737 | * file, sorry. Report zero threads. |
| 738 | */ |
Neil Brown | bedbdd8 | 2008-06-10 08:40:35 -0400 | [diff] [blame] | 739 | mutex_unlock(&nfsd_mutex); |
Greg Banks | eed2965 | 2006-10-02 02:18:02 -0700 | [diff] [blame] | 740 | strcpy(buf, "0\n"); |
| 741 | return strlen(buf); |
| 742 | } |
| 743 | |
| 744 | nthreads = kcalloc(npools, sizeof(int), GFP_KERNEL); |
Neil Brown | bedbdd8 | 2008-06-10 08:40:35 -0400 | [diff] [blame] | 745 | rv = -ENOMEM; |
Greg Banks | eed2965 | 2006-10-02 02:18:02 -0700 | [diff] [blame] | 746 | if (nthreads == NULL) |
Neil Brown | bedbdd8 | 2008-06-10 08:40:35 -0400 | [diff] [blame] | 747 | goto out_free; |
Greg Banks | eed2965 | 2006-10-02 02:18:02 -0700 | [diff] [blame] | 748 | |
| 749 | if (size > 0) { |
| 750 | for (i = 0; i < npools; i++) { |
| 751 | rv = get_int(&mesg, &nthreads[i]); |
| 752 | if (rv == -ENOENT) |
| 753 | break; /* fewer numbers than pools */ |
| 754 | if (rv) |
| 755 | goto out_free; /* syntax error */ |
| 756 | rv = -EINVAL; |
| 757 | if (nthreads[i] < 0) |
| 758 | goto out_free; |
| 759 | } |
| 760 | rv = nfsd_set_nrthreads(i, nthreads); |
| 761 | if (rv) |
| 762 | goto out_free; |
| 763 | } |
| 764 | |
| 765 | rv = nfsd_get_nrthreads(npools, nthreads); |
| 766 | if (rv) |
| 767 | goto out_free; |
| 768 | |
| 769 | mesg = buf; |
| 770 | size = SIMPLE_TRANSACTION_LIMIT; |
| 771 | for (i = 0; i < npools && size > 0; i++) { |
| 772 | snprintf(mesg, size, "%d%c", nthreads[i], (i == npools-1 ? '\n' : ' ')); |
| 773 | len = strlen(mesg); |
| 774 | size -= len; |
| 775 | mesg += len; |
| 776 | } |
J. Bruce Fields | 413d63d710 | 2009-07-28 11:37:25 -0400 | [diff] [blame] | 777 | rv = mesg - buf; |
Greg Banks | eed2965 | 2006-10-02 02:18:02 -0700 | [diff] [blame] | 778 | out_free: |
| 779 | kfree(nthreads); |
Neil Brown | bedbdd8 | 2008-06-10 08:40:35 -0400 | [diff] [blame] | 780 | mutex_unlock(&nfsd_mutex); |
Greg Banks | eed2965 | 2006-10-02 02:18:02 -0700 | [diff] [blame] | 781 | return rv; |
| 782 | } |
| 783 | |
Jeff Layton | 3dd98a3 | 2008-06-10 08:40:36 -0400 | [diff] [blame] | 784 | static ssize_t __write_versions(struct file *file, char *buf, size_t size) |
NeilBrown | 70c3b76 | 2005-11-07 01:00:25 -0800 | [diff] [blame] | 785 | { |
NeilBrown | 70c3b76 | 2005-11-07 01:00:25 -0800 | [diff] [blame] | 786 | char *mesg = buf; |
Benny Halevy | 8daf220 | 2009-04-03 08:28:59 +0300 | [diff] [blame] | 787 | char *vers, *minorp, sign; |
Chuck Lever | 261758b | 2009-04-23 19:33:18 -0400 | [diff] [blame] | 788 | int len, num, remaining; |
Benny Halevy | 8daf220 | 2009-04-03 08:28:59 +0300 | [diff] [blame] | 789 | unsigned minor; |
NeilBrown | 70c3b76 | 2005-11-07 01:00:25 -0800 | [diff] [blame] | 790 | ssize_t tlen = 0; |
| 791 | char *sep; |
| 792 | |
| 793 | if (size>0) { |
| 794 | if (nfsd_serv) |
NeilBrown | 6658d3a | 2006-10-02 02:17:46 -0700 | [diff] [blame] | 795 | /* Cannot change versions without updating |
| 796 | * nfsd_serv->sv_xdrsize, and reallocing |
| 797 | * rq_argp and rq_resp |
| 798 | */ |
NeilBrown | 70c3b76 | 2005-11-07 01:00:25 -0800 | [diff] [blame] | 799 | return -EBUSY; |
| 800 | if (buf[size-1] != '\n') |
| 801 | return -EINVAL; |
| 802 | buf[size-1] = 0; |
| 803 | |
| 804 | vers = mesg; |
| 805 | len = qword_get(&mesg, vers, size); |
| 806 | if (len <= 0) return -EINVAL; |
| 807 | do { |
| 808 | sign = *vers; |
| 809 | if (sign == '+' || sign == '-') |
Benny Halevy | 8daf220 | 2009-04-03 08:28:59 +0300 | [diff] [blame] | 810 | num = simple_strtol((vers+1), &minorp, 0); |
NeilBrown | 70c3b76 | 2005-11-07 01:00:25 -0800 | [diff] [blame] | 811 | else |
Benny Halevy | 8daf220 | 2009-04-03 08:28:59 +0300 | [diff] [blame] | 812 | num = simple_strtol(vers, &minorp, 0); |
| 813 | if (*minorp == '.') { |
| 814 | if (num < 4) |
| 815 | return -EINVAL; |
| 816 | minor = simple_strtoul(minorp+1, NULL, 0); |
| 817 | if (minor == 0) |
| 818 | return -EINVAL; |
| 819 | if (nfsd_minorversion(minor, sign == '-' ? |
| 820 | NFSD_CLEAR : NFSD_SET) < 0) |
| 821 | return -EINVAL; |
| 822 | goto next; |
| 823 | } |
NeilBrown | 70c3b76 | 2005-11-07 01:00:25 -0800 | [diff] [blame] | 824 | switch(num) { |
| 825 | case 2: |
| 826 | case 3: |
| 827 | case 4: |
NeilBrown | 6658d3a | 2006-10-02 02:17:46 -0700 | [diff] [blame] | 828 | nfsd_vers(num, sign == '-' ? NFSD_CLEAR : NFSD_SET); |
NeilBrown | 70c3b76 | 2005-11-07 01:00:25 -0800 | [diff] [blame] | 829 | break; |
| 830 | default: |
| 831 | return -EINVAL; |
| 832 | } |
Benny Halevy | 8daf220 | 2009-04-03 08:28:59 +0300 | [diff] [blame] | 833 | next: |
NeilBrown | 70c3b76 | 2005-11-07 01:00:25 -0800 | [diff] [blame] | 834 | vers += len + 1; |
NeilBrown | 70c3b76 | 2005-11-07 01:00:25 -0800 | [diff] [blame] | 835 | } while ((len = qword_get(&mesg, vers, size)) > 0); |
| 836 | /* If all get turned off, turn them back on, as |
| 837 | * having no versions is BAD |
| 838 | */ |
NeilBrown | 6658d3a | 2006-10-02 02:17:46 -0700 | [diff] [blame] | 839 | nfsd_reset_versions(); |
NeilBrown | 70c3b76 | 2005-11-07 01:00:25 -0800 | [diff] [blame] | 840 | } |
Chuck Lever | 261758b | 2009-04-23 19:33:18 -0400 | [diff] [blame] | 841 | |
NeilBrown | 70c3b76 | 2005-11-07 01:00:25 -0800 | [diff] [blame] | 842 | /* Now write current state into reply buffer */ |
| 843 | len = 0; |
| 844 | sep = ""; |
Chuck Lever | 261758b | 2009-04-23 19:33:18 -0400 | [diff] [blame] | 845 | remaining = SIMPLE_TRANSACTION_LIMIT; |
NeilBrown | 70c3b76 | 2005-11-07 01:00:25 -0800 | [diff] [blame] | 846 | for (num=2 ; num <= 4 ; num++) |
NeilBrown | 6658d3a | 2006-10-02 02:17:46 -0700 | [diff] [blame] | 847 | if (nfsd_vers(num, NFSD_AVAIL)) { |
Chuck Lever | 261758b | 2009-04-23 19:33:18 -0400 | [diff] [blame] | 848 | len = snprintf(buf, remaining, "%s%c%d", sep, |
NeilBrown | 6658d3a | 2006-10-02 02:17:46 -0700 | [diff] [blame] | 849 | nfsd_vers(num, NFSD_TEST)?'+':'-', |
NeilBrown | 70c3b76 | 2005-11-07 01:00:25 -0800 | [diff] [blame] | 850 | num); |
| 851 | sep = " "; |
Chuck Lever | 261758b | 2009-04-23 19:33:18 -0400 | [diff] [blame] | 852 | |
| 853 | if (len > remaining) |
| 854 | break; |
| 855 | remaining -= len; |
| 856 | buf += len; |
| 857 | tlen += len; |
NeilBrown | 70c3b76 | 2005-11-07 01:00:25 -0800 | [diff] [blame] | 858 | } |
Benny Halevy | 8daf220 | 2009-04-03 08:28:59 +0300 | [diff] [blame] | 859 | if (nfsd_vers(4, NFSD_AVAIL)) |
Chuck Lever | 261758b | 2009-04-23 19:33:18 -0400 | [diff] [blame] | 860 | for (minor = 1; minor <= NFSD_SUPPORTED_MINOR_VERSION; |
| 861 | minor++) { |
| 862 | len = snprintf(buf, remaining, " %c4.%u", |
Benny Halevy | 8daf220 | 2009-04-03 08:28:59 +0300 | [diff] [blame] | 863 | (nfsd_vers(4, NFSD_TEST) && |
| 864 | nfsd_minorversion(minor, NFSD_TEST)) ? |
| 865 | '+' : '-', |
| 866 | minor); |
Chuck Lever | 261758b | 2009-04-23 19:33:18 -0400 | [diff] [blame] | 867 | |
| 868 | if (len > remaining) |
| 869 | break; |
| 870 | remaining -= len; |
| 871 | buf += len; |
| 872 | tlen += len; |
| 873 | } |
| 874 | |
| 875 | len = snprintf(buf, remaining, "\n"); |
| 876 | if (len > remaining) |
| 877 | return -EINVAL; |
| 878 | return tlen + len; |
NeilBrown | 70c3b76 | 2005-11-07 01:00:25 -0800 | [diff] [blame] | 879 | } |
| 880 | |
Chuck Lever | 262a098 | 2008-12-12 16:57:35 -0500 | [diff] [blame] | 881 | /** |
| 882 | * write_versions - Set or report the available NFS protocol versions |
| 883 | * |
| 884 | * Input: |
| 885 | * buf: ignored |
| 886 | * size: zero |
| 887 | * Output: |
| 888 | * On success: passed-in buffer filled with '\n'-terminated C |
| 889 | * string containing positive or negative integer |
| 890 | * values representing the current status of each |
| 891 | * protocol version; |
| 892 | * return code is the size in bytes of the string |
| 893 | * On error: return code is zero or a negative errno value |
| 894 | * |
| 895 | * OR |
| 896 | * |
| 897 | * Input: |
| 898 | * buf: C string containing whitespace- |
| 899 | * separated positive or negative |
| 900 | * integer values representing NFS |
| 901 | * protocol versions to enable ("+n") |
| 902 | * or disable ("-n") |
| 903 | * size: non-zero length of C string in @buf |
| 904 | * Output: |
| 905 | * On success: status of zero or more protocol versions has |
| 906 | * been updated; passed-in buffer filled with |
| 907 | * '\n'-terminated C string containing positive |
| 908 | * or negative integer values representing the |
| 909 | * current status of each protocol version; |
| 910 | * return code is the size in bytes of the string |
| 911 | * On error: return code is zero or a negative errno value |
| 912 | */ |
Jeff Layton | 3dd98a3 | 2008-06-10 08:40:36 -0400 | [diff] [blame] | 913 | static ssize_t write_versions(struct file *file, char *buf, size_t size) |
| 914 | { |
| 915 | ssize_t rv; |
| 916 | |
| 917 | mutex_lock(&nfsd_mutex); |
| 918 | rv = __write_versions(file, buf, size); |
| 919 | mutex_unlock(&nfsd_mutex); |
| 920 | return rv; |
| 921 | } |
| 922 | |
Chuck Lever | 4cd5dc7 | 2009-04-23 19:31:32 -0400 | [diff] [blame] | 923 | /* |
Chuck Lever | 0a5372d | 2009-04-23 19:32:10 -0400 | [diff] [blame] | 924 | * Zero-length write. Return a list of NFSD's current listener |
| 925 | * transports. |
| 926 | */ |
| 927 | static ssize_t __write_ports_names(char *buf) |
| 928 | { |
| 929 | if (nfsd_serv == NULL) |
| 930 | return 0; |
Chuck Lever | 335c54b | 2009-04-23 19:32:25 -0400 | [diff] [blame] | 931 | return svc_xprt_names(nfsd_serv, buf, SIMPLE_TRANSACTION_LIMIT); |
Chuck Lever | 0a5372d | 2009-04-23 19:32:10 -0400 | [diff] [blame] | 932 | } |
| 933 | |
| 934 | /* |
Chuck Lever | 0b7c2f6 | 2009-04-23 19:31:55 -0400 | [diff] [blame] | 935 | * A single 'fd' number was written, in which case it must be for |
| 936 | * a socket of a supported family/protocol, and we use it as an |
| 937 | * nfsd listener. |
| 938 | */ |
| 939 | static ssize_t __write_ports_addfd(char *buf) |
| 940 | { |
| 941 | char *mesg = buf; |
| 942 | int fd, err; |
| 943 | |
| 944 | err = get_int(&mesg, &fd); |
| 945 | if (err != 0 || fd < 0) |
| 946 | return -EINVAL; |
| 947 | |
| 948 | err = nfsd_create_serv(); |
| 949 | if (err != 0) |
| 950 | return err; |
| 951 | |
Chuck Lever | bfba9ab | 2009-04-23 19:32:33 -0400 | [diff] [blame] | 952 | err = svc_addsock(nfsd_serv, fd, buf, SIMPLE_TRANSACTION_LIMIT); |
Jeff Layton | 78a8d7c | 2010-07-19 16:50:05 -0400 | [diff] [blame] | 953 | if (err < 0) { |
Jeff Layton | 78a8d7c | 2010-07-19 16:50:05 -0400 | [diff] [blame] | 954 | svc_destroy(nfsd_serv); |
| 955 | return err; |
| 956 | } |
Chuck Lever | 0b7c2f6 | 2009-04-23 19:31:55 -0400 | [diff] [blame] | 957 | |
Chuck Lever | ea068ba | 2009-04-23 19:32:18 -0400 | [diff] [blame] | 958 | /* Decrease the count, but don't shut down the service */ |
| 959 | nfsd_serv->sv_nrthreads--; |
| 960 | return err; |
Chuck Lever | 0b7c2f6 | 2009-04-23 19:31:55 -0400 | [diff] [blame] | 961 | } |
| 962 | |
| 963 | /* |
Chuck Lever | 82d5659 | 2009-04-23 19:31:48 -0400 | [diff] [blame] | 964 | * A '-' followed by the 'name' of a socket means we close the socket. |
| 965 | */ |
| 966 | static ssize_t __write_ports_delfd(char *buf) |
| 967 | { |
| 968 | char *toclose; |
| 969 | int len = 0; |
| 970 | |
| 971 | toclose = kstrdup(buf + 1, GFP_KERNEL); |
| 972 | if (toclose == NULL) |
| 973 | return -ENOMEM; |
| 974 | |
| 975 | if (nfsd_serv != NULL) |
Chuck Lever | 8435d34 | 2009-04-23 19:32:40 -0400 | [diff] [blame] | 976 | len = svc_sock_names(nfsd_serv, buf, |
| 977 | SIMPLE_TRANSACTION_LIMIT, toclose); |
Chuck Lever | 82d5659 | 2009-04-23 19:31:48 -0400 | [diff] [blame] | 978 | kfree(toclose); |
| 979 | return len; |
| 980 | } |
| 981 | |
| 982 | /* |
Chuck Lever | 4eb68c2 | 2009-04-23 19:31:40 -0400 | [diff] [blame] | 983 | * A transport listener is added by writing it's transport name and |
| 984 | * a port number. |
| 985 | */ |
| 986 | static ssize_t __write_ports_addxprt(char *buf) |
| 987 | { |
| 988 | char transport[16]; |
Chuck Lever | 3749829 | 2010-01-26 14:04:22 -0500 | [diff] [blame] | 989 | struct svc_xprt *xprt; |
Chuck Lever | 4eb68c2 | 2009-04-23 19:31:40 -0400 | [diff] [blame] | 990 | int port, err; |
| 991 | |
| 992 | if (sscanf(buf, "%15s %4u", transport, &port) != 2) |
| 993 | return -EINVAL; |
| 994 | |
Alexey Dobriyan | 4be929b | 2010-05-24 14:33:03 -0700 | [diff] [blame] | 995 | if (port < 1 || port > USHRT_MAX) |
Chuck Lever | 4eb68c2 | 2009-04-23 19:31:40 -0400 | [diff] [blame] | 996 | return -EINVAL; |
| 997 | |
| 998 | err = nfsd_create_serv(); |
| 999 | if (err != 0) |
| 1000 | return err; |
| 1001 | |
| 1002 | err = svc_create_xprt(nfsd_serv, transport, |
| 1003 | PF_INET, port, SVC_SOCK_ANONYMOUS); |
Chuck Lever | 6871790 | 2010-01-26 14:04:13 -0500 | [diff] [blame] | 1004 | if (err < 0) |
Chuck Lever | 3749829 | 2010-01-26 14:04:22 -0500 | [diff] [blame] | 1005 | goto out_err; |
| 1006 | |
| 1007 | err = svc_create_xprt(nfsd_serv, transport, |
| 1008 | PF_INET6, port, SVC_SOCK_ANONYMOUS); |
| 1009 | if (err < 0 && err != -EAFNOSUPPORT) |
| 1010 | goto out_close; |
Jeff Layton | 0cd14a0 | 2010-07-19 16:50:06 -0400 | [diff] [blame] | 1011 | |
| 1012 | /* Decrease the count, but don't shut down the service */ |
| 1013 | nfsd_serv->sv_nrthreads--; |
Chuck Lever | 4eb68c2 | 2009-04-23 19:31:40 -0400 | [diff] [blame] | 1014 | return 0; |
Chuck Lever | 3749829 | 2010-01-26 14:04:22 -0500 | [diff] [blame] | 1015 | out_close: |
| 1016 | xprt = svc_find_xprt(nfsd_serv, transport, PF_INET, port); |
| 1017 | if (xprt != NULL) { |
| 1018 | svc_close_xprt(xprt); |
| 1019 | svc_xprt_put(xprt); |
| 1020 | } |
| 1021 | out_err: |
Jeff Layton | 0cd14a0 | 2010-07-19 16:50:06 -0400 | [diff] [blame] | 1022 | svc_destroy(nfsd_serv); |
Chuck Lever | 3749829 | 2010-01-26 14:04:22 -0500 | [diff] [blame] | 1023 | return err; |
Chuck Lever | 4eb68c2 | 2009-04-23 19:31:40 -0400 | [diff] [blame] | 1024 | } |
| 1025 | |
| 1026 | /* |
Chuck Lever | 4cd5dc7 | 2009-04-23 19:31:32 -0400 | [diff] [blame] | 1027 | * A transport listener is removed by writing a "-", it's transport |
| 1028 | * name, and it's port number. |
| 1029 | */ |
| 1030 | static ssize_t __write_ports_delxprt(char *buf) |
| 1031 | { |
| 1032 | struct svc_xprt *xprt; |
| 1033 | char transport[16]; |
| 1034 | int port; |
| 1035 | |
| 1036 | if (sscanf(&buf[1], "%15s %4u", transport, &port) != 2) |
| 1037 | return -EINVAL; |
| 1038 | |
Alexey Dobriyan | 4be929b | 2010-05-24 14:33:03 -0700 | [diff] [blame] | 1039 | if (port < 1 || port > USHRT_MAX || nfsd_serv == NULL) |
Chuck Lever | 4cd5dc7 | 2009-04-23 19:31:32 -0400 | [diff] [blame] | 1040 | return -EINVAL; |
| 1041 | |
| 1042 | xprt = svc_find_xprt(nfsd_serv, transport, AF_UNSPEC, port); |
| 1043 | if (xprt == NULL) |
| 1044 | return -ENOTCONN; |
| 1045 | |
| 1046 | svc_close_xprt(xprt); |
| 1047 | svc_xprt_put(xprt); |
| 1048 | return 0; |
| 1049 | } |
| 1050 | |
Neil Brown | bedbdd8 | 2008-06-10 08:40:35 -0400 | [diff] [blame] | 1051 | static ssize_t __write_ports(struct file *file, char *buf, size_t size) |
NeilBrown | 80212d5 | 2006-10-02 02:17:47 -0700 | [diff] [blame] | 1052 | { |
Chuck Lever | 0a5372d | 2009-04-23 19:32:10 -0400 | [diff] [blame] | 1053 | if (size == 0) |
| 1054 | return __write_ports_names(buf); |
Chuck Lever | 0b7c2f6 | 2009-04-23 19:31:55 -0400 | [diff] [blame] | 1055 | |
| 1056 | if (isdigit(buf[0])) |
| 1057 | return __write_ports_addfd(buf); |
Chuck Lever | 82d5659 | 2009-04-23 19:31:48 -0400 | [diff] [blame] | 1058 | |
| 1059 | if (buf[0] == '-' && isdigit(buf[1])) |
| 1060 | return __write_ports_delfd(buf); |
Chuck Lever | 4eb68c2 | 2009-04-23 19:31:40 -0400 | [diff] [blame] | 1061 | |
| 1062 | if (isalpha(buf[0])) |
| 1063 | return __write_ports_addxprt(buf); |
Chuck Lever | 4cd5dc7 | 2009-04-23 19:31:32 -0400 | [diff] [blame] | 1064 | |
| 1065 | if (buf[0] == '-' && isalpha(buf[1])) |
| 1066 | return __write_ports_delxprt(buf); |
| 1067 | |
NeilBrown | b41b66d | 2006-10-02 02:17:48 -0700 | [diff] [blame] | 1068 | return -EINVAL; |
NeilBrown | 80212d5 | 2006-10-02 02:17:47 -0700 | [diff] [blame] | 1069 | } |
| 1070 | |
Chuck Lever | 262a098 | 2008-12-12 16:57:35 -0500 | [diff] [blame] | 1071 | /** |
| 1072 | * write_ports - Pass a socket file descriptor or transport name to listen on |
| 1073 | * |
| 1074 | * Input: |
| 1075 | * buf: ignored |
| 1076 | * size: zero |
| 1077 | * Output: |
| 1078 | * On success: passed-in buffer filled with a '\n'-terminated C |
| 1079 | * string containing a whitespace-separated list of |
| 1080 | * named NFSD listeners; |
| 1081 | * return code is the size in bytes of the string |
| 1082 | * On error: return code is zero or a negative errno value |
| 1083 | * |
| 1084 | * OR |
| 1085 | * |
| 1086 | * Input: |
| 1087 | * buf: C string containing an unsigned |
| 1088 | * integer value representing a bound |
| 1089 | * but unconnected socket that is to be |
Chuck Lever | c71206a | 2009-04-23 19:32:03 -0400 | [diff] [blame] | 1090 | * used as an NFSD listener; listen(3) |
| 1091 | * must be called for a SOCK_STREAM |
| 1092 | * socket, otherwise it is ignored |
Chuck Lever | 262a098 | 2008-12-12 16:57:35 -0500 | [diff] [blame] | 1093 | * size: non-zero length of C string in @buf |
| 1094 | * Output: |
| 1095 | * On success: NFS service is started; |
| 1096 | * passed-in buffer filled with a '\n'-terminated C |
| 1097 | * string containing a unique alphanumeric name of |
| 1098 | * the listener; |
| 1099 | * return code is the size in bytes of the string |
| 1100 | * On error: return code is a negative errno value |
| 1101 | * |
| 1102 | * OR |
| 1103 | * |
| 1104 | * Input: |
| 1105 | * buf: C string containing a "-" followed |
| 1106 | * by an integer value representing a |
| 1107 | * previously passed in socket file |
| 1108 | * descriptor |
| 1109 | * size: non-zero length of C string in @buf |
| 1110 | * Output: |
| 1111 | * On success: NFS service no longer listens on that socket; |
| 1112 | * passed-in buffer filled with a '\n'-terminated C |
| 1113 | * string containing a unique name of the listener; |
| 1114 | * return code is the size in bytes of the string |
| 1115 | * On error: return code is a negative errno value |
| 1116 | * |
| 1117 | * OR |
| 1118 | * |
| 1119 | * Input: |
| 1120 | * buf: C string containing a transport |
| 1121 | * name and an unsigned integer value |
| 1122 | * representing the port to listen on, |
| 1123 | * separated by whitespace |
| 1124 | * size: non-zero length of C string in @buf |
| 1125 | * Output: |
| 1126 | * On success: returns zero; NFS service is started |
| 1127 | * On error: return code is a negative errno value |
| 1128 | * |
| 1129 | * OR |
| 1130 | * |
| 1131 | * Input: |
| 1132 | * buf: C string containing a "-" followed |
| 1133 | * by a transport name and an unsigned |
| 1134 | * integer value representing the port |
| 1135 | * to listen on, separated by whitespace |
| 1136 | * size: non-zero length of C string in @buf |
| 1137 | * Output: |
| 1138 | * On success: returns zero; NFS service no longer listens |
| 1139 | * on that transport |
| 1140 | * On error: return code is a negative errno value |
| 1141 | */ |
Neil Brown | bedbdd8 | 2008-06-10 08:40:35 -0400 | [diff] [blame] | 1142 | static ssize_t write_ports(struct file *file, char *buf, size_t size) |
| 1143 | { |
| 1144 | ssize_t rv; |
Jeff Layton | 3dd98a3 | 2008-06-10 08:40:36 -0400 | [diff] [blame] | 1145 | |
Neil Brown | bedbdd8 | 2008-06-10 08:40:35 -0400 | [diff] [blame] | 1146 | mutex_lock(&nfsd_mutex); |
| 1147 | rv = __write_ports(file, buf, size); |
| 1148 | mutex_unlock(&nfsd_mutex); |
| 1149 | return rv; |
| 1150 | } |
| 1151 | |
| 1152 | |
NeilBrown | 596bbe5 | 2006-10-04 02:15:48 -0700 | [diff] [blame] | 1153 | int nfsd_max_blksize; |
| 1154 | |
Chuck Lever | 262a098 | 2008-12-12 16:57:35 -0500 | [diff] [blame] | 1155 | /** |
| 1156 | * write_maxblksize - Set or report the current NFS blksize |
| 1157 | * |
| 1158 | * Input: |
| 1159 | * buf: ignored |
| 1160 | * size: zero |
| 1161 | * |
| 1162 | * OR |
| 1163 | * |
| 1164 | * Input: |
| 1165 | * buf: C string containing an unsigned |
| 1166 | * integer value representing the new |
| 1167 | * NFS blksize |
| 1168 | * size: non-zero length of C string in @buf |
| 1169 | * Output: |
| 1170 | * On success: passed-in buffer filled with '\n'-terminated C string |
| 1171 | * containing numeric value of the current NFS blksize |
| 1172 | * setting; |
| 1173 | * return code is the size in bytes of the string |
| 1174 | * On error: return code is zero or a negative errno value |
| 1175 | */ |
NeilBrown | 596bbe5 | 2006-10-04 02:15:48 -0700 | [diff] [blame] | 1176 | static ssize_t write_maxblksize(struct file *file, char *buf, size_t size) |
| 1177 | { |
| 1178 | char *mesg = buf; |
| 1179 | if (size > 0) { |
| 1180 | int bsize; |
| 1181 | int rv = get_int(&mesg, &bsize); |
| 1182 | if (rv) |
| 1183 | return rv; |
| 1184 | /* force bsize into allowed range and |
| 1185 | * required alignment. |
| 1186 | */ |
| 1187 | if (bsize < 1024) |
| 1188 | bsize = 1024; |
| 1189 | if (bsize > NFSSVC_MAXBLKSIZE) |
| 1190 | bsize = NFSSVC_MAXBLKSIZE; |
| 1191 | bsize &= ~(1024-1); |
Neil Brown | bedbdd8 | 2008-06-10 08:40:35 -0400 | [diff] [blame] | 1192 | mutex_lock(&nfsd_mutex); |
J. Bruce Fields | 7fa53cc | 2010-08-06 18:00:33 -0400 | [diff] [blame] | 1193 | if (nfsd_serv) { |
Neil Brown | bedbdd8 | 2008-06-10 08:40:35 -0400 | [diff] [blame] | 1194 | mutex_unlock(&nfsd_mutex); |
NeilBrown | 596bbe5 | 2006-10-04 02:15:48 -0700 | [diff] [blame] | 1195 | return -EBUSY; |
| 1196 | } |
| 1197 | nfsd_max_blksize = bsize; |
Neil Brown | bedbdd8 | 2008-06-10 08:40:35 -0400 | [diff] [blame] | 1198 | mutex_unlock(&nfsd_mutex); |
NeilBrown | 596bbe5 | 2006-10-04 02:15:48 -0700 | [diff] [blame] | 1199 | } |
Chuck Lever | e06b640 | 2009-04-23 19:33:25 -0400 | [diff] [blame] | 1200 | |
| 1201 | return scnprintf(buf, SIMPLE_TRANSACTION_LIMIT, "%d\n", |
| 1202 | nfsd_max_blksize); |
NeilBrown | 596bbe5 | 2006-10-04 02:15:48 -0700 | [diff] [blame] | 1203 | } |
| 1204 | |
NeilBrown | 70c3b76 | 2005-11-07 01:00:25 -0800 | [diff] [blame] | 1205 | #ifdef CONFIG_NFSD_V4 |
J. Bruce Fields | f013574 | 2010-03-01 19:32:36 -0500 | [diff] [blame] | 1206 | static ssize_t __nfsd4_write_time(struct file *file, char *buf, size_t size, time_t *time) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1207 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1208 | char *mesg = buf; |
J. Bruce Fields | f013574 | 2010-03-01 19:32:36 -0500 | [diff] [blame] | 1209 | int rv, i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1210 | |
| 1211 | if (size > 0) { |
Jeff Layton | 3dd98a3 | 2008-06-10 08:40:36 -0400 | [diff] [blame] | 1212 | if (nfsd_serv) |
| 1213 | return -EBUSY; |
J. Bruce Fields | f013574 | 2010-03-01 19:32:36 -0500 | [diff] [blame] | 1214 | rv = get_int(&mesg, &i); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1215 | if (rv) |
| 1216 | return rv; |
J. Bruce Fields | e7b184f | 2010-03-02 11:18:40 -0500 | [diff] [blame] | 1217 | /* |
| 1218 | * Some sanity checking. We don't have a reason for |
| 1219 | * these particular numbers, but problems with the |
| 1220 | * extremes are: |
| 1221 | * - Too short: the briefest network outage may |
| 1222 | * cause clients to lose all their locks. Also, |
| 1223 | * the frequent polling may be wasteful. |
| 1224 | * - Too long: do you really want reboot recovery |
| 1225 | * to take more than an hour? Or to make other |
| 1226 | * clients wait an hour before being able to |
| 1227 | * revoke a dead client's locks? |
| 1228 | */ |
J. Bruce Fields | f013574 | 2010-03-01 19:32:36 -0500 | [diff] [blame] | 1229 | if (i < 10 || i > 3600) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1230 | return -EINVAL; |
J. Bruce Fields | f013574 | 2010-03-01 19:32:36 -0500 | [diff] [blame] | 1231 | *time = i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1232 | } |
Chuck Lever | e06b640 | 2009-04-23 19:33:25 -0400 | [diff] [blame] | 1233 | |
J. Bruce Fields | f013574 | 2010-03-01 19:32:36 -0500 | [diff] [blame] | 1234 | return scnprintf(buf, SIMPLE_TRANSACTION_LIMIT, "%ld\n", *time); |
| 1235 | } |
| 1236 | |
| 1237 | static ssize_t nfsd4_write_time(struct file *file, char *buf, size_t size, time_t *time) |
| 1238 | { |
| 1239 | ssize_t rv; |
| 1240 | |
| 1241 | mutex_lock(&nfsd_mutex); |
| 1242 | rv = __nfsd4_write_time(file, buf, size, time); |
| 1243 | mutex_unlock(&nfsd_mutex); |
| 1244 | return rv; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1245 | } |
| 1246 | |
Chuck Lever | 262a098 | 2008-12-12 16:57:35 -0500 | [diff] [blame] | 1247 | /** |
| 1248 | * write_leasetime - Set or report the current NFSv4 lease time |
| 1249 | * |
| 1250 | * Input: |
| 1251 | * buf: ignored |
| 1252 | * size: zero |
| 1253 | * |
| 1254 | * OR |
| 1255 | * |
| 1256 | * Input: |
| 1257 | * buf: C string containing an unsigned |
| 1258 | * integer value representing the new |
| 1259 | * NFSv4 lease expiry time |
| 1260 | * size: non-zero length of C string in @buf |
| 1261 | * Output: |
| 1262 | * On success: passed-in buffer filled with '\n'-terminated C |
| 1263 | * string containing unsigned integer value of the |
| 1264 | * current lease expiry time; |
| 1265 | * return code is the size in bytes of the string |
| 1266 | * On error: return code is zero or a negative errno value |
| 1267 | */ |
Jeff Layton | 3dd98a3 | 2008-06-10 08:40:36 -0400 | [diff] [blame] | 1268 | static ssize_t write_leasetime(struct file *file, char *buf, size_t size) |
| 1269 | { |
J. Bruce Fields | f013574 | 2010-03-01 19:32:36 -0500 | [diff] [blame] | 1270 | return nfsd4_write_time(file, buf, size, &nfsd4_lease); |
Jeff Layton | 3dd98a3 | 2008-06-10 08:40:36 -0400 | [diff] [blame] | 1271 | } |
| 1272 | |
J. Bruce Fields | efc4bb4f | 2010-03-02 11:04:06 -0500 | [diff] [blame] | 1273 | /** |
| 1274 | * write_gracetime - Set or report current NFSv4 grace period time |
| 1275 | * |
| 1276 | * As above, but sets the time of the NFSv4 grace period. |
| 1277 | * |
| 1278 | * Note this should never be set to less than the *previous* |
| 1279 | * lease-period time, but we don't try to enforce this. (In the common |
| 1280 | * case (a new boot), we don't know what the previous lease time was |
| 1281 | * anyway.) |
| 1282 | */ |
| 1283 | static ssize_t write_gracetime(struct file *file, char *buf, size_t size) |
| 1284 | { |
| 1285 | return nfsd4_write_time(file, buf, size, &nfsd4_grace); |
| 1286 | } |
| 1287 | |
Jeff Layton | 3dd98a3 | 2008-06-10 08:40:36 -0400 | [diff] [blame] | 1288 | extern char *nfs4_recoverydir(void); |
| 1289 | |
| 1290 | static ssize_t __write_recoverydir(struct file *file, char *buf, size_t size) |
NeilBrown | 0964a3d | 2005-06-23 22:04:32 -0700 | [diff] [blame] | 1291 | { |
| 1292 | char *mesg = buf; |
| 1293 | char *recdir; |
| 1294 | int len, status; |
| 1295 | |
Jeff Layton | 3dd98a3 | 2008-06-10 08:40:36 -0400 | [diff] [blame] | 1296 | if (size > 0) { |
| 1297 | if (nfsd_serv) |
| 1298 | return -EBUSY; |
| 1299 | if (size > PATH_MAX || buf[size-1] != '\n') |
| 1300 | return -EINVAL; |
| 1301 | buf[size-1] = 0; |
NeilBrown | 0964a3d | 2005-06-23 22:04:32 -0700 | [diff] [blame] | 1302 | |
Jeff Layton | 3dd98a3 | 2008-06-10 08:40:36 -0400 | [diff] [blame] | 1303 | recdir = mesg; |
| 1304 | len = qword_get(&mesg, recdir, size); |
| 1305 | if (len <= 0) |
| 1306 | return -EINVAL; |
NeilBrown | 0964a3d | 2005-06-23 22:04:32 -0700 | [diff] [blame] | 1307 | |
Jeff Layton | 3dd98a3 | 2008-06-10 08:40:36 -0400 | [diff] [blame] | 1308 | status = nfs4_reset_recoverydir(recdir); |
Andi Kleen | 6904996 | 2010-07-20 15:24:27 -0700 | [diff] [blame] | 1309 | if (status) |
| 1310 | return status; |
Jeff Layton | 3dd98a3 | 2008-06-10 08:40:36 -0400 | [diff] [blame] | 1311 | } |
Chuck Lever | 3d72ab8 | 2009-04-23 19:33:10 -0400 | [diff] [blame] | 1312 | |
| 1313 | return scnprintf(buf, SIMPLE_TRANSACTION_LIMIT, "%s\n", |
| 1314 | nfs4_recoverydir()); |
NeilBrown | 0964a3d | 2005-06-23 22:04:32 -0700 | [diff] [blame] | 1315 | } |
Jeff Layton | 3dd98a3 | 2008-06-10 08:40:36 -0400 | [diff] [blame] | 1316 | |
Chuck Lever | 262a098 | 2008-12-12 16:57:35 -0500 | [diff] [blame] | 1317 | /** |
| 1318 | * write_recoverydir - Set or report the pathname of the recovery directory |
| 1319 | * |
| 1320 | * Input: |
| 1321 | * buf: ignored |
| 1322 | * size: zero |
| 1323 | * |
| 1324 | * OR |
| 1325 | * |
| 1326 | * Input: |
| 1327 | * buf: C string containing the pathname |
| 1328 | * of the directory on a local file |
| 1329 | * system containing permanent NFSv4 |
| 1330 | * recovery data |
| 1331 | * size: non-zero length of C string in @buf |
| 1332 | * Output: |
| 1333 | * On success: passed-in buffer filled with '\n'-terminated C string |
| 1334 | * containing the current recovery pathname setting; |
| 1335 | * return code is the size in bytes of the string |
| 1336 | * On error: return code is zero or a negative errno value |
| 1337 | */ |
Jeff Layton | 3dd98a3 | 2008-06-10 08:40:36 -0400 | [diff] [blame] | 1338 | static ssize_t write_recoverydir(struct file *file, char *buf, size_t size) |
| 1339 | { |
| 1340 | ssize_t rv; |
| 1341 | |
| 1342 | mutex_lock(&nfsd_mutex); |
| 1343 | rv = __write_recoverydir(file, buf, size); |
| 1344 | mutex_unlock(&nfsd_mutex); |
| 1345 | return rv; |
| 1346 | } |
| 1347 | |
NeilBrown | 70c3b76 | 2005-11-07 01:00:25 -0800 | [diff] [blame] | 1348 | #endif |
NeilBrown | 0964a3d | 2005-06-23 22:04:32 -0700 | [diff] [blame] | 1349 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1350 | /*----------------------------------------------------------------------------*/ |
| 1351 | /* |
| 1352 | * populating the filesystem. |
| 1353 | */ |
| 1354 | |
| 1355 | static int nfsd_fill_super(struct super_block * sb, void * data, int silent) |
| 1356 | { |
| 1357 | static struct tree_descr nfsd_files[] = { |
| 1358 | [NFSD_Svc] = {".svc", &transaction_ops, S_IWUSR}, |
| 1359 | [NFSD_Add] = {".add", &transaction_ops, S_IWUSR}, |
| 1360 | [NFSD_Del] = {".del", &transaction_ops, S_IWUSR}, |
| 1361 | [NFSD_Export] = {".export", &transaction_ops, S_IWUSR}, |
| 1362 | [NFSD_Unexport] = {".unexport", &transaction_ops, S_IWUSR}, |
| 1363 | [NFSD_Getfd] = {".getfd", &transaction_ops, S_IWUSR|S_IRUSR}, |
| 1364 | [NFSD_Getfs] = {".getfs", &transaction_ops, S_IWUSR|S_IRUSR}, |
| 1365 | [NFSD_List] = {"exports", &exports_operations, S_IRUGO}, |
J. Bruce Fields | e8e8753 | 2009-12-14 12:53:32 -0500 | [diff] [blame] | 1366 | [NFSD_Export_features] = {"export_features", |
| 1367 | &export_features_operations, S_IRUGO}, |
Wendy Cheng | 4373ea8 | 2008-01-17 11:10:12 -0500 | [diff] [blame] | 1368 | [NFSD_FO_UnlockIP] = {"unlock_ip", |
| 1369 | &transaction_ops, S_IWUSR|S_IRUSR}, |
Wendy Cheng | 17efa37 | 2008-01-17 11:10:12 -0500 | [diff] [blame] | 1370 | [NFSD_FO_UnlockFS] = {"unlock_filesystem", |
| 1371 | &transaction_ops, S_IWUSR|S_IRUSR}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1372 | [NFSD_Fh] = {"filehandle", &transaction_ops, S_IWUSR|S_IRUSR}, |
| 1373 | [NFSD_Threads] = {"threads", &transaction_ops, S_IWUSR|S_IRUSR}, |
Greg Banks | eed2965 | 2006-10-02 02:18:02 -0700 | [diff] [blame] | 1374 | [NFSD_Pool_Threads] = {"pool_threads", &transaction_ops, S_IWUSR|S_IRUSR}, |
Greg Banks | 03cf6c9 | 2009-01-13 21:26:36 +1100 | [diff] [blame] | 1375 | [NFSD_Pool_Stats] = {"pool_stats", &pool_stats_operations, S_IRUGO}, |
NeilBrown | 70c3b76 | 2005-11-07 01:00:25 -0800 | [diff] [blame] | 1376 | [NFSD_Versions] = {"versions", &transaction_ops, S_IWUSR|S_IRUSR}, |
NeilBrown | 80212d5 | 2006-10-02 02:17:47 -0700 | [diff] [blame] | 1377 | [NFSD_Ports] = {"portlist", &transaction_ops, S_IWUSR|S_IRUGO}, |
NeilBrown | 596bbe5 | 2006-10-04 02:15:48 -0700 | [diff] [blame] | 1378 | [NFSD_MaxBlkSize] = {"max_block_size", &transaction_ops, S_IWUSR|S_IRUGO}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1379 | #ifdef CONFIG_NFSD_V4 |
| 1380 | [NFSD_Leasetime] = {"nfsv4leasetime", &transaction_ops, S_IWUSR|S_IRUSR}, |
J. Bruce Fields | efc4bb4f | 2010-03-02 11:04:06 -0500 | [diff] [blame] | 1381 | [NFSD_Gracetime] = {"nfsv4gracetime", &transaction_ops, S_IWUSR|S_IRUSR}, |
NeilBrown | 0964a3d | 2005-06-23 22:04:32 -0700 | [diff] [blame] | 1382 | [NFSD_RecoveryDir] = {"nfsv4recoverydir", &transaction_ops, S_IWUSR|S_IRUSR}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1383 | #endif |
| 1384 | /* last one */ {""} |
| 1385 | }; |
| 1386 | return simple_fill_super(sb, 0x6e667364, nfsd_files); |
| 1387 | } |
| 1388 | |
David Howells | 454e239 | 2006-06-23 02:02:57 -0700 | [diff] [blame] | 1389 | static int nfsd_get_sb(struct file_system_type *fs_type, |
| 1390 | int flags, const char *dev_name, void *data, struct vfsmount *mnt) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1391 | { |
David Howells | 454e239 | 2006-06-23 02:02:57 -0700 | [diff] [blame] | 1392 | return get_sb_single(fs_type, flags, data, nfsd_fill_super, mnt); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1393 | } |
| 1394 | |
| 1395 | static struct file_system_type nfsd_fs_type = { |
| 1396 | .owner = THIS_MODULE, |
| 1397 | .name = "nfsd", |
| 1398 | .get_sb = nfsd_get_sb, |
| 1399 | .kill_sb = kill_litter_super, |
| 1400 | }; |
| 1401 | |
J. Bruce Fields | e331f60 | 2007-11-12 17:32:21 -0500 | [diff] [blame] | 1402 | #ifdef CONFIG_PROC_FS |
| 1403 | static int create_proc_exports_entry(void) |
| 1404 | { |
| 1405 | struct proc_dir_entry *entry; |
| 1406 | |
| 1407 | entry = proc_mkdir("fs/nfs", NULL); |
| 1408 | if (!entry) |
| 1409 | return -ENOMEM; |
Denis V. Lunev | 9ef2db2 | 2008-04-29 01:02:04 -0700 | [diff] [blame] | 1410 | entry = proc_create("exports", 0, entry, &exports_operations); |
J. Bruce Fields | e331f60 | 2007-11-12 17:32:21 -0500 | [diff] [blame] | 1411 | if (!entry) |
| 1412 | return -ENOMEM; |
J. Bruce Fields | e331f60 | 2007-11-12 17:32:21 -0500 | [diff] [blame] | 1413 | return 0; |
| 1414 | } |
| 1415 | #else /* CONFIG_PROC_FS */ |
| 1416 | static int create_proc_exports_entry(void) |
| 1417 | { |
| 1418 | return 0; |
| 1419 | } |
| 1420 | #endif |
| 1421 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1422 | static int __init init_nfsd(void) |
| 1423 | { |
| 1424 | int retval; |
| 1425 | printk(KERN_INFO "Installing knfsd (copyright (C) 1996 okir@monad.swb.de).\n"); |
| 1426 | |
J. Bruce Fields | e8ff2a8 | 2007-08-01 15:30:59 -0400 | [diff] [blame] | 1427 | retval = nfs4_state_init(); /* nfs4 locking state */ |
| 1428 | if (retval) |
| 1429 | return retval; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1430 | nfsd_stat_init(); /* Statistics */ |
J. Bruce Fields | d5c3428 | 2007-11-09 14:10:56 -0500 | [diff] [blame] | 1431 | retval = nfsd_reply_cache_init(); |
| 1432 | if (retval) |
| 1433 | goto out_free_stat; |
J. Bruce Fields | dbf847e | 2007-11-08 17:20:34 -0500 | [diff] [blame] | 1434 | retval = nfsd_export_init(); |
| 1435 | if (retval) |
| 1436 | goto out_free_cache; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1437 | nfsd_lockd_init(); /* lockd->nfsd callbacks */ |
J. Bruce Fields | dbf847e | 2007-11-08 17:20:34 -0500 | [diff] [blame] | 1438 | retval = nfsd_idmap_init(); |
| 1439 | if (retval) |
| 1440 | goto out_free_lockd; |
J. Bruce Fields | e331f60 | 2007-11-12 17:32:21 -0500 | [diff] [blame] | 1441 | retval = create_proc_exports_entry(); |
| 1442 | if (retval) |
| 1443 | goto out_free_idmap; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1444 | retval = register_filesystem(&nfsd_fs_type); |
J. Bruce Fields | 26808d3 | 2007-11-09 13:44:06 -0500 | [diff] [blame] | 1445 | if (retval) |
| 1446 | goto out_free_all; |
| 1447 | return 0; |
| 1448 | out_free_all: |
J. Bruce Fields | 26808d3 | 2007-11-09 13:44:06 -0500 | [diff] [blame] | 1449 | remove_proc_entry("fs/nfs/exports", NULL); |
| 1450 | remove_proc_entry("fs/nfs", NULL); |
J. Bruce Fields | e331f60 | 2007-11-12 17:32:21 -0500 | [diff] [blame] | 1451 | out_free_idmap: |
J. Bruce Fields | dbf847e | 2007-11-08 17:20:34 -0500 | [diff] [blame] | 1452 | nfsd_idmap_shutdown(); |
| 1453 | out_free_lockd: |
J. Bruce Fields | 26808d3 | 2007-11-09 13:44:06 -0500 | [diff] [blame] | 1454 | nfsd_lockd_shutdown(); |
J. Bruce Fields | e331f60 | 2007-11-12 17:32:21 -0500 | [diff] [blame] | 1455 | nfsd_export_shutdown(); |
J. Bruce Fields | dbf847e | 2007-11-08 17:20:34 -0500 | [diff] [blame] | 1456 | out_free_cache: |
J. Bruce Fields | e331f60 | 2007-11-12 17:32:21 -0500 | [diff] [blame] | 1457 | nfsd_reply_cache_shutdown(); |
J. Bruce Fields | d5c3428 | 2007-11-09 14:10:56 -0500 | [diff] [blame] | 1458 | out_free_stat: |
| 1459 | nfsd_stat_shutdown(); |
J. Bruce Fields | 26808d3 | 2007-11-09 13:44:06 -0500 | [diff] [blame] | 1460 | nfsd4_free_slabs(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1461 | return retval; |
| 1462 | } |
| 1463 | |
| 1464 | static void __exit exit_nfsd(void) |
| 1465 | { |
| 1466 | nfsd_export_shutdown(); |
J. Bruce Fields | d5c3428 | 2007-11-09 14:10:56 -0500 | [diff] [blame] | 1467 | nfsd_reply_cache_shutdown(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1468 | remove_proc_entry("fs/nfs/exports", NULL); |
| 1469 | remove_proc_entry("fs/nfs", NULL); |
| 1470 | nfsd_stat_shutdown(); |
| 1471 | nfsd_lockd_shutdown(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1472 | nfsd_idmap_shutdown(); |
J. Bruce Fields | e8ff2a8 | 2007-08-01 15:30:59 -0400 | [diff] [blame] | 1473 | nfsd4_free_slabs(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1474 | unregister_filesystem(&nfsd_fs_type); |
| 1475 | } |
| 1476 | |
| 1477 | MODULE_AUTHOR("Olaf Kirch <okir@monad.swb.de>"); |
| 1478 | MODULE_LICENSE("GPL"); |
| 1479 | module_init(init_nfsd) |
| 1480 | module_exit(exit_nfsd) |