Merge remote-tracking branch 'iwlwifi-fixes/master' into NEXT
[deliverable/linux.git] / fs / nfsd / nfsctl.c
CommitLineData
1da177e4 1/*
1da177e4
LT
2 * Syscall interface to knfsd.
3 *
4 * Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de>
5 */
6
5a0e3ad6 7#include <linux/slab.h>
3f8206d4 8#include <linux/namei.h>
b41b66d6 9#include <linux/ctype.h>
1da177e4 10
80212d59 11#include <linux/sunrpc/svcsock.h>
4373ea84 12#include <linux/lockd/lockd.h>
5976687a 13#include <linux/sunrpc/addr.h>
b0b0c0a2 14#include <linux/sunrpc/gss_api.h>
b084f598 15#include <linux/sunrpc/gss_krb5_enctypes.h>
813fd320 16#include <linux/sunrpc/rpc_pipe_fs.h>
143cb494 17#include <linux/module.h>
1da177e4 18
2ca72e17 19#include "idmap.h"
9a74af21
BH
20#include "nfsd.h"
21#include "cache.h"
f3c7521f 22#include "state.h"
7ea34ac1 23#include "netns.h"
9a74af21 24
1da177e4 25/*
b0b0c0a2 26 * We have a single directory with several nodes in it.
1da177e4
LT
27 */
28enum {
29 NFSD_Root = 1,
1da177e4 30 NFSD_List,
e8e8753f 31 NFSD_Export_features,
1da177e4 32 NFSD_Fh,
4373ea84 33 NFSD_FO_UnlockIP,
17efa372 34 NFSD_FO_UnlockFS,
1da177e4 35 NFSD_Threads,
eed2965a 36 NFSD_Pool_Threads,
03cf6c9f 37 NFSD_Pool_Stats,
a2f999a3 38 NFSD_Reply_Cache_Stats,
70c3b76c 39 NFSD_Versions,
80212d59 40 NFSD_Ports,
596bbe53 41 NFSD_MaxBlkSize,
5b8db00b 42 NFSD_MaxConnections,
b0b0c0a2 43 NFSD_SupportedEnctypes,
70c3b76c
N
44 /*
45 * The below MUST come last. Otherwise we leave a hole in nfsd_files[]
46 * with !CONFIG_NFSD_V4 and simple_fill_super() goes oops
47 */
48#ifdef CONFIG_NFSD_V4
1da177e4 49 NFSD_Leasetime,
efc4bb4f 50 NFSD_Gracetime,
0964a3d3 51 NFSD_RecoveryDir,
70c3b76c 52#endif
1da177e4
LT
53};
54
55/*
56 * write() for these nodes.
57 */
1da177e4 58static ssize_t write_filehandle(struct file *file, char *buf, size_t size);
b046ccdc
CL
59static ssize_t write_unlock_ip(struct file *file, char *buf, size_t size);
60static ssize_t write_unlock_fs(struct file *file, char *buf, size_t size);
1da177e4 61static ssize_t write_threads(struct file *file, char *buf, size_t size);
eed2965a 62static ssize_t write_pool_threads(struct file *file, char *buf, size_t size);
70c3b76c 63static ssize_t write_versions(struct file *file, char *buf, size_t size);
80212d59 64static ssize_t write_ports(struct file *file, char *buf, size_t size);
596bbe53 65static ssize_t write_maxblksize(struct file *file, char *buf, size_t size);
5b8db00b 66static ssize_t write_maxconn(struct file *file, char *buf, size_t size);
70c3b76c 67#ifdef CONFIG_NFSD_V4
1da177e4 68static ssize_t write_leasetime(struct file *file, char *buf, size_t size);
efc4bb4f 69static ssize_t write_gracetime(struct file *file, char *buf, size_t size);
0964a3d3 70static ssize_t write_recoverydir(struct file *file, char *buf, size_t size);
70c3b76c 71#endif
1da177e4
LT
72
73static ssize_t (*write_op[])(struct file *, char *, size_t) = {
1da177e4 74 [NFSD_Fh] = write_filehandle,
b046ccdc
CL
75 [NFSD_FO_UnlockIP] = write_unlock_ip,
76 [NFSD_FO_UnlockFS] = write_unlock_fs,
1da177e4 77 [NFSD_Threads] = write_threads,
eed2965a 78 [NFSD_Pool_Threads] = write_pool_threads,
70c3b76c 79 [NFSD_Versions] = write_versions,
80212d59 80 [NFSD_Ports] = write_ports,
596bbe53 81 [NFSD_MaxBlkSize] = write_maxblksize,
5b8db00b 82 [NFSD_MaxConnections] = write_maxconn,
70c3b76c 83#ifdef CONFIG_NFSD_V4
1da177e4 84 [NFSD_Leasetime] = write_leasetime,
efc4bb4f 85 [NFSD_Gracetime] = write_gracetime,
0964a3d3 86 [NFSD_RecoveryDir] = write_recoverydir,
70c3b76c 87#endif
1da177e4
LT
88};
89
90static ssize_t nfsctl_transaction_write(struct file *file, const char __user *buf, size_t size, loff_t *pos)
91{
496ad9aa 92 ino_t ino = file_inode(file)->i_ino;
1da177e4
LT
93 char *data;
94 ssize_t rv;
95
e8c96f8c 96 if (ino >= ARRAY_SIZE(write_op) || !write_op[ino])
1da177e4
LT
97 return -EINVAL;
98
99 data = simple_transaction_get(file, buf, size);
100 if (IS_ERR(data))
101 return PTR_ERR(data);
102
103 rv = write_op[ino](file, data, size);
8971a101 104 if (rv >= 0) {
1da177e4
LT
105 simple_transaction_set(file, rv);
106 rv = size;
107 }
108 return rv;
109}
110
7390022d
N
111static ssize_t nfsctl_transaction_read(struct file *file, char __user *buf, size_t size, loff_t *pos)
112{
113 if (! file->private_data) {
114 /* An attempt to read a transaction file without writing
115 * causes a 0-byte write so that the file can return
116 * state information
117 */
118 ssize_t rv = nfsctl_transaction_write(file, buf, 0, pos);
119 if (rv < 0)
120 return rv;
121 }
122 return simple_transaction_read(file, buf, size, pos);
123}
124
4b6f5d20 125static const struct file_operations transaction_ops = {
1da177e4 126 .write = nfsctl_transaction_write,
7390022d 127 .read = nfsctl_transaction_read,
1da177e4 128 .release = simple_transaction_release,
6038f373 129 .llseek = default_llseek,
1da177e4
LT
130};
131
96d851c4 132static int exports_net_open(struct net *net, struct file *file)
1da177e4 133{
f2c7ea10
SK
134 int err;
135 struct seq_file *seq;
96d851c4 136 struct nfsd_net *nn = net_generic(net, nfsd_net_id);
f2c7ea10
SK
137
138 err = seq_open(file, &nfs_exports_op);
139 if (err)
140 return err;
141
142 seq = file->private_data;
e5f06f72 143 seq->private = nn->svc_export_cache;
f2c7ea10 144 return 0;
1da177e4
LT
145}
146
96d851c4
SK
147static int exports_proc_open(struct inode *inode, struct file *file)
148{
149 return exports_net_open(current->nsproxy->net_ns, file);
150}
151
152static const struct file_operations exports_proc_operations = {
153 .open = exports_proc_open,
154 .read = seq_read,
155 .llseek = seq_lseek,
156 .release = seq_release,
157 .owner = THIS_MODULE,
158};
159
160static int exports_nfsd_open(struct inode *inode, struct file *file)
161{
162 return exports_net_open(inode->i_sb->s_fs_info, file);
163}
164
165static const struct file_operations exports_nfsd_operations = {
166 .open = exports_nfsd_open,
1da177e4
LT
167 .read = seq_read,
168 .llseek = seq_lseek,
169 .release = seq_release,
9ef2db26 170 .owner = THIS_MODULE,
1da177e4
LT
171};
172
e8e8753f
BF
173static int export_features_show(struct seq_file *m, void *v)
174{
175 seq_printf(m, "0x%x 0x%x\n", NFSEXP_ALLFLAGS, NFSEXP_SECINFO_FLAGS);
176 return 0;
177}
178
179static int export_features_open(struct inode *inode, struct file *file)
180{
181 return single_open(file, export_features_show, NULL);
182}
183
75ef9de1 184static const struct file_operations export_features_operations = {
e8e8753f
BF
185 .open = export_features_open,
186 .read = seq_read,
187 .llseek = seq_lseek,
188 .release = single_release,
189};
190
b084f598 191#if defined(CONFIG_SUNRPC_GSS) || defined(CONFIG_SUNRPC_GSS_MODULE)
b0b0c0a2
KC
192static int supported_enctypes_show(struct seq_file *m, void *v)
193{
b084f598 194 seq_printf(m, KRB5_SUPPORTED_ENCTYPES);
b0b0c0a2
KC
195 return 0;
196}
197
198static int supported_enctypes_open(struct inode *inode, struct file *file)
199{
200 return single_open(file, supported_enctypes_show, NULL);
201}
202
75ef9de1 203static const struct file_operations supported_enctypes_ops = {
b0b0c0a2
KC
204 .open = supported_enctypes_open,
205 .read = seq_read,
206 .llseek = seq_lseek,
207 .release = single_release,
208};
b084f598 209#endif /* CONFIG_SUNRPC_GSS or CONFIG_SUNRPC_GSS_MODULE */
b0b0c0a2 210
828c0950 211static const struct file_operations pool_stats_operations = {
03cf6c9f
GB
212 .open = nfsd_pool_stats_open,
213 .read = seq_read,
214 .llseek = seq_lseek,
ed2d8aed 215 .release = nfsd_pool_stats_release,
03cf6c9f
GB
216 .owner = THIS_MODULE,
217};
218
a2f999a3
JL
219static struct file_operations reply_cache_stats_operations = {
220 .open = nfsd_reply_cache_stats_open,
221 .read = seq_read,
222 .llseek = seq_lseek,
223 .release = single_release,
224};
225
1da177e4
LT
226/*----------------------------------------------------------------------------*/
227/*
228 * payload - write methods
1da177e4
LT
229 */
230
1da177e4 231
262a0982
CL
232/**
233 * write_unlock_ip - Release all locks used by a client
234 *
235 * Experimental.
236 *
237 * Input:
238 * buf: '\n'-terminated C string containing a
4116092b 239 * presentation format IP address
262a0982
CL
240 * size: length of C string in @buf
241 * Output:
242 * On success: returns zero if all specified locks were released;
243 * returns one if one or more locks were not released
244 * On error: return code is negative errno value
262a0982 245 */
b046ccdc 246static ssize_t write_unlock_ip(struct file *file, char *buf, size_t size)
4373ea84 247{
4116092b
CL
248 struct sockaddr_storage address;
249 struct sockaddr *sap = (struct sockaddr *)&address;
250 size_t salen = sizeof(address);
367c8c7b 251 char *fo_path;
11f77942 252 struct net *net = file->f_dentry->d_sb->s_fs_info;
4373ea84
WC
253
254 /* sanity check */
255 if (size == 0)
256 return -EINVAL;
257
258 if (buf[size-1] != '\n')
259 return -EINVAL;
260
261 fo_path = buf;
262 if (qword_get(&buf, fo_path, size) < 0)
263 return -EINVAL;
264
11f77942 265 if (rpc_pton(net, fo_path, size, sap, salen) == 0)
4373ea84 266 return -EINVAL;
4373ea84 267
4116092b 268 return nlmsvc_unlock_all_by_ip(sap);
4373ea84
WC
269}
270
262a0982
CL
271/**
272 * write_unlock_fs - Release all locks on a local file system
273 *
274 * Experimental.
275 *
276 * Input:
277 * buf: '\n'-terminated C string containing the
278 * absolute pathname of a local file system
279 * size: length of C string in @buf
280 * Output:
281 * On success: returns zero if all specified locks were released;
282 * returns one if one or more locks were not released
283 * On error: return code is negative errno value
284 */
b046ccdc 285static ssize_t write_unlock_fs(struct file *file, char *buf, size_t size)
17efa372 286{
a63bb996 287 struct path path;
17efa372
WC
288 char *fo_path;
289 int error;
290
291 /* sanity check */
292 if (size == 0)
293 return -EINVAL;
294
295 if (buf[size-1] != '\n')
296 return -EINVAL;
297
298 fo_path = buf;
299 if (qword_get(&buf, fo_path, size) < 0)
300 return -EINVAL;
301
a63bb996 302 error = kern_path(fo_path, 0, &path);
17efa372
WC
303 if (error)
304 return error;
305
262a0982
CL
306 /*
307 * XXX: Needs better sanity checking. Otherwise we could end up
308 * releasing locks on the wrong file system.
309 *
310 * For example:
311 * 1. Does the path refer to a directory?
312 * 2. Is that directory a mount point, or
313 * 3. Is that directory the root of an exported file system?
314 */
d8c9584e 315 error = nlmsvc_unlock_all_by_sb(path.dentry->d_sb);
17efa372 316
a63bb996 317 path_put(&path);
17efa372
WC
318 return error;
319}
320
262a0982
CL
321/**
322 * write_filehandle - Get a variable-length NFS file handle by path
323 *
324 * On input, the buffer contains a '\n'-terminated C string comprised of
325 * three alphanumeric words separated by whitespace. The string may
326 * contain escape sequences.
327 *
328 * Input:
329 * buf:
330 * domain: client domain name
331 * path: export pathname
332 * maxsize: numeric maximum size of
333 * @buf
334 * size: length of C string in @buf
335 * Output:
336 * On success: passed-in buffer filled with '\n'-terminated C
337 * string containing a ASCII hex text version
338 * of the NFS file handle;
339 * return code is the size in bytes of the string
340 * On error: return code is negative errno value
341 */
1da177e4
LT
342static ssize_t write_filehandle(struct file *file, char *buf, size_t size)
343{
1da177e4 344 char *dname, *path;
246d95ba 345 int uninitialized_var(maxsize);
1da177e4
LT
346 char *mesg = buf;
347 int len;
348 struct auth_domain *dom;
349 struct knfsd_fh fh;
11f77942 350 struct net *net = file->f_dentry->d_sb->s_fs_info;
1da177e4 351
87d26ea7
BF
352 if (size == 0)
353 return -EINVAL;
354
1da177e4
LT
355 if (buf[size-1] != '\n')
356 return -EINVAL;
357 buf[size-1] = 0;
358
359 dname = mesg;
360 len = qword_get(&mesg, dname, size);
54224f04
CL
361 if (len <= 0)
362 return -EINVAL;
1da177e4
LT
363
364 path = dname+len+1;
365 len = qword_get(&mesg, path, size);
54224f04
CL
366 if (len <= 0)
367 return -EINVAL;
1da177e4
LT
368
369 len = get_int(&mesg, &maxsize);
370 if (len)
371 return len;
372
373 if (maxsize < NFS_FHSIZE)
374 return -EINVAL;
3c7aa15d 375 maxsize = min(maxsize, NFS3_FHSIZE);
1da177e4
LT
376
377 if (qword_get(&mesg, mesg, size)>0)
378 return -EINVAL;
379
380 /* we have all the words, they are in buf.. */
381 dom = unix_domain_find(dname);
382 if (!dom)
383 return -ENOMEM;
384
11f77942 385 len = exp_rootfh(net, dom, path, &fh, maxsize);
1da177e4
LT
386 auth_domain_put(dom);
387 if (len)
388 return len;
389
54224f04
CL
390 mesg = buf;
391 len = SIMPLE_TRANSACTION_LIMIT;
1da177e4
LT
392 qword_addhex(&mesg, &len, (char*)&fh.fh_base, fh.fh_size);
393 mesg[-1] = '\n';
394 return mesg - buf;
395}
396
262a0982
CL
397/**
398 * write_threads - Start NFSD, or report the current number of running threads
399 *
400 * Input:
401 * buf: ignored
402 * size: zero
403 * Output:
404 * On success: passed-in buffer filled with '\n'-terminated C
405 * string numeric value representing the number of
406 * running NFSD threads;
407 * return code is the size in bytes of the string
408 * On error: return code is zero
409 *
410 * OR
411 *
412 * Input:
413 * buf: C string containing an unsigned
414 * integer value representing the
415 * number of NFSD threads to start
416 * size: non-zero length of C string in @buf
417 * Output:
418 * On success: NFS service is started;
419 * passed-in buffer filled with '\n'-terminated C
420 * string numeric value representing the number of
421 * running NFSD threads;
422 * return code is the size in bytes of the string
423 * On error: return code is zero or a negative errno value
424 */
1da177e4
LT
425static ssize_t write_threads(struct file *file, char *buf, size_t size)
426{
1da177e4
LT
427 char *mesg = buf;
428 int rv;
11f77942 429 struct net *net = file->f_dentry->d_sb->s_fs_info;
d41a9417 430
1da177e4
LT
431 if (size > 0) {
432 int newthreads;
433 rv = get_int(&mesg, &newthreads);
434 if (rv)
435 return rv;
9e074856 436 if (newthreads < 0)
1da177e4 437 return -EINVAL;
d41a9417 438 rv = nfsd_svc(newthreads, net);
82e12fe9 439 if (rv < 0)
1da177e4 440 return rv;
82e12fe9 441 } else
9dd9845f 442 rv = nfsd_nrthreads(net);
e06b6405 443
82e12fe9 444 return scnprintf(buf, SIMPLE_TRANSACTION_LIMIT, "%d\n", rv);
1da177e4
LT
445}
446
262a0982
CL
447/**
448 * write_pool_threads - Set or report the current number of threads per pool
449 *
450 * Input:
451 * buf: ignored
452 * size: zero
453 *
454 * OR
455 *
456 * Input:
457 * buf: C string containing whitespace-
458 * separated unsigned integer values
459 * representing the number of NFSD
460 * threads to start in each pool
461 * size: non-zero length of C string in @buf
462 * Output:
463 * On success: passed-in buffer filled with '\n'-terminated C
464 * string containing integer values representing the
465 * number of NFSD threads in each pool;
466 * return code is the size in bytes of the string
467 * On error: return code is zero or a negative errno value
468 */
eed2965a
GB
469static ssize_t write_pool_threads(struct file *file, char *buf, size_t size)
470{
471 /* if size > 0, look for an array of number of threads per node
472 * and apply them then write out number of threads per node as reply
473 */
474 char *mesg = buf;
475 int i;
476 int rv;
477 int len;
bedbdd8b 478 int npools;
eed2965a 479 int *nthreads;
11f77942 480 struct net *net = file->f_dentry->d_sb->s_fs_info;
eed2965a 481
bedbdd8b 482 mutex_lock(&nfsd_mutex);
9dd9845f 483 npools = nfsd_nrpools(net);
eed2965a
GB
484 if (npools == 0) {
485 /*
486 * NFS is shut down. The admin can start it by
487 * writing to the threads file but NOT the pool_threads
488 * file, sorry. Report zero threads.
489 */
bedbdd8b 490 mutex_unlock(&nfsd_mutex);
eed2965a
GB
491 strcpy(buf, "0\n");
492 return strlen(buf);
493 }
494
495 nthreads = kcalloc(npools, sizeof(int), GFP_KERNEL);
bedbdd8b 496 rv = -ENOMEM;
eed2965a 497 if (nthreads == NULL)
bedbdd8b 498 goto out_free;
eed2965a
GB
499
500 if (size > 0) {
501 for (i = 0; i < npools; i++) {
502 rv = get_int(&mesg, &nthreads[i]);
503 if (rv == -ENOENT)
504 break; /* fewer numbers than pools */
505 if (rv)
506 goto out_free; /* syntax error */
507 rv = -EINVAL;
508 if (nthreads[i] < 0)
509 goto out_free;
510 }
3938a0d5 511 rv = nfsd_set_nrthreads(i, nthreads, net);
eed2965a
GB
512 if (rv)
513 goto out_free;
514 }
515
9dd9845f 516 rv = nfsd_get_nrthreads(npools, nthreads, net);
eed2965a
GB
517 if (rv)
518 goto out_free;
519
520 mesg = buf;
521 size = SIMPLE_TRANSACTION_LIMIT;
522 for (i = 0; i < npools && size > 0; i++) {
523 snprintf(mesg, size, "%d%c", nthreads[i], (i == npools-1 ? '\n' : ' '));
524 len = strlen(mesg);
525 size -= len;
526 mesg += len;
527 }
413d63d7 528 rv = mesg - buf;
eed2965a
GB
529out_free:
530 kfree(nthreads);
bedbdd8b 531 mutex_unlock(&nfsd_mutex);
eed2965a
GB
532 return rv;
533}
534
3dd98a3b 535static ssize_t __write_versions(struct file *file, char *buf, size_t size)
70c3b76c 536{
70c3b76c 537 char *mesg = buf;
8daf220a 538 char *vers, *minorp, sign;
261758b5 539 int len, num, remaining;
8daf220a 540 unsigned minor;
70c3b76c
N
541 ssize_t tlen = 0;
542 char *sep;
11f77942 543 struct net *net = file->f_dentry->d_sb->s_fs_info;
9dd9845f 544 struct nfsd_net *nn = net_generic(net, nfsd_net_id);
70c3b76c
N
545
546 if (size>0) {
9dd9845f 547 if (nn->nfsd_serv)
6658d3a7 548 /* Cannot change versions without updating
9dd9845f 549 * nn->nfsd_serv->sv_xdrsize, and reallocing
6658d3a7
N
550 * rq_argp and rq_resp
551 */
70c3b76c
N
552 return -EBUSY;
553 if (buf[size-1] != '\n')
554 return -EINVAL;
555 buf[size-1] = 0;
556
557 vers = mesg;
558 len = qword_get(&mesg, vers, size);
559 if (len <= 0) return -EINVAL;
560 do {
561 sign = *vers;
562 if (sign == '+' || sign == '-')
8daf220a 563 num = simple_strtol((vers+1), &minorp, 0);
70c3b76c 564 else
8daf220a
BH
565 num = simple_strtol(vers, &minorp, 0);
566 if (*minorp == '.') {
ff89be87 567 if (num != 4)
8daf220a
BH
568 return -EINVAL;
569 minor = simple_strtoul(minorp+1, NULL, 0);
570 if (minor == 0)
571 return -EINVAL;
572 if (nfsd_minorversion(minor, sign == '-' ?
573 NFSD_CLEAR : NFSD_SET) < 0)
574 return -EINVAL;
575 goto next;
576 }
70c3b76c
N
577 switch(num) {
578 case 2:
579 case 3:
580 case 4:
6658d3a7 581 nfsd_vers(num, sign == '-' ? NFSD_CLEAR : NFSD_SET);
70c3b76c
N
582 break;
583 default:
584 return -EINVAL;
585 }
8daf220a 586 next:
70c3b76c 587 vers += len + 1;
70c3b76c
N
588 } while ((len = qword_get(&mesg, vers, size)) > 0);
589 /* If all get turned off, turn them back on, as
590 * having no versions is BAD
591 */
6658d3a7 592 nfsd_reset_versions();
70c3b76c 593 }
261758b5 594
70c3b76c
N
595 /* Now write current state into reply buffer */
596 len = 0;
597 sep = "";
261758b5 598 remaining = SIMPLE_TRANSACTION_LIMIT;
70c3b76c 599 for (num=2 ; num <= 4 ; num++)
6658d3a7 600 if (nfsd_vers(num, NFSD_AVAIL)) {
261758b5 601 len = snprintf(buf, remaining, "%s%c%d", sep,
6658d3a7 602 nfsd_vers(num, NFSD_TEST)?'+':'-',
70c3b76c
N
603 num);
604 sep = " ";
261758b5
CL
605
606 if (len > remaining)
607 break;
608 remaining -= len;
609 buf += len;
610 tlen += len;
70c3b76c 611 }
8daf220a 612 if (nfsd_vers(4, NFSD_AVAIL))
261758b5
CL
613 for (minor = 1; minor <= NFSD_SUPPORTED_MINOR_VERSION;
614 minor++) {
615 len = snprintf(buf, remaining, " %c4.%u",
8daf220a
BH
616 (nfsd_vers(4, NFSD_TEST) &&
617 nfsd_minorversion(minor, NFSD_TEST)) ?
618 '+' : '-',
619 minor);
261758b5
CL
620
621 if (len > remaining)
622 break;
623 remaining -= len;
624 buf += len;
625 tlen += len;
626 }
627
628 len = snprintf(buf, remaining, "\n");
629 if (len > remaining)
630 return -EINVAL;
631 return tlen + len;
70c3b76c
N
632}
633
262a0982
CL
634/**
635 * write_versions - Set or report the available NFS protocol versions
636 *
637 * Input:
638 * buf: ignored
639 * size: zero
640 * Output:
641 * On success: passed-in buffer filled with '\n'-terminated C
642 * string containing positive or negative integer
643 * values representing the current status of each
644 * protocol version;
645 * return code is the size in bytes of the string
646 * On error: return code is zero or a negative errno value
647 *
648 * OR
649 *
650 * Input:
651 * buf: C string containing whitespace-
652 * separated positive or negative
653 * integer values representing NFS
654 * protocol versions to enable ("+n")
655 * or disable ("-n")
656 * size: non-zero length of C string in @buf
657 * Output:
658 * On success: status of zero or more protocol versions has
659 * been updated; passed-in buffer filled with
660 * '\n'-terminated C string containing positive
661 * or negative integer values representing the
662 * current status of each protocol version;
663 * return code is the size in bytes of the string
664 * On error: return code is zero or a negative errno value
665 */
3dd98a3b
JL
666static ssize_t write_versions(struct file *file, char *buf, size_t size)
667{
668 ssize_t rv;
669
670 mutex_lock(&nfsd_mutex);
671 rv = __write_versions(file, buf, size);
672 mutex_unlock(&nfsd_mutex);
673 return rv;
674}
675
0a5372d8
CL
676/*
677 * Zero-length write. Return a list of NFSD's current listener
678 * transports.
679 */
9dd9845f 680static ssize_t __write_ports_names(char *buf, struct net *net)
0a5372d8 681{
9dd9845f
SK
682 struct nfsd_net *nn = net_generic(net, nfsd_net_id);
683
684 if (nn->nfsd_serv == NULL)
0a5372d8 685 return 0;
9dd9845f 686 return svc_xprt_names(nn->nfsd_serv, buf, SIMPLE_TRANSACTION_LIMIT);
0a5372d8
CL
687}
688
0b7c2f6f
CL
689/*
690 * A single 'fd' number was written, in which case it must be for
691 * a socket of a supported family/protocol, and we use it as an
692 * nfsd listener.
693 */
08160352 694static ssize_t __write_ports_addfd(char *buf, struct net *net)
0b7c2f6f
CL
695{
696 char *mesg = buf;
697 int fd, err;
9dd9845f 698 struct nfsd_net *nn = net_generic(net, nfsd_net_id);
0b7c2f6f
CL
699
700 err = get_int(&mesg, &fd);
701 if (err != 0 || fd < 0)
702 return -EINVAL;
703
30646394
SK
704 if (svc_alien_sock(net, fd)) {
705 printk(KERN_ERR "%s: socket net is different to NFSd's one\n", __func__);
706 return -EINVAL;
707 }
708
6777436b 709 err = nfsd_create_serv(net);
0b7c2f6f
CL
710 if (err != 0)
711 return err;
712
9dd9845f 713 err = svc_addsock(nn->nfsd_serv, fd, buf, SIMPLE_TRANSACTION_LIMIT);
78a8d7c8 714 if (err < 0) {
19f7e2ca 715 nfsd_destroy(net);
78a8d7c8
JL
716 return err;
717 }
0b7c2f6f 718
ea068bad 719 /* Decrease the count, but don't shut down the service */
9dd9845f 720 nn->nfsd_serv->sv_nrthreads--;
ea068bad 721 return err;
0b7c2f6f
CL
722}
723
4eb68c26
CL
724/*
725 * A transport listener is added by writing it's transport name and
726 * a port number.
727 */
08160352 728static ssize_t __write_ports_addxprt(char *buf, struct net *net)
4eb68c26
CL
729{
730 char transport[16];
37498292 731 struct svc_xprt *xprt;
4eb68c26 732 int port, err;
9dd9845f 733 struct nfsd_net *nn = net_generic(net, nfsd_net_id);
4eb68c26 734
a10fded1 735 if (sscanf(buf, "%15s %5u", transport, &port) != 2)
4eb68c26
CL
736 return -EINVAL;
737
4be929be 738 if (port < 1 || port > USHRT_MAX)
4eb68c26
CL
739 return -EINVAL;
740
6777436b 741 err = nfsd_create_serv(net);
4eb68c26
CL
742 if (err != 0)
743 return err;
744
9dd9845f 745 err = svc_create_xprt(nn->nfsd_serv, transport, net,
4eb68c26 746 PF_INET, port, SVC_SOCK_ANONYMOUS);
68717908 747 if (err < 0)
37498292
CL
748 goto out_err;
749
9dd9845f 750 err = svc_create_xprt(nn->nfsd_serv, transport, net,
37498292
CL
751 PF_INET6, port, SVC_SOCK_ANONYMOUS);
752 if (err < 0 && err != -EAFNOSUPPORT)
753 goto out_close;
0cd14a06
JL
754
755 /* Decrease the count, but don't shut down the service */
9dd9845f 756 nn->nfsd_serv->sv_nrthreads--;
4eb68c26 757 return 0;
37498292 758out_close:
9dd9845f 759 xprt = svc_find_xprt(nn->nfsd_serv, transport, net, PF_INET, port);
37498292
CL
760 if (xprt != NULL) {
761 svc_close_xprt(xprt);
762 svc_xprt_put(xprt);
763 }
764out_err:
19f7e2ca 765 nfsd_destroy(net);
37498292 766 return err;
4eb68c26
CL
767}
768
08160352
SK
769static ssize_t __write_ports(struct file *file, char *buf, size_t size,
770 struct net *net)
80212d59 771{
0a5372d8 772 if (size == 0)
9dd9845f 773 return __write_ports_names(buf, net);
0b7c2f6f
CL
774
775 if (isdigit(buf[0]))
08160352 776 return __write_ports_addfd(buf, net);
82d56591 777
4eb68c26 778 if (isalpha(buf[0]))
08160352 779 return __write_ports_addxprt(buf, net);
4cd5dc75 780
b41b66d6 781 return -EINVAL;
80212d59
N
782}
783
262a0982
CL
784/**
785 * write_ports - Pass a socket file descriptor or transport name to listen on
786 *
787 * Input:
788 * buf: ignored
789 * size: zero
790 * Output:
791 * On success: passed-in buffer filled with a '\n'-terminated C
792 * string containing a whitespace-separated list of
793 * named NFSD listeners;
794 * return code is the size in bytes of the string
795 * On error: return code is zero or a negative errno value
796 *
797 * OR
798 *
799 * Input:
800 * buf: C string containing an unsigned
801 * integer value representing a bound
802 * but unconnected socket that is to be
c71206a7
CL
803 * used as an NFSD listener; listen(3)
804 * must be called for a SOCK_STREAM
805 * socket, otherwise it is ignored
262a0982
CL
806 * size: non-zero length of C string in @buf
807 * Output:
808 * On success: NFS service is started;
809 * passed-in buffer filled with a '\n'-terminated C
810 * string containing a unique alphanumeric name of
811 * the listener;
812 * return code is the size in bytes of the string
813 * On error: return code is a negative errno value
814 *
815 * OR
816 *
817 * Input:
262a0982
CL
818 * buf: C string containing a transport
819 * name and an unsigned integer value
820 * representing the port to listen on,
821 * separated by whitespace
822 * size: non-zero length of C string in @buf
823 * Output:
824 * On success: returns zero; NFS service is started
825 * On error: return code is a negative errno value
262a0982 826 */
bedbdd8b
NB
827static ssize_t write_ports(struct file *file, char *buf, size_t size)
828{
829 ssize_t rv;
11f77942 830 struct net *net = file->f_dentry->d_sb->s_fs_info;
3dd98a3b 831
bedbdd8b 832 mutex_lock(&nfsd_mutex);
08160352 833 rv = __write_ports(file, buf, size, net);
bedbdd8b
NB
834 mutex_unlock(&nfsd_mutex);
835 return rv;
836}
837
838
596bbe53
N
839int nfsd_max_blksize;
840
262a0982
CL
841/**
842 * write_maxblksize - Set or report the current NFS blksize
843 *
844 * Input:
845 * buf: ignored
846 * size: zero
847 *
848 * OR
849 *
850 * Input:
851 * buf: C string containing an unsigned
852 * integer value representing the new
853 * NFS blksize
854 * size: non-zero length of C string in @buf
855 * Output:
856 * On success: passed-in buffer filled with '\n'-terminated C string
857 * containing numeric value of the current NFS blksize
858 * setting;
859 * return code is the size in bytes of the string
860 * On error: return code is zero or a negative errno value
861 */
596bbe53
N
862static ssize_t write_maxblksize(struct file *file, char *buf, size_t size)
863{
864 char *mesg = buf;
11f77942 865 struct net *net = file->f_dentry->d_sb->s_fs_info;
9dd9845f
SK
866 struct nfsd_net *nn = net_generic(net, nfsd_net_id);
867
596bbe53
N
868 if (size > 0) {
869 int bsize;
870 int rv = get_int(&mesg, &bsize);
871 if (rv)
872 return rv;
873 /* force bsize into allowed range and
874 * required alignment.
875 */
3c7aa15d
KM
876 bsize = max_t(int, bsize, 1024);
877 bsize = min_t(int, bsize, NFSSVC_MAXBLKSIZE);
596bbe53 878 bsize &= ~(1024-1);
bedbdd8b 879 mutex_lock(&nfsd_mutex);
9dd9845f 880 if (nn->nfsd_serv) {
bedbdd8b 881 mutex_unlock(&nfsd_mutex);
596bbe53
N
882 return -EBUSY;
883 }
884 nfsd_max_blksize = bsize;
bedbdd8b 885 mutex_unlock(&nfsd_mutex);
596bbe53 886 }
e06b6405
CL
887
888 return scnprintf(buf, SIMPLE_TRANSACTION_LIMIT, "%d\n",
889 nfsd_max_blksize);
596bbe53
N
890}
891
5b8db00b
JL
892/**
893 * write_maxconn - Set or report the current max number of connections
894 *
895 * Input:
896 * buf: ignored
897 * size: zero
898 * OR
899 *
900 * Input:
901 * buf: C string containing an unsigned
902 * integer value representing the new
903 * number of max connections
904 * size: non-zero length of C string in @buf
905 * Output:
906 * On success: passed-in buffer filled with '\n'-terminated C string
907 * containing numeric value of max_connections setting
908 * for this net namespace;
909 * return code is the size in bytes of the string
910 * On error: return code is zero or a negative errno value
911 */
912static ssize_t write_maxconn(struct file *file, char *buf, size_t size)
913{
914 char *mesg = buf;
915 struct net *net = file->f_dentry->d_sb->s_fs_info;
916 struct nfsd_net *nn = net_generic(net, nfsd_net_id);
917 unsigned int maxconn = nn->max_connections;
918
919 if (size > 0) {
920 int rv = get_uint(&mesg, &maxconn);
921
922 if (rv)
923 return rv;
924 nn->max_connections = maxconn;
925 }
926
927 return scnprintf(buf, SIMPLE_TRANSACTION_LIMIT, "%u\n", maxconn);
928}
929
70c3b76c 930#ifdef CONFIG_NFSD_V4
9dd9845f
SK
931static ssize_t __nfsd4_write_time(struct file *file, char *buf, size_t size,
932 time_t *time, struct nfsd_net *nn)
1da177e4 933{
1da177e4 934 char *mesg = buf;
f0135740 935 int rv, i;
1da177e4
LT
936
937 if (size > 0) {
9dd9845f 938 if (nn->nfsd_serv)
3dd98a3b 939 return -EBUSY;
f0135740 940 rv = get_int(&mesg, &i);
1da177e4
LT
941 if (rv)
942 return rv;
e7b184f1
BF
943 /*
944 * Some sanity checking. We don't have a reason for
945 * these particular numbers, but problems with the
946 * extremes are:
947 * - Too short: the briefest network outage may
948 * cause clients to lose all their locks. Also,
949 * the frequent polling may be wasteful.
950 * - Too long: do you really want reboot recovery
951 * to take more than an hour? Or to make other
952 * clients wait an hour before being able to
953 * revoke a dead client's locks?
954 */
f0135740 955 if (i < 10 || i > 3600)
1da177e4 956 return -EINVAL;
f0135740 957 *time = i;
1da177e4 958 }
e06b6405 959
f0135740
BF
960 return scnprintf(buf, SIMPLE_TRANSACTION_LIMIT, "%ld\n", *time);
961}
962
9dd9845f
SK
963static ssize_t nfsd4_write_time(struct file *file, char *buf, size_t size,
964 time_t *time, struct nfsd_net *nn)
f0135740
BF
965{
966 ssize_t rv;
967
968 mutex_lock(&nfsd_mutex);
9dd9845f 969 rv = __nfsd4_write_time(file, buf, size, time, nn);
f0135740
BF
970 mutex_unlock(&nfsd_mutex);
971 return rv;
1da177e4
LT
972}
973
262a0982
CL
974/**
975 * write_leasetime - Set or report the current NFSv4 lease time
976 *
977 * Input:
978 * buf: ignored
979 * size: zero
980 *
981 * OR
982 *
983 * Input:
984 * buf: C string containing an unsigned
985 * integer value representing the new
986 * NFSv4 lease expiry time
987 * size: non-zero length of C string in @buf
988 * Output:
989 * On success: passed-in buffer filled with '\n'-terminated C
990 * string containing unsigned integer value of the
991 * current lease expiry time;
992 * return code is the size in bytes of the string
993 * On error: return code is zero or a negative errno value
994 */
3dd98a3b
JL
995static ssize_t write_leasetime(struct file *file, char *buf, size_t size)
996{
11f77942
SK
997 struct net *net = file->f_dentry->d_sb->s_fs_info;
998 struct nfsd_net *nn = net_generic(net, nfsd_net_id);
9dd9845f 999 return nfsd4_write_time(file, buf, size, &nn->nfsd4_lease, nn);
3dd98a3b
JL
1000}
1001
efc4bb4f
BF
1002/**
1003 * write_gracetime - Set or report current NFSv4 grace period time
1004 *
1005 * As above, but sets the time of the NFSv4 grace period.
1006 *
1007 * Note this should never be set to less than the *previous*
1008 * lease-period time, but we don't try to enforce this. (In the common
1009 * case (a new boot), we don't know what the previous lease time was
1010 * anyway.)
1011 */
1012static ssize_t write_gracetime(struct file *file, char *buf, size_t size)
1013{
11f77942
SK
1014 struct net *net = file->f_dentry->d_sb->s_fs_info;
1015 struct nfsd_net *nn = net_generic(net, nfsd_net_id);
9dd9845f 1016 return nfsd4_write_time(file, buf, size, &nn->nfsd4_grace, nn);
efc4bb4f
BF
1017}
1018
9dd9845f
SK
1019static ssize_t __write_recoverydir(struct file *file, char *buf, size_t size,
1020 struct nfsd_net *nn)
0964a3d3
N
1021{
1022 char *mesg = buf;
1023 char *recdir;
1024 int len, status;
1025
3dd98a3b 1026 if (size > 0) {
9dd9845f 1027 if (nn->nfsd_serv)
3dd98a3b
JL
1028 return -EBUSY;
1029 if (size > PATH_MAX || buf[size-1] != '\n')
1030 return -EINVAL;
1031 buf[size-1] = 0;
0964a3d3 1032
3dd98a3b
JL
1033 recdir = mesg;
1034 len = qword_get(&mesg, recdir, size);
1035 if (len <= 0)
1036 return -EINVAL;
0964a3d3 1037
3dd98a3b 1038 status = nfs4_reset_recoverydir(recdir);
69049961
AK
1039 if (status)
1040 return status;
3dd98a3b 1041 }
3d72ab8f
CL
1042
1043 return scnprintf(buf, SIMPLE_TRANSACTION_LIMIT, "%s\n",
1044 nfs4_recoverydir());
0964a3d3 1045}
3dd98a3b 1046
262a0982
CL
1047/**
1048 * write_recoverydir - Set or report the pathname of the recovery directory
1049 *
1050 * Input:
1051 * buf: ignored
1052 * size: zero
1053 *
1054 * OR
1055 *
1056 * Input:
1057 * buf: C string containing the pathname
1058 * of the directory on a local file
1059 * system containing permanent NFSv4
1060 * recovery data
1061 * size: non-zero length of C string in @buf
1062 * Output:
1063 * On success: passed-in buffer filled with '\n'-terminated C string
1064 * containing the current recovery pathname setting;
1065 * return code is the size in bytes of the string
1066 * On error: return code is zero or a negative errno value
1067 */
3dd98a3b
JL
1068static ssize_t write_recoverydir(struct file *file, char *buf, size_t size)
1069{
1070 ssize_t rv;
11f77942
SK
1071 struct net *net = file->f_dentry->d_sb->s_fs_info;
1072 struct nfsd_net *nn = net_generic(net, nfsd_net_id);
3dd98a3b
JL
1073
1074 mutex_lock(&nfsd_mutex);
9dd9845f 1075 rv = __write_recoverydir(file, buf, size, nn);
3dd98a3b
JL
1076 mutex_unlock(&nfsd_mutex);
1077 return rv;
1078}
1079
70c3b76c 1080#endif
0964a3d3 1081
1da177e4
LT
1082/*----------------------------------------------------------------------------*/
1083/*
1084 * populating the filesystem.
1085 */
1086
1087static int nfsd_fill_super(struct super_block * sb, void * data, int silent)
1088{
1089 static struct tree_descr nfsd_files[] = {
96d851c4 1090 [NFSD_List] = {"exports", &exports_nfsd_operations, S_IRUGO},
e8e8753f
BF
1091 [NFSD_Export_features] = {"export_features",
1092 &export_features_operations, S_IRUGO},
4373ea84
WC
1093 [NFSD_FO_UnlockIP] = {"unlock_ip",
1094 &transaction_ops, S_IWUSR|S_IRUSR},
17efa372
WC
1095 [NFSD_FO_UnlockFS] = {"unlock_filesystem",
1096 &transaction_ops, S_IWUSR|S_IRUSR},
1da177e4
LT
1097 [NFSD_Fh] = {"filehandle", &transaction_ops, S_IWUSR|S_IRUSR},
1098 [NFSD_Threads] = {"threads", &transaction_ops, S_IWUSR|S_IRUSR},
eed2965a 1099 [NFSD_Pool_Threads] = {"pool_threads", &transaction_ops, S_IWUSR|S_IRUSR},
03cf6c9f 1100 [NFSD_Pool_Stats] = {"pool_stats", &pool_stats_operations, S_IRUGO},
a2f999a3 1101 [NFSD_Reply_Cache_Stats] = {"reply_cache_stats", &reply_cache_stats_operations, S_IRUGO},
70c3b76c 1102 [NFSD_Versions] = {"versions", &transaction_ops, S_IWUSR|S_IRUSR},
80212d59 1103 [NFSD_Ports] = {"portlist", &transaction_ops, S_IWUSR|S_IRUGO},
596bbe53 1104 [NFSD_MaxBlkSize] = {"max_block_size", &transaction_ops, S_IWUSR|S_IRUGO},
5b8db00b 1105 [NFSD_MaxConnections] = {"max_connections", &transaction_ops, S_IWUSR|S_IRUGO},
b084f598 1106#if defined(CONFIG_SUNRPC_GSS) || defined(CONFIG_SUNRPC_GSS_MODULE)
b0b0c0a2 1107 [NFSD_SupportedEnctypes] = {"supported_krb5_enctypes", &supported_enctypes_ops, S_IRUGO},
b084f598 1108#endif /* CONFIG_SUNRPC_GSS or CONFIG_SUNRPC_GSS_MODULE */
1da177e4
LT
1109#ifdef CONFIG_NFSD_V4
1110 [NFSD_Leasetime] = {"nfsv4leasetime", &transaction_ops, S_IWUSR|S_IRUSR},
efc4bb4f 1111 [NFSD_Gracetime] = {"nfsv4gracetime", &transaction_ops, S_IWUSR|S_IRUSR},
0964a3d3 1112 [NFSD_RecoveryDir] = {"nfsv4recoverydir", &transaction_ops, S_IWUSR|S_IRUSR},
1da177e4
LT
1113#endif
1114 /* last one */ {""}
1115 };
11f77942
SK
1116 struct net *net = data;
1117 int ret;
1118
1119 ret = simple_fill_super(sb, 0x6e667364, nfsd_files);
1120 if (ret)
1121 return ret;
1122 sb->s_fs_info = get_net(net);
1123 return 0;
1da177e4
LT
1124}
1125
fc14f2fe
AV
1126static struct dentry *nfsd_mount(struct file_system_type *fs_type,
1127 int flags, const char *dev_name, void *data)
1da177e4 1128{
11f77942
SK
1129 return mount_ns(fs_type, flags, current->nsproxy->net_ns, nfsd_fill_super);
1130}
1131
1132static void nfsd_umount(struct super_block *sb)
1133{
1134 struct net *net = sb->s_fs_info;
1135
1136 kill_litter_super(sb);
1137 put_net(net);
1da177e4
LT
1138}
1139
1140static struct file_system_type nfsd_fs_type = {
1141 .owner = THIS_MODULE,
1142 .name = "nfsd",
fc14f2fe 1143 .mount = nfsd_mount,
11f77942 1144 .kill_sb = nfsd_umount,
1da177e4 1145};
7f78e035 1146MODULE_ALIAS_FS("nfsd");
1da177e4 1147
e331f606
BF
1148#ifdef CONFIG_PROC_FS
1149static int create_proc_exports_entry(void)
1150{
1151 struct proc_dir_entry *entry;
1152
1153 entry = proc_mkdir("fs/nfs", NULL);
1154 if (!entry)
1155 return -ENOMEM;
96d851c4
SK
1156 entry = proc_create("exports", 0, entry,
1157 &exports_proc_operations);
ff7c4b36 1158 if (!entry) {
1159 remove_proc_entry("fs/nfs", NULL);
e331f606 1160 return -ENOMEM;
ff7c4b36 1161 }
e331f606
BF
1162 return 0;
1163}
1164#else /* CONFIG_PROC_FS */
1165static int create_proc_exports_entry(void)
1166{
1167 return 0;
1168}
1169#endif
1170
7ea34ac1 1171int nfsd_net_id;
5717e012
SK
1172
1173static __net_init int nfsd_init_net(struct net *net)
1174{
1175 int retval;
3d733711 1176 struct nfsd_net *nn = net_generic(net, nfsd_net_id);
5717e012
SK
1177
1178 retval = nfsd_export_init(net);
1179 if (retval)
1180 goto out_export_error;
f69adb2f
SK
1181 retval = nfsd_idmap_init(net);
1182 if (retval)
1183 goto out_idmap_error;
3d733711 1184 nn->nfsd4_lease = 90; /* default lease time */
5284b44e 1185 nn->nfsd4_grace = 90;
5717e012
SK
1186 return 0;
1187
f69adb2f
SK
1188out_idmap_error:
1189 nfsd_export_shutdown(net);
5717e012
SK
1190out_export_error:
1191 return retval;
1192}
1193
1194static __net_exit void nfsd_exit_net(struct net *net)
1195{
f69adb2f 1196 nfsd_idmap_shutdown(net);
5717e012
SK
1197 nfsd_export_shutdown(net);
1198}
1199
7ea34ac1 1200static struct pernet_operations nfsd_net_ops = {
5717e012
SK
1201 .init = nfsd_init_net,
1202 .exit = nfsd_exit_net,
7ea34ac1
JL
1203 .id = &nfsd_net_id,
1204 .size = sizeof(struct nfsd_net),
1205};
1206
1da177e4
LT
1207static int __init init_nfsd(void)
1208{
1209 int retval;
1210 printk(KERN_INFO "Installing knfsd (copyright (C) 1996 okir@monad.swb.de).\n");
1211
797a9d79 1212 retval = register_cld_notifier();
813fd320
JL
1213 if (retval)
1214 return retval;
7ea34ac1
JL
1215 retval = register_pernet_subsys(&nfsd_net_ops);
1216 if (retval < 0)
813fd320 1217 goto out_unregister_notifier;
72083396 1218 retval = nfsd4_init_slabs();
e8ff2a84 1219 if (retval)
7ea34ac1 1220 goto out_unregister_pernet;
65178db4
BS
1221 retval = nfsd_fault_inject_init(); /* nfsd fault injection controls */
1222 if (retval)
1223 goto out_free_slabs;
1da177e4 1224 nfsd_stat_init(); /* Statistics */
d5c3428b
BF
1225 retval = nfsd_reply_cache_init();
1226 if (retval)
1227 goto out_free_stat;
1da177e4 1228 nfsd_lockd_init(); /* lockd->nfsd callbacks */
e331f606
BF
1229 retval = create_proc_exports_entry();
1230 if (retval)
f69adb2f 1231 goto out_free_lockd;
1da177e4 1232 retval = register_filesystem(&nfsd_fs_type);
26808d3f
BF
1233 if (retval)
1234 goto out_free_all;
1235 return 0;
1236out_free_all:
26808d3f
BF
1237 remove_proc_entry("fs/nfs/exports", NULL);
1238 remove_proc_entry("fs/nfs", NULL);
dbf847ec 1239out_free_lockd:
26808d3f 1240 nfsd_lockd_shutdown();
e331f606 1241 nfsd_reply_cache_shutdown();
d5c3428b
BF
1242out_free_stat:
1243 nfsd_stat_shutdown();
65178db4
BS
1244 nfsd_fault_inject_cleanup();
1245out_free_slabs:
26808d3f 1246 nfsd4_free_slabs();
7ea34ac1
JL
1247out_unregister_pernet:
1248 unregister_pernet_subsys(&nfsd_net_ops);
813fd320 1249out_unregister_notifier:
797a9d79 1250 unregister_cld_notifier();
1da177e4
LT
1251 return retval;
1252}
1253
1254static void __exit exit_nfsd(void)
1255{
d5c3428b 1256 nfsd_reply_cache_shutdown();
1da177e4
LT
1257 remove_proc_entry("fs/nfs/exports", NULL);
1258 remove_proc_entry("fs/nfs", NULL);
1259 nfsd_stat_shutdown();
1260 nfsd_lockd_shutdown();
e8ff2a84 1261 nfsd4_free_slabs();
65178db4 1262 nfsd_fault_inject_cleanup();
1da177e4 1263 unregister_filesystem(&nfsd_fs_type);
7ea34ac1 1264 unregister_pernet_subsys(&nfsd_net_ops);
797a9d79 1265 unregister_cld_notifier();
1da177e4
LT
1266}
1267
1268MODULE_AUTHOR("Olaf Kirch <okir@monad.swb.de>");
1269MODULE_LICENSE("GPL");
1270module_init(init_nfsd)
1271module_exit(exit_nfsd)
This page took 0.68554 seconds and 5 git commands to generate.