blob: b6e192d25633af5c7f8fab6af688262ed0a271eb [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07002 * Syscall interface to knfsd.
3 *
4 * Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de>
5 */
6
Tejun Heo5a0e3ad2010-03-24 17:04:11 +09007#include <linux/slab.h>
Al Viro3f8206d2008-07-26 03:46:43 -04008#include <linux/namei.h>
NeilBrownb41b66d2006-10-02 02:17:48 -07009#include <linux/ctype.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010
Linus Torvalds1da177e2005-04-16 15:20:36 -070011#include <linux/nfsd_idmap.h>
NeilBrown80212d52006-10-02 02:17:47 -070012#include <linux/sunrpc/svcsock.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070013#include <linux/nfsd/syscall.h>
Wendy Cheng4373ea82008-01-17 11:10:12 -050014#include <linux/lockd/lockd.h>
Chuck Lever41160922009-08-09 15:09:40 -040015#include <linux/sunrpc/clnt.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070016
Boaz Harrosh9a74af22009-12-03 20:30:56 +020017#include "nfsd.h"
18#include "cache.h"
19
Linus Torvalds1da177e2005-04-16 15:20:36 -070020/*
21 * We have a single directory with 9 nodes in it.
22 */
23enum {
24 NFSD_Root = 1,
NeilBrown1e140562010-09-22 12:55:07 +100025#ifdef CONFIG_NFSD_DEPRECATED
Linus Torvalds1da177e2005-04-16 15:20:36 -070026 NFSD_Svc,
27 NFSD_Add,
28 NFSD_Del,
29 NFSD_Export,
30 NFSD_Unexport,
31 NFSD_Getfd,
32 NFSD_Getfs,
NeilBrown1e140562010-09-22 12:55:07 +100033#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070034 NFSD_List,
J. Bruce Fieldse8e87532009-12-14 12:53:32 -050035 NFSD_Export_features,
Linus Torvalds1da177e2005-04-16 15:20:36 -070036 NFSD_Fh,
Wendy Cheng4373ea82008-01-17 11:10:12 -050037 NFSD_FO_UnlockIP,
Wendy Cheng17efa372008-01-17 11:10:12 -050038 NFSD_FO_UnlockFS,
Linus Torvalds1da177e2005-04-16 15:20:36 -070039 NFSD_Threads,
Greg Bankseed29652006-10-02 02:18:02 -070040 NFSD_Pool_Threads,
Greg Banks03cf6c92009-01-13 21:26:36 +110041 NFSD_Pool_Stats,
NeilBrown70c3b762005-11-07 01:00:25 -080042 NFSD_Versions,
NeilBrown80212d52006-10-02 02:17:47 -070043 NFSD_Ports,
NeilBrown596bbe52006-10-04 02:15:48 -070044 NFSD_MaxBlkSize,
NeilBrown70c3b762005-11-07 01:00:25 -080045 /*
46 * The below MUST come last. Otherwise we leave a hole in nfsd_files[]
47 * with !CONFIG_NFSD_V4 and simple_fill_super() goes oops
48 */
49#ifdef CONFIG_NFSD_V4
Linus Torvalds1da177e2005-04-16 15:20:36 -070050 NFSD_Leasetime,
J. Bruce Fieldsefc4bb4f2010-03-02 11:04:06 -050051 NFSD_Gracetime,
NeilBrown0964a3d2005-06-23 22:04:32 -070052 NFSD_RecoveryDir,
NeilBrown70c3b762005-11-07 01:00:25 -080053#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070054};
55
56/*
57 * write() for these nodes.
58 */
NeilBrown1e140562010-09-22 12:55:07 +100059#ifdef CONFIG_NFSD_DEPRECATED
Linus Torvalds1da177e2005-04-16 15:20:36 -070060static ssize_t write_svc(struct file *file, char *buf, size_t size);
61static ssize_t write_add(struct file *file, char *buf, size_t size);
62static ssize_t write_del(struct file *file, char *buf, size_t size);
63static ssize_t write_export(struct file *file, char *buf, size_t size);
64static ssize_t write_unexport(struct file *file, char *buf, size_t size);
65static ssize_t write_getfd(struct file *file, char *buf, size_t size);
66static ssize_t write_getfs(struct file *file, char *buf, size_t size);
NeilBrown1e140562010-09-22 12:55:07 +100067#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070068static ssize_t write_filehandle(struct file *file, char *buf, size_t size);
Chuck Leverb046ccd2008-12-12 16:57:13 -050069static ssize_t write_unlock_ip(struct file *file, char *buf, size_t size);
70static ssize_t write_unlock_fs(struct file *file, char *buf, size_t size);
Linus Torvalds1da177e2005-04-16 15:20:36 -070071static ssize_t write_threads(struct file *file, char *buf, size_t size);
Greg Bankseed29652006-10-02 02:18:02 -070072static ssize_t write_pool_threads(struct file *file, char *buf, size_t size);
NeilBrown70c3b762005-11-07 01:00:25 -080073static ssize_t write_versions(struct file *file, char *buf, size_t size);
NeilBrown80212d52006-10-02 02:17:47 -070074static ssize_t write_ports(struct file *file, char *buf, size_t size);
NeilBrown596bbe52006-10-04 02:15:48 -070075static ssize_t write_maxblksize(struct file *file, char *buf, size_t size);
NeilBrown70c3b762005-11-07 01:00:25 -080076#ifdef CONFIG_NFSD_V4
Linus Torvalds1da177e2005-04-16 15:20:36 -070077static ssize_t write_leasetime(struct file *file, char *buf, size_t size);
J. Bruce Fieldsefc4bb4f2010-03-02 11:04:06 -050078static ssize_t write_gracetime(struct file *file, char *buf, size_t size);
NeilBrown0964a3d2005-06-23 22:04:32 -070079static ssize_t write_recoverydir(struct file *file, char *buf, size_t size);
NeilBrown70c3b762005-11-07 01:00:25 -080080#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070081
82static ssize_t (*write_op[])(struct file *, char *, size_t) = {
NeilBrown1e140562010-09-22 12:55:07 +100083#ifdef CONFIG_NFSD_DEPRECATED
Linus Torvalds1da177e2005-04-16 15:20:36 -070084 [NFSD_Svc] = write_svc,
85 [NFSD_Add] = write_add,
86 [NFSD_Del] = write_del,
87 [NFSD_Export] = write_export,
88 [NFSD_Unexport] = write_unexport,
89 [NFSD_Getfd] = write_getfd,
90 [NFSD_Getfs] = write_getfs,
NeilBrown1e140562010-09-22 12:55:07 +100091#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070092 [NFSD_Fh] = write_filehandle,
Chuck Leverb046ccd2008-12-12 16:57:13 -050093 [NFSD_FO_UnlockIP] = write_unlock_ip,
94 [NFSD_FO_UnlockFS] = write_unlock_fs,
Linus Torvalds1da177e2005-04-16 15:20:36 -070095 [NFSD_Threads] = write_threads,
Greg Bankseed29652006-10-02 02:18:02 -070096 [NFSD_Pool_Threads] = write_pool_threads,
NeilBrown70c3b762005-11-07 01:00:25 -080097 [NFSD_Versions] = write_versions,
NeilBrown80212d52006-10-02 02:17:47 -070098 [NFSD_Ports] = write_ports,
NeilBrown596bbe52006-10-04 02:15:48 -070099 [NFSD_MaxBlkSize] = write_maxblksize,
NeilBrown70c3b762005-11-07 01:00:25 -0800100#ifdef CONFIG_NFSD_V4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700101 [NFSD_Leasetime] = write_leasetime,
J. Bruce Fieldsefc4bb4f2010-03-02 11:04:06 -0500102 [NFSD_Gracetime] = write_gracetime,
NeilBrown0964a3d2005-06-23 22:04:32 -0700103 [NFSD_RecoveryDir] = write_recoverydir,
NeilBrown70c3b762005-11-07 01:00:25 -0800104#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700105};
106
107static ssize_t nfsctl_transaction_write(struct file *file, const char __user *buf, size_t size, loff_t *pos)
108{
Josef "Jeff" Sipek7eaa36e2006-12-08 02:36:41 -0800109 ino_t ino = file->f_path.dentry->d_inode->i_ino;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110 char *data;
111 ssize_t rv;
112
Tobias Klausere8c96f82006-03-24 03:15:34 -0800113 if (ino >= ARRAY_SIZE(write_op) || !write_op[ino])
Linus Torvalds1da177e2005-04-16 15:20:36 -0700114 return -EINVAL;
115
116 data = simple_transaction_get(file, buf, size);
117 if (IS_ERR(data))
118 return PTR_ERR(data);
119
120 rv = write_op[ino](file, data, size);
NeilBrown8971a102007-02-14 00:33:11 -0800121 if (rv >= 0) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700122 simple_transaction_set(file, rv);
123 rv = size;
124 }
125 return rv;
126}
127
NeilBrown73900222005-11-07 01:00:24 -0800128static ssize_t nfsctl_transaction_read(struct file *file, char __user *buf, size_t size, loff_t *pos)
129{
NeilBrownc67874f2010-09-22 12:55:07 +1000130 static int warned;
131 if (file->f_dentry->d_name.name[0] == '.' && !warned) {
NeilBrownc67874f2010-09-22 12:55:07 +1000132 printk(KERN_INFO
133 "Warning: \"%s\" uses deprecated NFSD interface: %s."
134 " This will be removed in 2.6.40\n",
Pavel Emelyanov049ef272010-09-23 18:26:58 +0400135 current->comm, file->f_dentry->d_name.name);
NeilBrownc67874f2010-09-22 12:55:07 +1000136 warned = 1;
137 }
NeilBrown73900222005-11-07 01:00:24 -0800138 if (! file->private_data) {
139 /* An attempt to read a transaction file without writing
140 * causes a 0-byte write so that the file can return
141 * state information
142 */
143 ssize_t rv = nfsctl_transaction_write(file, buf, 0, pos);
144 if (rv < 0)
145 return rv;
146 }
147 return simple_transaction_read(file, buf, size, pos);
148}
149
Arjan van de Ven4b6f5d22006-03-28 01:56:42 -0800150static const struct file_operations transaction_ops = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700151 .write = nfsctl_transaction_write,
NeilBrown73900222005-11-07 01:00:24 -0800152 .read = nfsctl_transaction_read,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700153 .release = simple_transaction_release,
154};
155
Linus Torvalds1da177e2005-04-16 15:20:36 -0700156static int exports_open(struct inode *inode, struct file *file)
157{
158 return seq_open(file, &nfs_exports_op);
159}
160
Arjan van de Ven4b6f5d22006-03-28 01:56:42 -0800161static const struct file_operations exports_operations = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700162 .open = exports_open,
163 .read = seq_read,
164 .llseek = seq_lseek,
165 .release = seq_release,
Denis V. Lunev9ef2db22008-04-29 01:02:04 -0700166 .owner = THIS_MODULE,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700167};
168
J. Bruce Fieldse8e87532009-12-14 12:53:32 -0500169static int export_features_show(struct seq_file *m, void *v)
170{
171 seq_printf(m, "0x%x 0x%x\n", NFSEXP_ALLFLAGS, NFSEXP_SECINFO_FLAGS);
172 return 0;
173}
174
175static int export_features_open(struct inode *inode, struct file *file)
176{
177 return single_open(file, export_features_show, NULL);
178}
179
180static struct file_operations export_features_operations = {
181 .open = export_features_open,
182 .read = seq_read,
183 .llseek = seq_lseek,
184 .release = single_release,
185};
186
Greg Banks03cf6c92009-01-13 21:26:36 +1100187extern int nfsd_pool_stats_open(struct inode *inode, struct file *file);
Ryusei Yamaguchied2d8ae2009-08-16 00:54:41 +0900188extern int nfsd_pool_stats_release(struct inode *inode, struct file *file);
Greg Banks03cf6c92009-01-13 21:26:36 +1100189
Alexey Dobriyan828c0952009-10-01 15:43:56 -0700190static const struct file_operations pool_stats_operations = {
Greg Banks03cf6c92009-01-13 21:26:36 +1100191 .open = nfsd_pool_stats_open,
192 .read = seq_read,
193 .llseek = seq_lseek,
Ryusei Yamaguchied2d8ae2009-08-16 00:54:41 +0900194 .release = nfsd_pool_stats_release,
Greg Banks03cf6c92009-01-13 21:26:36 +1100195 .owner = THIS_MODULE,
196};
197
Linus Torvalds1da177e2005-04-16 15:20:36 -0700198/*----------------------------------------------------------------------------*/
199/*
200 * payload - write methods
Linus Torvalds1da177e2005-04-16 15:20:36 -0700201 */
202
NeilBrown1e140562010-09-22 12:55:07 +1000203#ifdef CONFIG_NFSD_DEPRECATED
Chuck Lever262a0982008-12-12 16:57:35 -0500204/**
205 * write_svc - Start kernel's NFSD server
206 *
207 * Deprecated. /proc/fs/nfsd/threads is preferred.
208 * Function remains to support old versions of nfs-utils.
209 *
210 * Input:
211 * buf: struct nfsctl_svc
212 * svc_port: port number of this
213 * server's listener
214 * svc_nthreads: number of threads to start
215 * size: size in bytes of passed in nfsctl_svc
216 * Output:
217 * On success: returns zero
218 * On error: return code is negative errno value
219 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700220static ssize_t write_svc(struct file *file, char *buf, size_t size)
221{
222 struct nfsctl_svc *data;
NeilBrown82e12fe2009-06-16 11:03:07 +1000223 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700224 if (size < sizeof(*data))
225 return -EINVAL;
226 data = (struct nfsctl_svc*) buf;
NeilBrown82e12fe2009-06-16 11:03:07 +1000227 err = nfsd_svc(data->svc_port, data->svc_nthreads);
228 if (err < 0)
229 return err;
230 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700231}
232
Chuck Lever262a0982008-12-12 16:57:35 -0500233/**
234 * write_add - Add or modify client entry in auth unix cache
235 *
236 * Deprecated. /proc/net/rpc/auth.unix.ip is preferred.
237 * Function remains to support old versions of nfs-utils.
238 *
239 * Input:
240 * buf: struct nfsctl_client
241 * cl_ident: '\0'-terminated C string
242 * containing domain name
243 * of client
244 * cl_naddr: no. of items in cl_addrlist
245 * cl_addrlist: array of client addresses
246 * cl_fhkeytype: ignored
247 * cl_fhkeylen: ignored
248 * cl_fhkey: ignored
249 * size: size in bytes of passed in nfsctl_client
250 * Output:
251 * On success: returns zero
252 * On error: return code is negative errno value
253 *
254 * Note: Only AF_INET client addresses are passed in, since
255 * nfsctl_client.cl_addrlist contains only in_addr fields for addresses.
256 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700257static ssize_t write_add(struct file *file, char *buf, size_t size)
258{
259 struct nfsctl_client *data;
260 if (size < sizeof(*data))
261 return -EINVAL;
262 data = (struct nfsctl_client *)buf;
263 return exp_addclient(data);
264}
265
Chuck Lever262a0982008-12-12 16:57:35 -0500266/**
267 * write_del - Remove client from auth unix cache
268 *
269 * Deprecated. /proc/net/rpc/auth.unix.ip is preferred.
270 * Function remains to support old versions of nfs-utils.
271 *
272 * Input:
273 * buf: struct nfsctl_client
274 * cl_ident: '\0'-terminated C string
275 * containing domain name
276 * of client
277 * cl_naddr: ignored
278 * cl_addrlist: ignored
279 * cl_fhkeytype: ignored
280 * cl_fhkeylen: ignored
281 * cl_fhkey: ignored
282 * size: size in bytes of passed in nfsctl_client
283 * Output:
284 * On success: returns zero
285 * On error: return code is negative errno value
286 *
287 * Note: Only AF_INET client addresses are passed in, since
288 * nfsctl_client.cl_addrlist contains only in_addr fields for addresses.
289 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700290static ssize_t write_del(struct file *file, char *buf, size_t size)
291{
292 struct nfsctl_client *data;
293 if (size < sizeof(*data))
294 return -EINVAL;
295 data = (struct nfsctl_client *)buf;
296 return exp_delclient(data);
297}
298
Chuck Lever262a0982008-12-12 16:57:35 -0500299/**
300 * write_export - Export part or all of a local file system
301 *
302 * Deprecated. /proc/net/rpc/{nfsd.export,nfsd.fh} are preferred.
303 * Function remains to support old versions of nfs-utils.
304 *
305 * Input:
306 * buf: struct nfsctl_export
307 * ex_client: '\0'-terminated C string
308 * containing domain name
309 * of client allowed to access
310 * this export
311 * ex_path: '\0'-terminated C string
312 * containing pathname of
313 * directory in local file system
314 * ex_dev: fsid to use for this export
315 * ex_ino: ignored
316 * ex_flags: export flags for this export
317 * ex_anon_uid: UID to use for anonymous
318 * requests
319 * ex_anon_gid: GID to use for anonymous
320 * requests
321 * size: size in bytes of passed in nfsctl_export
322 * Output:
323 * On success: returns zero
324 * On error: return code is negative errno value
325 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700326static ssize_t write_export(struct file *file, char *buf, size_t size)
327{
328 struct nfsctl_export *data;
329 if (size < sizeof(*data))
330 return -EINVAL;
331 data = (struct nfsctl_export*)buf;
332 return exp_export(data);
333}
334
Chuck Lever262a0982008-12-12 16:57:35 -0500335/**
336 * write_unexport - Unexport a previously exported file system
337 *
338 * Deprecated. /proc/net/rpc/{nfsd.export,nfsd.fh} are preferred.
339 * Function remains to support old versions of nfs-utils.
340 *
341 * Input:
342 * buf: struct nfsctl_export
343 * ex_client: '\0'-terminated C string
344 * containing domain name
345 * of client no longer allowed
346 * to access this export
347 * ex_path: '\0'-terminated C string
348 * containing pathname of
349 * directory in local file system
350 * ex_dev: ignored
351 * ex_ino: ignored
352 * ex_flags: ignored
353 * ex_anon_uid: ignored
354 * ex_anon_gid: ignored
355 * size: size in bytes of passed in nfsctl_export
356 * Output:
357 * On success: returns zero
358 * On error: return code is negative errno value
359 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700360static ssize_t write_unexport(struct file *file, char *buf, size_t size)
361{
362 struct nfsctl_export *data;
363
364 if (size < sizeof(*data))
365 return -EINVAL;
366 data = (struct nfsctl_export*)buf;
367 return exp_unexport(data);
368}
369
Chuck Lever262a0982008-12-12 16:57:35 -0500370/**
371 * write_getfs - Get a variable-length NFS file handle by path
372 *
373 * Deprecated. /proc/fs/nfsd/filehandle is preferred.
374 * Function remains to support old versions of nfs-utils.
375 *
376 * Input:
377 * buf: struct nfsctl_fsparm
378 * gd_addr: socket address of client
379 * gd_path: '\0'-terminated C string
380 * containing pathname of
381 * directory in local file system
382 * gd_maxlen: maximum size of returned file
383 * handle
384 * size: size in bytes of passed in nfsctl_fsparm
385 * Output:
386 * On success: passed-in buffer filled with a knfsd_fh structure
387 * (a variable-length raw NFS file handle);
388 * return code is the size in bytes of the file handle
389 * On error: return code is negative errno value
390 *
391 * Note: Only AF_INET client addresses are passed in, since gd_addr
392 * is the same size as a struct sockaddr_in.
393 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700394static ssize_t write_getfs(struct file *file, char *buf, size_t size)
395{
396 struct nfsctl_fsparm *data;
397 struct sockaddr_in *sin;
398 struct auth_domain *clp;
399 int err = 0;
400 struct knfsd_fh *res;
Aurélien Charbonf15364b2008-01-18 15:50:56 +0100401 struct in6_addr in6;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700402
403 if (size < sizeof(*data))
404 return -EINVAL;
405 data = (struct nfsctl_fsparm*)buf;
406 err = -EPROTONOSUPPORT;
407 if (data->gd_addr.sa_family != AF_INET)
408 goto out;
409 sin = (struct sockaddr_in *)&data->gd_addr;
410 if (data->gd_maxlen > NFS3_FHSIZE)
411 data->gd_maxlen = NFS3_FHSIZE;
412
413 res = (struct knfsd_fh*)buf;
414
415 exp_readlock();
Aurélien Charbonf15364b2008-01-18 15:50:56 +0100416
417 ipv6_addr_set_v4mapped(sin->sin_addr.s_addr, &in6);
418
Pavel Emelyanov352114f2010-09-27 13:59:48 +0400419 clp = auth_unix_lookup(&init_net, &in6);
Aurélien Charbonf15364b2008-01-18 15:50:56 +0100420 if (!clp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700421 err = -EPERM;
422 else {
423 err = exp_rootfh(clp, data->gd_path, res, data->gd_maxlen);
424 auth_domain_put(clp);
425 }
426 exp_readunlock();
427 if (err == 0)
Andrew Morton12127492007-07-17 04:04:34 -0700428 err = res->fh_size + offsetof(struct knfsd_fh, fh_base);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700429 out:
430 return err;
431}
432
Chuck Lever262a0982008-12-12 16:57:35 -0500433/**
434 * write_getfd - Get a fixed-length NFS file handle by path (used by mountd)
435 *
436 * Deprecated. /proc/fs/nfsd/filehandle is preferred.
437 * Function remains to support old versions of nfs-utils.
438 *
439 * Input:
440 * buf: struct nfsctl_fdparm
441 * gd_addr: socket address of client
442 * gd_path: '\0'-terminated C string
443 * containing pathname of
444 * directory in local file system
445 * gd_version: fdparm structure version
446 * size: size in bytes of passed in nfsctl_fdparm
447 * Output:
448 * On success: passed-in buffer filled with nfsctl_res
449 * (a fixed-length raw NFS file handle);
450 * return code is the size in bytes of the file handle
451 * On error: return code is negative errno value
452 *
453 * Note: Only AF_INET client addresses are passed in, since gd_addr
454 * is the same size as a struct sockaddr_in.
455 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700456static ssize_t write_getfd(struct file *file, char *buf, size_t size)
457{
458 struct nfsctl_fdparm *data;
459 struct sockaddr_in *sin;
460 struct auth_domain *clp;
461 int err = 0;
462 struct knfsd_fh fh;
463 char *res;
Aurélien Charbonf15364b2008-01-18 15:50:56 +0100464 struct in6_addr in6;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700465
466 if (size < sizeof(*data))
467 return -EINVAL;
468 data = (struct nfsctl_fdparm*)buf;
469 err = -EPROTONOSUPPORT;
470 if (data->gd_addr.sa_family != AF_INET)
471 goto out;
472 err = -EINVAL;
473 if (data->gd_version < 2 || data->gd_version > NFSSVC_MAXVERS)
474 goto out;
475
476 res = buf;
477 sin = (struct sockaddr_in *)&data->gd_addr;
478 exp_readlock();
Aurélien Charbonf15364b2008-01-18 15:50:56 +0100479
480 ipv6_addr_set_v4mapped(sin->sin_addr.s_addr, &in6);
481
Pavel Emelyanov352114f2010-09-27 13:59:48 +0400482 clp = auth_unix_lookup(&init_net, &in6);
Aurélien Charbonf15364b2008-01-18 15:50:56 +0100483 if (!clp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700484 err = -EPERM;
485 else {
486 err = exp_rootfh(clp, data->gd_path, &fh, NFS_FHSIZE);
487 auth_domain_put(clp);
488 }
489 exp_readunlock();
490
491 if (err == 0) {
492 memset(res,0, NFS_FHSIZE);
493 memcpy(res, &fh.fh_base, fh.fh_size);
494 err = NFS_FHSIZE;
495 }
496 out:
497 return err;
498}
NeilBrown1e140562010-09-22 12:55:07 +1000499#endif /* CONFIG_NFSD_DEPRECATED */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700500
Chuck Lever262a0982008-12-12 16:57:35 -0500501/**
502 * write_unlock_ip - Release all locks used by a client
503 *
504 * Experimental.
505 *
506 * Input:
507 * buf: '\n'-terminated C string containing a
Chuck Lever41160922009-08-09 15:09:40 -0400508 * presentation format IP address
Chuck Lever262a0982008-12-12 16:57:35 -0500509 * size: length of C string in @buf
510 * Output:
511 * On success: returns zero if all specified locks were released;
512 * returns one if one or more locks were not released
513 * On error: return code is negative errno value
Chuck Lever262a0982008-12-12 16:57:35 -0500514 */
Chuck Leverb046ccd2008-12-12 16:57:13 -0500515static ssize_t write_unlock_ip(struct file *file, char *buf, size_t size)
Wendy Cheng4373ea82008-01-17 11:10:12 -0500516{
Chuck Lever41160922009-08-09 15:09:40 -0400517 struct sockaddr_storage address;
518 struct sockaddr *sap = (struct sockaddr *)&address;
519 size_t salen = sizeof(address);
Chuck Lever367c8c72008-06-30 18:58:14 -0400520 char *fo_path;
Wendy Cheng4373ea82008-01-17 11:10:12 -0500521
522 /* sanity check */
523 if (size == 0)
524 return -EINVAL;
525
526 if (buf[size-1] != '\n')
527 return -EINVAL;
528
529 fo_path = buf;
530 if (qword_get(&buf, fo_path, size) < 0)
531 return -EINVAL;
532
Chuck Lever41160922009-08-09 15:09:40 -0400533 if (rpc_pton(fo_path, size, sap, salen) == 0)
Wendy Cheng4373ea82008-01-17 11:10:12 -0500534 return -EINVAL;
Wendy Cheng4373ea82008-01-17 11:10:12 -0500535
Chuck Lever41160922009-08-09 15:09:40 -0400536 return nlmsvc_unlock_all_by_ip(sap);
Wendy Cheng4373ea82008-01-17 11:10:12 -0500537}
538
Chuck Lever262a0982008-12-12 16:57:35 -0500539/**
540 * write_unlock_fs - Release all locks on a local file system
541 *
542 * Experimental.
543 *
544 * Input:
545 * buf: '\n'-terminated C string containing the
546 * absolute pathname of a local file system
547 * size: length of C string in @buf
548 * Output:
549 * On success: returns zero if all specified locks were released;
550 * returns one if one or more locks were not released
551 * On error: return code is negative errno value
552 */
Chuck Leverb046ccd2008-12-12 16:57:13 -0500553static ssize_t write_unlock_fs(struct file *file, char *buf, size_t size)
Wendy Cheng17efa372008-01-17 11:10:12 -0500554{
Al Viroa63bb992008-08-02 01:03:36 -0400555 struct path path;
Wendy Cheng17efa372008-01-17 11:10:12 -0500556 char *fo_path;
557 int error;
558
559 /* sanity check */
560 if (size == 0)
561 return -EINVAL;
562
563 if (buf[size-1] != '\n')
564 return -EINVAL;
565
566 fo_path = buf;
567 if (qword_get(&buf, fo_path, size) < 0)
568 return -EINVAL;
569
Al Viroa63bb992008-08-02 01:03:36 -0400570 error = kern_path(fo_path, 0, &path);
Wendy Cheng17efa372008-01-17 11:10:12 -0500571 if (error)
572 return error;
573
Chuck Lever262a0982008-12-12 16:57:35 -0500574 /*
575 * XXX: Needs better sanity checking. Otherwise we could end up
576 * releasing locks on the wrong file system.
577 *
578 * For example:
579 * 1. Does the path refer to a directory?
580 * 2. Is that directory a mount point, or
581 * 3. Is that directory the root of an exported file system?
582 */
Al Viroa63bb992008-08-02 01:03:36 -0400583 error = nlmsvc_unlock_all_by_sb(path.mnt->mnt_sb);
Wendy Cheng17efa372008-01-17 11:10:12 -0500584
Al Viroa63bb992008-08-02 01:03:36 -0400585 path_put(&path);
Wendy Cheng17efa372008-01-17 11:10:12 -0500586 return error;
587}
588
Chuck Lever262a0982008-12-12 16:57:35 -0500589/**
590 * write_filehandle - Get a variable-length NFS file handle by path
591 *
592 * On input, the buffer contains a '\n'-terminated C string comprised of
593 * three alphanumeric words separated by whitespace. The string may
594 * contain escape sequences.
595 *
596 * Input:
597 * buf:
598 * domain: client domain name
599 * path: export pathname
600 * maxsize: numeric maximum size of
601 * @buf
602 * size: length of C string in @buf
603 * Output:
604 * On success: passed-in buffer filled with '\n'-terminated C
605 * string containing a ASCII hex text version
606 * of the NFS file handle;
607 * return code is the size in bytes of the string
608 * On error: return code is negative errno value
609 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700610static ssize_t write_filehandle(struct file *file, char *buf, size_t size)
611{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700612 char *dname, *path;
Andrew Morton246d95b2007-08-09 00:53:50 -0700613 int uninitialized_var(maxsize);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700614 char *mesg = buf;
615 int len;
616 struct auth_domain *dom;
617 struct knfsd_fh fh;
618
J. Bruce Fields87d26ea2008-01-22 17:40:42 -0500619 if (size == 0)
620 return -EINVAL;
621
Linus Torvalds1da177e2005-04-16 15:20:36 -0700622 if (buf[size-1] != '\n')
623 return -EINVAL;
624 buf[size-1] = 0;
625
626 dname = mesg;
627 len = qword_get(&mesg, dname, size);
Chuck Lever54224f02008-12-12 16:57:20 -0500628 if (len <= 0)
629 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700630
631 path = dname+len+1;
632 len = qword_get(&mesg, path, size);
Chuck Lever54224f02008-12-12 16:57:20 -0500633 if (len <= 0)
634 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700635
636 len = get_int(&mesg, &maxsize);
637 if (len)
638 return len;
639
640 if (maxsize < NFS_FHSIZE)
641 return -EINVAL;
642 if (maxsize > NFS3_FHSIZE)
643 maxsize = NFS3_FHSIZE;
644
645 if (qword_get(&mesg, mesg, size)>0)
646 return -EINVAL;
647
648 /* we have all the words, they are in buf.. */
649 dom = unix_domain_find(dname);
650 if (!dom)
651 return -ENOMEM;
652
653 len = exp_rootfh(dom, path, &fh, maxsize);
654 auth_domain_put(dom);
655 if (len)
656 return len;
657
Chuck Lever54224f02008-12-12 16:57:20 -0500658 mesg = buf;
659 len = SIMPLE_TRANSACTION_LIMIT;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700660 qword_addhex(&mesg, &len, (char*)&fh.fh_base, fh.fh_size);
661 mesg[-1] = '\n';
662 return mesg - buf;
663}
664
Chuck Lever262a0982008-12-12 16:57:35 -0500665/**
666 * write_threads - Start NFSD, or report the current number of running threads
667 *
668 * Input:
669 * buf: ignored
670 * size: zero
671 * Output:
672 * On success: passed-in buffer filled with '\n'-terminated C
673 * string numeric value representing the number of
674 * running NFSD threads;
675 * return code is the size in bytes of the string
676 * On error: return code is zero
677 *
678 * OR
679 *
680 * Input:
681 * buf: C string containing an unsigned
682 * integer value representing the
683 * number of NFSD threads to start
684 * size: non-zero length of C string in @buf
685 * Output:
686 * On success: NFS service is started;
687 * passed-in buffer filled with '\n'-terminated C
688 * string numeric value representing the number of
689 * running NFSD threads;
690 * return code is the size in bytes of the string
691 * On error: return code is zero or a negative errno value
692 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700693static ssize_t write_threads(struct file *file, char *buf, size_t size)
694{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700695 char *mesg = buf;
696 int rv;
697 if (size > 0) {
698 int newthreads;
699 rv = get_int(&mesg, &newthreads);
700 if (rv)
701 return rv;
Chuck Lever9e074852008-12-12 16:57:27 -0500702 if (newthreads < 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700703 return -EINVAL;
Chuck Lever9e074852008-12-12 16:57:27 -0500704 rv = nfsd_svc(NFS_PORT, newthreads);
NeilBrown82e12fe2009-06-16 11:03:07 +1000705 if (rv < 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700706 return rv;
NeilBrown82e12fe2009-06-16 11:03:07 +1000707 } else
708 rv = nfsd_nrthreads();
Chuck Levere06b6402009-04-23 19:33:25 -0400709
NeilBrown82e12fe2009-06-16 11:03:07 +1000710 return scnprintf(buf, SIMPLE_TRANSACTION_LIMIT, "%d\n", rv);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700711}
712
Chuck Lever262a0982008-12-12 16:57:35 -0500713/**
714 * write_pool_threads - Set or report the current number of threads per pool
715 *
716 * Input:
717 * buf: ignored
718 * size: zero
719 *
720 * OR
721 *
722 * Input:
723 * buf: C string containing whitespace-
724 * separated unsigned integer values
725 * representing the number of NFSD
726 * threads to start in each pool
727 * size: non-zero length of C string in @buf
728 * Output:
729 * On success: passed-in buffer filled with '\n'-terminated C
730 * string containing integer values representing the
731 * number of NFSD threads in each pool;
732 * return code is the size in bytes of the string
733 * On error: return code is zero or a negative errno value
734 */
Greg Bankseed29652006-10-02 02:18:02 -0700735static ssize_t write_pool_threads(struct file *file, char *buf, size_t size)
736{
737 /* if size > 0, look for an array of number of threads per node
738 * and apply them then write out number of threads per node as reply
739 */
740 char *mesg = buf;
741 int i;
742 int rv;
743 int len;
Neil Brownbedbdd82008-06-10 08:40:35 -0400744 int npools;
Greg Bankseed29652006-10-02 02:18:02 -0700745 int *nthreads;
746
Neil Brownbedbdd82008-06-10 08:40:35 -0400747 mutex_lock(&nfsd_mutex);
748 npools = nfsd_nrpools();
Greg Bankseed29652006-10-02 02:18:02 -0700749 if (npools == 0) {
750 /*
751 * NFS is shut down. The admin can start it by
752 * writing to the threads file but NOT the pool_threads
753 * file, sorry. Report zero threads.
754 */
Neil Brownbedbdd82008-06-10 08:40:35 -0400755 mutex_unlock(&nfsd_mutex);
Greg Bankseed29652006-10-02 02:18:02 -0700756 strcpy(buf, "0\n");
757 return strlen(buf);
758 }
759
760 nthreads = kcalloc(npools, sizeof(int), GFP_KERNEL);
Neil Brownbedbdd82008-06-10 08:40:35 -0400761 rv = -ENOMEM;
Greg Bankseed29652006-10-02 02:18:02 -0700762 if (nthreads == NULL)
Neil Brownbedbdd82008-06-10 08:40:35 -0400763 goto out_free;
Greg Bankseed29652006-10-02 02:18:02 -0700764
765 if (size > 0) {
766 for (i = 0; i < npools; i++) {
767 rv = get_int(&mesg, &nthreads[i]);
768 if (rv == -ENOENT)
769 break; /* fewer numbers than pools */
770 if (rv)
771 goto out_free; /* syntax error */
772 rv = -EINVAL;
773 if (nthreads[i] < 0)
774 goto out_free;
775 }
776 rv = nfsd_set_nrthreads(i, nthreads);
777 if (rv)
778 goto out_free;
779 }
780
781 rv = nfsd_get_nrthreads(npools, nthreads);
782 if (rv)
783 goto out_free;
784
785 mesg = buf;
786 size = SIMPLE_TRANSACTION_LIMIT;
787 for (i = 0; i < npools && size > 0; i++) {
788 snprintf(mesg, size, "%d%c", nthreads[i], (i == npools-1 ? '\n' : ' '));
789 len = strlen(mesg);
790 size -= len;
791 mesg += len;
792 }
J. Bruce Fields413d63d7102009-07-28 11:37:25 -0400793 rv = mesg - buf;
Greg Bankseed29652006-10-02 02:18:02 -0700794out_free:
795 kfree(nthreads);
Neil Brownbedbdd82008-06-10 08:40:35 -0400796 mutex_unlock(&nfsd_mutex);
Greg Bankseed29652006-10-02 02:18:02 -0700797 return rv;
798}
799
Jeff Layton3dd98a32008-06-10 08:40:36 -0400800static ssize_t __write_versions(struct file *file, char *buf, size_t size)
NeilBrown70c3b762005-11-07 01:00:25 -0800801{
NeilBrown70c3b762005-11-07 01:00:25 -0800802 char *mesg = buf;
Benny Halevy8daf2202009-04-03 08:28:59 +0300803 char *vers, *minorp, sign;
Chuck Lever261758b2009-04-23 19:33:18 -0400804 int len, num, remaining;
Benny Halevy8daf2202009-04-03 08:28:59 +0300805 unsigned minor;
NeilBrown70c3b762005-11-07 01:00:25 -0800806 ssize_t tlen = 0;
807 char *sep;
808
809 if (size>0) {
810 if (nfsd_serv)
NeilBrown6658d3a2006-10-02 02:17:46 -0700811 /* Cannot change versions without updating
812 * nfsd_serv->sv_xdrsize, and reallocing
813 * rq_argp and rq_resp
814 */
NeilBrown70c3b762005-11-07 01:00:25 -0800815 return -EBUSY;
816 if (buf[size-1] != '\n')
817 return -EINVAL;
818 buf[size-1] = 0;
819
820 vers = mesg;
821 len = qword_get(&mesg, vers, size);
822 if (len <= 0) return -EINVAL;
823 do {
824 sign = *vers;
825 if (sign == '+' || sign == '-')
Benny Halevy8daf2202009-04-03 08:28:59 +0300826 num = simple_strtol((vers+1), &minorp, 0);
NeilBrown70c3b762005-11-07 01:00:25 -0800827 else
Benny Halevy8daf2202009-04-03 08:28:59 +0300828 num = simple_strtol(vers, &minorp, 0);
829 if (*minorp == '.') {
830 if (num < 4)
831 return -EINVAL;
832 minor = simple_strtoul(minorp+1, NULL, 0);
833 if (minor == 0)
834 return -EINVAL;
835 if (nfsd_minorversion(minor, sign == '-' ?
836 NFSD_CLEAR : NFSD_SET) < 0)
837 return -EINVAL;
838 goto next;
839 }
NeilBrown70c3b762005-11-07 01:00:25 -0800840 switch(num) {
841 case 2:
842 case 3:
843 case 4:
NeilBrown6658d3a2006-10-02 02:17:46 -0700844 nfsd_vers(num, sign == '-' ? NFSD_CLEAR : NFSD_SET);
NeilBrown70c3b762005-11-07 01:00:25 -0800845 break;
846 default:
847 return -EINVAL;
848 }
Benny Halevy8daf2202009-04-03 08:28:59 +0300849 next:
NeilBrown70c3b762005-11-07 01:00:25 -0800850 vers += len + 1;
NeilBrown70c3b762005-11-07 01:00:25 -0800851 } while ((len = qword_get(&mesg, vers, size)) > 0);
852 /* If all get turned off, turn them back on, as
853 * having no versions is BAD
854 */
NeilBrown6658d3a2006-10-02 02:17:46 -0700855 nfsd_reset_versions();
NeilBrown70c3b762005-11-07 01:00:25 -0800856 }
Chuck Lever261758b2009-04-23 19:33:18 -0400857
NeilBrown70c3b762005-11-07 01:00:25 -0800858 /* Now write current state into reply buffer */
859 len = 0;
860 sep = "";
Chuck Lever261758b2009-04-23 19:33:18 -0400861 remaining = SIMPLE_TRANSACTION_LIMIT;
NeilBrown70c3b762005-11-07 01:00:25 -0800862 for (num=2 ; num <= 4 ; num++)
NeilBrown6658d3a2006-10-02 02:17:46 -0700863 if (nfsd_vers(num, NFSD_AVAIL)) {
Chuck Lever261758b2009-04-23 19:33:18 -0400864 len = snprintf(buf, remaining, "%s%c%d", sep,
NeilBrown6658d3a2006-10-02 02:17:46 -0700865 nfsd_vers(num, NFSD_TEST)?'+':'-',
NeilBrown70c3b762005-11-07 01:00:25 -0800866 num);
867 sep = " ";
Chuck Lever261758b2009-04-23 19:33:18 -0400868
869 if (len > remaining)
870 break;
871 remaining -= len;
872 buf += len;
873 tlen += len;
NeilBrown70c3b762005-11-07 01:00:25 -0800874 }
Benny Halevy8daf2202009-04-03 08:28:59 +0300875 if (nfsd_vers(4, NFSD_AVAIL))
Chuck Lever261758b2009-04-23 19:33:18 -0400876 for (minor = 1; minor <= NFSD_SUPPORTED_MINOR_VERSION;
877 minor++) {
878 len = snprintf(buf, remaining, " %c4.%u",
Benny Halevy8daf2202009-04-03 08:28:59 +0300879 (nfsd_vers(4, NFSD_TEST) &&
880 nfsd_minorversion(minor, NFSD_TEST)) ?
881 '+' : '-',
882 minor);
Chuck Lever261758b2009-04-23 19:33:18 -0400883
884 if (len > remaining)
885 break;
886 remaining -= len;
887 buf += len;
888 tlen += len;
889 }
890
891 len = snprintf(buf, remaining, "\n");
892 if (len > remaining)
893 return -EINVAL;
894 return tlen + len;
NeilBrown70c3b762005-11-07 01:00:25 -0800895}
896
Chuck Lever262a0982008-12-12 16:57:35 -0500897/**
898 * write_versions - Set or report the available NFS protocol versions
899 *
900 * Input:
901 * buf: ignored
902 * size: zero
903 * Output:
904 * On success: passed-in buffer filled with '\n'-terminated C
905 * string containing positive or negative integer
906 * values representing the current status of each
907 * protocol version;
908 * return code is the size in bytes of the string
909 * On error: return code is zero or a negative errno value
910 *
911 * OR
912 *
913 * Input:
914 * buf: C string containing whitespace-
915 * separated positive or negative
916 * integer values representing NFS
917 * protocol versions to enable ("+n")
918 * or disable ("-n")
919 * size: non-zero length of C string in @buf
920 * Output:
921 * On success: status of zero or more protocol versions has
922 * been updated; passed-in buffer filled with
923 * '\n'-terminated C string containing positive
924 * or negative integer values representing the
925 * current status of each protocol version;
926 * return code is the size in bytes of the string
927 * On error: return code is zero or a negative errno value
928 */
Jeff Layton3dd98a32008-06-10 08:40:36 -0400929static ssize_t write_versions(struct file *file, char *buf, size_t size)
930{
931 ssize_t rv;
932
933 mutex_lock(&nfsd_mutex);
934 rv = __write_versions(file, buf, size);
935 mutex_unlock(&nfsd_mutex);
936 return rv;
937}
938
Chuck Lever4cd5dc72009-04-23 19:31:32 -0400939/*
Chuck Lever0a5372d2009-04-23 19:32:10 -0400940 * Zero-length write. Return a list of NFSD's current listener
941 * transports.
942 */
943static ssize_t __write_ports_names(char *buf)
944{
945 if (nfsd_serv == NULL)
946 return 0;
Chuck Lever335c54b2009-04-23 19:32:25 -0400947 return svc_xprt_names(nfsd_serv, buf, SIMPLE_TRANSACTION_LIMIT);
Chuck Lever0a5372d2009-04-23 19:32:10 -0400948}
949
950/*
Chuck Lever0b7c2f62009-04-23 19:31:55 -0400951 * A single 'fd' number was written, in which case it must be for
952 * a socket of a supported family/protocol, and we use it as an
953 * nfsd listener.
954 */
955static ssize_t __write_ports_addfd(char *buf)
956{
957 char *mesg = buf;
958 int fd, err;
959
960 err = get_int(&mesg, &fd);
961 if (err != 0 || fd < 0)
962 return -EINVAL;
963
964 err = nfsd_create_serv();
965 if (err != 0)
966 return err;
967
Chuck Leverbfba9ab2009-04-23 19:32:33 -0400968 err = svc_addsock(nfsd_serv, fd, buf, SIMPLE_TRANSACTION_LIMIT);
Jeff Layton78a8d7c2010-07-19 16:50:05 -0400969 if (err < 0) {
Jeff Layton78a8d7c2010-07-19 16:50:05 -0400970 svc_destroy(nfsd_serv);
971 return err;
972 }
Chuck Lever0b7c2f62009-04-23 19:31:55 -0400973
Chuck Leverea068ba2009-04-23 19:32:18 -0400974 /* Decrease the count, but don't shut down the service */
975 nfsd_serv->sv_nrthreads--;
976 return err;
Chuck Lever0b7c2f62009-04-23 19:31:55 -0400977}
978
979/*
Chuck Lever82d56592009-04-23 19:31:48 -0400980 * A '-' followed by the 'name' of a socket means we close the socket.
981 */
982static ssize_t __write_ports_delfd(char *buf)
983{
984 char *toclose;
985 int len = 0;
986
987 toclose = kstrdup(buf + 1, GFP_KERNEL);
988 if (toclose == NULL)
989 return -ENOMEM;
990
991 if (nfsd_serv != NULL)
Chuck Lever8435d342009-04-23 19:32:40 -0400992 len = svc_sock_names(nfsd_serv, buf,
993 SIMPLE_TRANSACTION_LIMIT, toclose);
Chuck Lever82d56592009-04-23 19:31:48 -0400994 kfree(toclose);
995 return len;
996}
997
998/*
Chuck Lever4eb68c22009-04-23 19:31:40 -0400999 * A transport listener is added by writing it's transport name and
1000 * a port number.
1001 */
1002static ssize_t __write_ports_addxprt(char *buf)
1003{
1004 char transport[16];
Chuck Lever37498292010-01-26 14:04:22 -05001005 struct svc_xprt *xprt;
Chuck Lever4eb68c22009-04-23 19:31:40 -04001006 int port, err;
1007
1008 if (sscanf(buf, "%15s %4u", transport, &port) != 2)
1009 return -EINVAL;
1010
Alexey Dobriyan4be929b2010-05-24 14:33:03 -07001011 if (port < 1 || port > USHRT_MAX)
Chuck Lever4eb68c22009-04-23 19:31:40 -04001012 return -EINVAL;
1013
1014 err = nfsd_create_serv();
1015 if (err != 0)
1016 return err;
1017
1018 err = svc_create_xprt(nfsd_serv, transport,
1019 PF_INET, port, SVC_SOCK_ANONYMOUS);
Chuck Lever68717902010-01-26 14:04:13 -05001020 if (err < 0)
Chuck Lever37498292010-01-26 14:04:22 -05001021 goto out_err;
1022
1023 err = svc_create_xprt(nfsd_serv, transport,
1024 PF_INET6, port, SVC_SOCK_ANONYMOUS);
1025 if (err < 0 && err != -EAFNOSUPPORT)
1026 goto out_close;
Jeff Layton0cd14a02010-07-19 16:50:06 -04001027
1028 /* Decrease the count, but don't shut down the service */
1029 nfsd_serv->sv_nrthreads--;
Chuck Lever4eb68c22009-04-23 19:31:40 -04001030 return 0;
Chuck Lever37498292010-01-26 14:04:22 -05001031out_close:
1032 xprt = svc_find_xprt(nfsd_serv, transport, PF_INET, port);
1033 if (xprt != NULL) {
1034 svc_close_xprt(xprt);
1035 svc_xprt_put(xprt);
1036 }
1037out_err:
Jeff Layton0cd14a02010-07-19 16:50:06 -04001038 svc_destroy(nfsd_serv);
Chuck Lever37498292010-01-26 14:04:22 -05001039 return err;
Chuck Lever4eb68c22009-04-23 19:31:40 -04001040}
1041
1042/*
Chuck Lever4cd5dc72009-04-23 19:31:32 -04001043 * A transport listener is removed by writing a "-", it's transport
1044 * name, and it's port number.
1045 */
1046static ssize_t __write_ports_delxprt(char *buf)
1047{
1048 struct svc_xprt *xprt;
1049 char transport[16];
1050 int port;
1051
1052 if (sscanf(&buf[1], "%15s %4u", transport, &port) != 2)
1053 return -EINVAL;
1054
Alexey Dobriyan4be929b2010-05-24 14:33:03 -07001055 if (port < 1 || port > USHRT_MAX || nfsd_serv == NULL)
Chuck Lever4cd5dc72009-04-23 19:31:32 -04001056 return -EINVAL;
1057
1058 xprt = svc_find_xprt(nfsd_serv, transport, AF_UNSPEC, port);
1059 if (xprt == NULL)
1060 return -ENOTCONN;
1061
1062 svc_close_xprt(xprt);
1063 svc_xprt_put(xprt);
1064 return 0;
1065}
1066
Neil Brownbedbdd82008-06-10 08:40:35 -04001067static ssize_t __write_ports(struct file *file, char *buf, size_t size)
NeilBrown80212d52006-10-02 02:17:47 -07001068{
Chuck Lever0a5372d2009-04-23 19:32:10 -04001069 if (size == 0)
1070 return __write_ports_names(buf);
Chuck Lever0b7c2f62009-04-23 19:31:55 -04001071
1072 if (isdigit(buf[0]))
1073 return __write_ports_addfd(buf);
Chuck Lever82d56592009-04-23 19:31:48 -04001074
1075 if (buf[0] == '-' && isdigit(buf[1]))
1076 return __write_ports_delfd(buf);
Chuck Lever4eb68c22009-04-23 19:31:40 -04001077
1078 if (isalpha(buf[0]))
1079 return __write_ports_addxprt(buf);
Chuck Lever4cd5dc72009-04-23 19:31:32 -04001080
1081 if (buf[0] == '-' && isalpha(buf[1]))
1082 return __write_ports_delxprt(buf);
1083
NeilBrownb41b66d2006-10-02 02:17:48 -07001084 return -EINVAL;
NeilBrown80212d52006-10-02 02:17:47 -07001085}
1086
Chuck Lever262a0982008-12-12 16:57:35 -05001087/**
1088 * write_ports - Pass a socket file descriptor or transport name to listen on
1089 *
1090 * Input:
1091 * buf: ignored
1092 * size: zero
1093 * Output:
1094 * On success: passed-in buffer filled with a '\n'-terminated C
1095 * string containing a whitespace-separated list of
1096 * named NFSD listeners;
1097 * return code is the size in bytes of the string
1098 * On error: return code is zero or a negative errno value
1099 *
1100 * OR
1101 *
1102 * Input:
1103 * buf: C string containing an unsigned
1104 * integer value representing a bound
1105 * but unconnected socket that is to be
Chuck Leverc71206a2009-04-23 19:32:03 -04001106 * used as an NFSD listener; listen(3)
1107 * must be called for a SOCK_STREAM
1108 * socket, otherwise it is ignored
Chuck Lever262a0982008-12-12 16:57:35 -05001109 * size: non-zero length of C string in @buf
1110 * Output:
1111 * On success: NFS service is started;
1112 * passed-in buffer filled with a '\n'-terminated C
1113 * string containing a unique alphanumeric name of
1114 * the listener;
1115 * return code is the size in bytes of the string
1116 * On error: return code is a negative errno value
1117 *
1118 * OR
1119 *
1120 * Input:
1121 * buf: C string containing a "-" followed
1122 * by an integer value representing a
1123 * previously passed in socket file
1124 * descriptor
1125 * size: non-zero length of C string in @buf
1126 * Output:
1127 * On success: NFS service no longer listens on that socket;
1128 * passed-in buffer filled with a '\n'-terminated C
1129 * string containing a unique name of the listener;
1130 * return code is the size in bytes of the string
1131 * On error: return code is a negative errno value
1132 *
1133 * OR
1134 *
1135 * Input:
1136 * buf: C string containing a transport
1137 * name and an unsigned integer value
1138 * representing the port to listen on,
1139 * separated by whitespace
1140 * size: non-zero length of C string in @buf
1141 * Output:
1142 * On success: returns zero; NFS service is started
1143 * On error: return code is a negative errno value
1144 *
1145 * OR
1146 *
1147 * Input:
1148 * buf: C string containing a "-" followed
1149 * by a transport name and an unsigned
1150 * integer value representing the port
1151 * to listen on, separated by whitespace
1152 * size: non-zero length of C string in @buf
1153 * Output:
1154 * On success: returns zero; NFS service no longer listens
1155 * on that transport
1156 * On error: return code is a negative errno value
1157 */
Neil Brownbedbdd82008-06-10 08:40:35 -04001158static ssize_t write_ports(struct file *file, char *buf, size_t size)
1159{
1160 ssize_t rv;
Jeff Layton3dd98a32008-06-10 08:40:36 -04001161
Neil Brownbedbdd82008-06-10 08:40:35 -04001162 mutex_lock(&nfsd_mutex);
1163 rv = __write_ports(file, buf, size);
1164 mutex_unlock(&nfsd_mutex);
1165 return rv;
1166}
1167
1168
NeilBrown596bbe52006-10-04 02:15:48 -07001169int nfsd_max_blksize;
1170
Chuck Lever262a0982008-12-12 16:57:35 -05001171/**
1172 * write_maxblksize - Set or report the current NFS blksize
1173 *
1174 * Input:
1175 * buf: ignored
1176 * size: zero
1177 *
1178 * OR
1179 *
1180 * Input:
1181 * buf: C string containing an unsigned
1182 * integer value representing the new
1183 * NFS blksize
1184 * size: non-zero length of C string in @buf
1185 * Output:
1186 * On success: passed-in buffer filled with '\n'-terminated C string
1187 * containing numeric value of the current NFS blksize
1188 * setting;
1189 * return code is the size in bytes of the string
1190 * On error: return code is zero or a negative errno value
1191 */
NeilBrown596bbe52006-10-04 02:15:48 -07001192static ssize_t write_maxblksize(struct file *file, char *buf, size_t size)
1193{
1194 char *mesg = buf;
1195 if (size > 0) {
1196 int bsize;
1197 int rv = get_int(&mesg, &bsize);
1198 if (rv)
1199 return rv;
1200 /* force bsize into allowed range and
1201 * required alignment.
1202 */
1203 if (bsize < 1024)
1204 bsize = 1024;
1205 if (bsize > NFSSVC_MAXBLKSIZE)
1206 bsize = NFSSVC_MAXBLKSIZE;
1207 bsize &= ~(1024-1);
Neil Brownbedbdd82008-06-10 08:40:35 -04001208 mutex_lock(&nfsd_mutex);
J. Bruce Fields7fa53cc2010-08-06 18:00:33 -04001209 if (nfsd_serv) {
Neil Brownbedbdd82008-06-10 08:40:35 -04001210 mutex_unlock(&nfsd_mutex);
NeilBrown596bbe52006-10-04 02:15:48 -07001211 return -EBUSY;
1212 }
1213 nfsd_max_blksize = bsize;
Neil Brownbedbdd82008-06-10 08:40:35 -04001214 mutex_unlock(&nfsd_mutex);
NeilBrown596bbe52006-10-04 02:15:48 -07001215 }
Chuck Levere06b6402009-04-23 19:33:25 -04001216
1217 return scnprintf(buf, SIMPLE_TRANSACTION_LIMIT, "%d\n",
1218 nfsd_max_blksize);
NeilBrown596bbe52006-10-04 02:15:48 -07001219}
1220
NeilBrown70c3b762005-11-07 01:00:25 -08001221#ifdef CONFIG_NFSD_V4
J. Bruce Fieldsf0135742010-03-01 19:32:36 -05001222static ssize_t __nfsd4_write_time(struct file *file, char *buf, size_t size, time_t *time)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001223{
Linus Torvalds1da177e2005-04-16 15:20:36 -07001224 char *mesg = buf;
J. Bruce Fieldsf0135742010-03-01 19:32:36 -05001225 int rv, i;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001226
1227 if (size > 0) {
Jeff Layton3dd98a32008-06-10 08:40:36 -04001228 if (nfsd_serv)
1229 return -EBUSY;
J. Bruce Fieldsf0135742010-03-01 19:32:36 -05001230 rv = get_int(&mesg, &i);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001231 if (rv)
1232 return rv;
J. Bruce Fieldse7b184f2010-03-02 11:18:40 -05001233 /*
1234 * Some sanity checking. We don't have a reason for
1235 * these particular numbers, but problems with the
1236 * extremes are:
1237 * - Too short: the briefest network outage may
1238 * cause clients to lose all their locks. Also,
1239 * the frequent polling may be wasteful.
1240 * - Too long: do you really want reboot recovery
1241 * to take more than an hour? Or to make other
1242 * clients wait an hour before being able to
1243 * revoke a dead client's locks?
1244 */
J. Bruce Fieldsf0135742010-03-01 19:32:36 -05001245 if (i < 10 || i > 3600)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001246 return -EINVAL;
J. Bruce Fieldsf0135742010-03-01 19:32:36 -05001247 *time = i;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001248 }
Chuck Levere06b6402009-04-23 19:33:25 -04001249
J. Bruce Fieldsf0135742010-03-01 19:32:36 -05001250 return scnprintf(buf, SIMPLE_TRANSACTION_LIMIT, "%ld\n", *time);
1251}
1252
1253static ssize_t nfsd4_write_time(struct file *file, char *buf, size_t size, time_t *time)
1254{
1255 ssize_t rv;
1256
1257 mutex_lock(&nfsd_mutex);
1258 rv = __nfsd4_write_time(file, buf, size, time);
1259 mutex_unlock(&nfsd_mutex);
1260 return rv;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001261}
1262
Chuck Lever262a0982008-12-12 16:57:35 -05001263/**
1264 * write_leasetime - Set or report the current NFSv4 lease time
1265 *
1266 * Input:
1267 * buf: ignored
1268 * size: zero
1269 *
1270 * OR
1271 *
1272 * Input:
1273 * buf: C string containing an unsigned
1274 * integer value representing the new
1275 * NFSv4 lease expiry time
1276 * size: non-zero length of C string in @buf
1277 * Output:
1278 * On success: passed-in buffer filled with '\n'-terminated C
1279 * string containing unsigned integer value of the
1280 * current lease expiry time;
1281 * return code is the size in bytes of the string
1282 * On error: return code is zero or a negative errno value
1283 */
Jeff Layton3dd98a32008-06-10 08:40:36 -04001284static ssize_t write_leasetime(struct file *file, char *buf, size_t size)
1285{
J. Bruce Fieldsf0135742010-03-01 19:32:36 -05001286 return nfsd4_write_time(file, buf, size, &nfsd4_lease);
Jeff Layton3dd98a32008-06-10 08:40:36 -04001287}
1288
J. Bruce Fieldsefc4bb4f2010-03-02 11:04:06 -05001289/**
1290 * write_gracetime - Set or report current NFSv4 grace period time
1291 *
1292 * As above, but sets the time of the NFSv4 grace period.
1293 *
1294 * Note this should never be set to less than the *previous*
1295 * lease-period time, but we don't try to enforce this. (In the common
1296 * case (a new boot), we don't know what the previous lease time was
1297 * anyway.)
1298 */
1299static ssize_t write_gracetime(struct file *file, char *buf, size_t size)
1300{
1301 return nfsd4_write_time(file, buf, size, &nfsd4_grace);
1302}
1303
Jeff Layton3dd98a32008-06-10 08:40:36 -04001304extern char *nfs4_recoverydir(void);
1305
1306static ssize_t __write_recoverydir(struct file *file, char *buf, size_t size)
NeilBrown0964a3d2005-06-23 22:04:32 -07001307{
1308 char *mesg = buf;
1309 char *recdir;
1310 int len, status;
1311
Jeff Layton3dd98a32008-06-10 08:40:36 -04001312 if (size > 0) {
1313 if (nfsd_serv)
1314 return -EBUSY;
1315 if (size > PATH_MAX || buf[size-1] != '\n')
1316 return -EINVAL;
1317 buf[size-1] = 0;
NeilBrown0964a3d2005-06-23 22:04:32 -07001318
Jeff Layton3dd98a32008-06-10 08:40:36 -04001319 recdir = mesg;
1320 len = qword_get(&mesg, recdir, size);
1321 if (len <= 0)
1322 return -EINVAL;
NeilBrown0964a3d2005-06-23 22:04:32 -07001323
Jeff Layton3dd98a32008-06-10 08:40:36 -04001324 status = nfs4_reset_recoverydir(recdir);
Andi Kleen69049962010-07-20 15:24:27 -07001325 if (status)
1326 return status;
Jeff Layton3dd98a32008-06-10 08:40:36 -04001327 }
Chuck Lever3d72ab82009-04-23 19:33:10 -04001328
1329 return scnprintf(buf, SIMPLE_TRANSACTION_LIMIT, "%s\n",
1330 nfs4_recoverydir());
NeilBrown0964a3d2005-06-23 22:04:32 -07001331}
Jeff Layton3dd98a32008-06-10 08:40:36 -04001332
Chuck Lever262a0982008-12-12 16:57:35 -05001333/**
1334 * write_recoverydir - Set or report the pathname of the recovery directory
1335 *
1336 * Input:
1337 * buf: ignored
1338 * size: zero
1339 *
1340 * OR
1341 *
1342 * Input:
1343 * buf: C string containing the pathname
1344 * of the directory on a local file
1345 * system containing permanent NFSv4
1346 * recovery data
1347 * size: non-zero length of C string in @buf
1348 * Output:
1349 * On success: passed-in buffer filled with '\n'-terminated C string
1350 * containing the current recovery pathname setting;
1351 * return code is the size in bytes of the string
1352 * On error: return code is zero or a negative errno value
1353 */
Jeff Layton3dd98a32008-06-10 08:40:36 -04001354static ssize_t write_recoverydir(struct file *file, char *buf, size_t size)
1355{
1356 ssize_t rv;
1357
1358 mutex_lock(&nfsd_mutex);
1359 rv = __write_recoverydir(file, buf, size);
1360 mutex_unlock(&nfsd_mutex);
1361 return rv;
1362}
1363
NeilBrown70c3b762005-11-07 01:00:25 -08001364#endif
NeilBrown0964a3d2005-06-23 22:04:32 -07001365
Linus Torvalds1da177e2005-04-16 15:20:36 -07001366/*----------------------------------------------------------------------------*/
1367/*
1368 * populating the filesystem.
1369 */
1370
1371static int nfsd_fill_super(struct super_block * sb, void * data, int silent)
1372{
1373 static struct tree_descr nfsd_files[] = {
NeilBrown1e140562010-09-22 12:55:07 +10001374#ifdef CONFIG_NFSD_DEPRECATED
Linus Torvalds1da177e2005-04-16 15:20:36 -07001375 [NFSD_Svc] = {".svc", &transaction_ops, S_IWUSR},
1376 [NFSD_Add] = {".add", &transaction_ops, S_IWUSR},
1377 [NFSD_Del] = {".del", &transaction_ops, S_IWUSR},
1378 [NFSD_Export] = {".export", &transaction_ops, S_IWUSR},
1379 [NFSD_Unexport] = {".unexport", &transaction_ops, S_IWUSR},
1380 [NFSD_Getfd] = {".getfd", &transaction_ops, S_IWUSR|S_IRUSR},
1381 [NFSD_Getfs] = {".getfs", &transaction_ops, S_IWUSR|S_IRUSR},
NeilBrown1e140562010-09-22 12:55:07 +10001382#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001383 [NFSD_List] = {"exports", &exports_operations, S_IRUGO},
J. Bruce Fieldse8e87532009-12-14 12:53:32 -05001384 [NFSD_Export_features] = {"export_features",
1385 &export_features_operations, S_IRUGO},
Wendy Cheng4373ea82008-01-17 11:10:12 -05001386 [NFSD_FO_UnlockIP] = {"unlock_ip",
1387 &transaction_ops, S_IWUSR|S_IRUSR},
Wendy Cheng17efa372008-01-17 11:10:12 -05001388 [NFSD_FO_UnlockFS] = {"unlock_filesystem",
1389 &transaction_ops, S_IWUSR|S_IRUSR},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001390 [NFSD_Fh] = {"filehandle", &transaction_ops, S_IWUSR|S_IRUSR},
1391 [NFSD_Threads] = {"threads", &transaction_ops, S_IWUSR|S_IRUSR},
Greg Bankseed29652006-10-02 02:18:02 -07001392 [NFSD_Pool_Threads] = {"pool_threads", &transaction_ops, S_IWUSR|S_IRUSR},
Greg Banks03cf6c92009-01-13 21:26:36 +11001393 [NFSD_Pool_Stats] = {"pool_stats", &pool_stats_operations, S_IRUGO},
NeilBrown70c3b762005-11-07 01:00:25 -08001394 [NFSD_Versions] = {"versions", &transaction_ops, S_IWUSR|S_IRUSR},
NeilBrown80212d52006-10-02 02:17:47 -07001395 [NFSD_Ports] = {"portlist", &transaction_ops, S_IWUSR|S_IRUGO},
NeilBrown596bbe52006-10-04 02:15:48 -07001396 [NFSD_MaxBlkSize] = {"max_block_size", &transaction_ops, S_IWUSR|S_IRUGO},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001397#ifdef CONFIG_NFSD_V4
1398 [NFSD_Leasetime] = {"nfsv4leasetime", &transaction_ops, S_IWUSR|S_IRUSR},
J. Bruce Fieldsefc4bb4f2010-03-02 11:04:06 -05001399 [NFSD_Gracetime] = {"nfsv4gracetime", &transaction_ops, S_IWUSR|S_IRUSR},
NeilBrown0964a3d2005-06-23 22:04:32 -07001400 [NFSD_RecoveryDir] = {"nfsv4recoverydir", &transaction_ops, S_IWUSR|S_IRUSR},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001401#endif
1402 /* last one */ {""}
1403 };
1404 return simple_fill_super(sb, 0x6e667364, nfsd_files);
1405}
1406
David Howells454e2392006-06-23 02:02:57 -07001407static int nfsd_get_sb(struct file_system_type *fs_type,
1408 int flags, const char *dev_name, void *data, struct vfsmount *mnt)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001409{
David Howells454e2392006-06-23 02:02:57 -07001410 return get_sb_single(fs_type, flags, data, nfsd_fill_super, mnt);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001411}
1412
1413static struct file_system_type nfsd_fs_type = {
1414 .owner = THIS_MODULE,
1415 .name = "nfsd",
1416 .get_sb = nfsd_get_sb,
1417 .kill_sb = kill_litter_super,
1418};
1419
J. Bruce Fieldse331f602007-11-12 17:32:21 -05001420#ifdef CONFIG_PROC_FS
1421static int create_proc_exports_entry(void)
1422{
1423 struct proc_dir_entry *entry;
1424
1425 entry = proc_mkdir("fs/nfs", NULL);
1426 if (!entry)
1427 return -ENOMEM;
Denis V. Lunev9ef2db22008-04-29 01:02:04 -07001428 entry = proc_create("exports", 0, entry, &exports_operations);
J. Bruce Fieldse331f602007-11-12 17:32:21 -05001429 if (!entry)
1430 return -ENOMEM;
J. Bruce Fieldse331f602007-11-12 17:32:21 -05001431 return 0;
1432}
1433#else /* CONFIG_PROC_FS */
1434static int create_proc_exports_entry(void)
1435{
1436 return 0;
1437}
1438#endif
1439
Linus Torvalds1da177e2005-04-16 15:20:36 -07001440static int __init init_nfsd(void)
1441{
1442 int retval;
1443 printk(KERN_INFO "Installing knfsd (copyright (C) 1996 okir@monad.swb.de).\n");
1444
J. Bruce Fieldse8ff2a82007-08-01 15:30:59 -04001445 retval = nfs4_state_init(); /* nfs4 locking state */
1446 if (retval)
1447 return retval;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001448 nfsd_stat_init(); /* Statistics */
J. Bruce Fieldsd5c34282007-11-09 14:10:56 -05001449 retval = nfsd_reply_cache_init();
1450 if (retval)
1451 goto out_free_stat;
J. Bruce Fieldsdbf847e2007-11-08 17:20:34 -05001452 retval = nfsd_export_init();
1453 if (retval)
1454 goto out_free_cache;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001455 nfsd_lockd_init(); /* lockd->nfsd callbacks */
J. Bruce Fieldsdbf847e2007-11-08 17:20:34 -05001456 retval = nfsd_idmap_init();
1457 if (retval)
1458 goto out_free_lockd;
J. Bruce Fieldse331f602007-11-12 17:32:21 -05001459 retval = create_proc_exports_entry();
1460 if (retval)
1461 goto out_free_idmap;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001462 retval = register_filesystem(&nfsd_fs_type);
J. Bruce Fields26808d32007-11-09 13:44:06 -05001463 if (retval)
1464 goto out_free_all;
1465 return 0;
1466out_free_all:
J. Bruce Fields26808d32007-11-09 13:44:06 -05001467 remove_proc_entry("fs/nfs/exports", NULL);
1468 remove_proc_entry("fs/nfs", NULL);
J. Bruce Fieldse331f602007-11-12 17:32:21 -05001469out_free_idmap:
J. Bruce Fieldsdbf847e2007-11-08 17:20:34 -05001470 nfsd_idmap_shutdown();
1471out_free_lockd:
J. Bruce Fields26808d32007-11-09 13:44:06 -05001472 nfsd_lockd_shutdown();
J. Bruce Fieldse331f602007-11-12 17:32:21 -05001473 nfsd_export_shutdown();
J. Bruce Fieldsdbf847e2007-11-08 17:20:34 -05001474out_free_cache:
J. Bruce Fieldse331f602007-11-12 17:32:21 -05001475 nfsd_reply_cache_shutdown();
J. Bruce Fieldsd5c34282007-11-09 14:10:56 -05001476out_free_stat:
1477 nfsd_stat_shutdown();
J. Bruce Fields26808d32007-11-09 13:44:06 -05001478 nfsd4_free_slabs();
Linus Torvalds1da177e2005-04-16 15:20:36 -07001479 return retval;
1480}
1481
1482static void __exit exit_nfsd(void)
1483{
1484 nfsd_export_shutdown();
J. Bruce Fieldsd5c34282007-11-09 14:10:56 -05001485 nfsd_reply_cache_shutdown();
Linus Torvalds1da177e2005-04-16 15:20:36 -07001486 remove_proc_entry("fs/nfs/exports", NULL);
1487 remove_proc_entry("fs/nfs", NULL);
1488 nfsd_stat_shutdown();
1489 nfsd_lockd_shutdown();
Linus Torvalds1da177e2005-04-16 15:20:36 -07001490 nfsd_idmap_shutdown();
J. Bruce Fieldse8ff2a82007-08-01 15:30:59 -04001491 nfsd4_free_slabs();
Linus Torvalds1da177e2005-04-16 15:20:36 -07001492 unregister_filesystem(&nfsd_fs_type);
1493}
1494
1495MODULE_AUTHOR("Olaf Kirch <okir@monad.swb.de>");
1496MODULE_LICENSE("GPL");
1497module_init(init_nfsd)
1498module_exit(exit_nfsd)