nfsctl.c 34 KB

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