nfssvc.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682
  1. /*
  2. * Central processing for nfsd.
  3. *
  4. * Authors: Olaf Kirch (okir@monad.swb.de)
  5. *
  6. * Copyright (C) 1995, 1996, 1997 Olaf Kirch <okir@monad.swb.de>
  7. */
  8. #include <linux/sched.h>
  9. #include <linux/freezer.h>
  10. #include <linux/module.h>
  11. #include <linux/fs_struct.h>
  12. #include <linux/swap.h>
  13. #include <linux/nsproxy.h>
  14. #include <linux/sunrpc/stats.h>
  15. #include <linux/sunrpc/svcsock.h>
  16. #include <linux/lockd/bind.h>
  17. #include <linux/nfsacl.h>
  18. #include <linux/seq_file.h>
  19. #include <net/net_namespace.h>
  20. #include "nfsd.h"
  21. #include "cache.h"
  22. #include "vfs.h"
  23. #define NFSDDBG_FACILITY NFSDDBG_SVC
  24. extern struct svc_program nfsd_program;
  25. static int nfsd(void *vrqstp);
  26. struct timeval nfssvc_boot;
  27. /*
  28. * nfsd_mutex protects nfsd_serv -- both the pointer itself and the members
  29. * of the svc_serv struct. In particular, ->sv_nrthreads but also to some
  30. * extent ->sv_temp_socks and ->sv_permsocks. It also protects nfsdstats.th_cnt
  31. *
  32. * If (out side the lock) nfsd_serv is non-NULL, then it must point to a
  33. * properly initialised 'struct svc_serv' with ->sv_nrthreads > 0. That number
  34. * of nfsd threads must exist and each must listed in ->sp_all_threads in each
  35. * entry of ->sv_pools[].
  36. *
  37. * Transitions of the thread count between zero and non-zero are of particular
  38. * interest since the svc_serv needs to be created and initialized at that
  39. * point, or freed.
  40. *
  41. * Finally, the nfsd_mutex also protects some of the global variables that are
  42. * accessed when nfsd starts and that are settable via the write_* routines in
  43. * nfsctl.c. In particular:
  44. *
  45. * user_recovery_dirname
  46. * user_lease_time
  47. * nfsd_versions
  48. */
  49. DEFINE_MUTEX(nfsd_mutex);
  50. struct svc_serv *nfsd_serv;
  51. /*
  52. * nfsd_drc_lock protects nfsd_drc_max_pages and nfsd_drc_pages_used.
  53. * nfsd_drc_max_pages limits the total amount of memory available for
  54. * version 4.1 DRC caches.
  55. * nfsd_drc_pages_used tracks the current version 4.1 DRC memory usage.
  56. */
  57. spinlock_t nfsd_drc_lock;
  58. unsigned int nfsd_drc_max_mem;
  59. unsigned int nfsd_drc_mem_used;
  60. #if defined(CONFIG_NFSD_V2_ACL) || defined(CONFIG_NFSD_V3_ACL)
  61. static struct svc_stat nfsd_acl_svcstats;
  62. static struct svc_version * nfsd_acl_version[] = {
  63. [2] = &nfsd_acl_version2,
  64. [3] = &nfsd_acl_version3,
  65. };
  66. #define NFSD_ACL_MINVERS 2
  67. #define NFSD_ACL_NRVERS ARRAY_SIZE(nfsd_acl_version)
  68. static struct svc_version *nfsd_acl_versions[NFSD_ACL_NRVERS];
  69. static struct svc_program nfsd_acl_program = {
  70. .pg_prog = NFS_ACL_PROGRAM,
  71. .pg_nvers = NFSD_ACL_NRVERS,
  72. .pg_vers = nfsd_acl_versions,
  73. .pg_name = "nfsacl",
  74. .pg_class = "nfsd",
  75. .pg_stats = &nfsd_acl_svcstats,
  76. .pg_authenticate = &svc_set_client,
  77. };
  78. static struct svc_stat nfsd_acl_svcstats = {
  79. .program = &nfsd_acl_program,
  80. };
  81. #endif /* defined(CONFIG_NFSD_V2_ACL) || defined(CONFIG_NFSD_V3_ACL) */
  82. static struct svc_version * nfsd_version[] = {
  83. [2] = &nfsd_version2,
  84. #if defined(CONFIG_NFSD_V3)
  85. [3] = &nfsd_version3,
  86. #endif
  87. #if defined(CONFIG_NFSD_V4)
  88. [4] = &nfsd_version4,
  89. #endif
  90. };
  91. #define NFSD_MINVERS 2
  92. #define NFSD_NRVERS ARRAY_SIZE(nfsd_version)
  93. static struct svc_version *nfsd_versions[NFSD_NRVERS];
  94. struct svc_program nfsd_program = {
  95. #if defined(CONFIG_NFSD_V2_ACL) || defined(CONFIG_NFSD_V3_ACL)
  96. .pg_next = &nfsd_acl_program,
  97. #endif
  98. .pg_prog = NFS_PROGRAM, /* program number */
  99. .pg_nvers = NFSD_NRVERS, /* nr of entries in nfsd_version */
  100. .pg_vers = nfsd_versions, /* version table */
  101. .pg_name = "nfsd", /* program name */
  102. .pg_class = "nfsd", /* authentication class */
  103. .pg_stats = &nfsd_svcstats, /* version table */
  104. .pg_authenticate = &svc_set_client, /* export authentication */
  105. };
  106. u32 nfsd_supported_minorversion;
  107. int nfsd_vers(int vers, enum vers_op change)
  108. {
  109. if (vers < NFSD_MINVERS || vers >= NFSD_NRVERS)
  110. return 0;
  111. switch(change) {
  112. case NFSD_SET:
  113. nfsd_versions[vers] = nfsd_version[vers];
  114. #if defined(CONFIG_NFSD_V2_ACL) || defined(CONFIG_NFSD_V3_ACL)
  115. if (vers < NFSD_ACL_NRVERS)
  116. nfsd_acl_versions[vers] = nfsd_acl_version[vers];
  117. #endif
  118. break;
  119. case NFSD_CLEAR:
  120. nfsd_versions[vers] = NULL;
  121. #if defined(CONFIG_NFSD_V2_ACL) || defined(CONFIG_NFSD_V3_ACL)
  122. if (vers < NFSD_ACL_NRVERS)
  123. nfsd_acl_versions[vers] = NULL;
  124. #endif
  125. break;
  126. case NFSD_TEST:
  127. return nfsd_versions[vers] != NULL;
  128. case NFSD_AVAIL:
  129. return nfsd_version[vers] != NULL;
  130. }
  131. return 0;
  132. }
  133. int nfsd_minorversion(u32 minorversion, enum vers_op change)
  134. {
  135. if (minorversion > NFSD_SUPPORTED_MINOR_VERSION)
  136. return -1;
  137. switch(change) {
  138. case NFSD_SET:
  139. nfsd_supported_minorversion = minorversion;
  140. break;
  141. case NFSD_CLEAR:
  142. if (minorversion == 0)
  143. return -1;
  144. nfsd_supported_minorversion = minorversion - 1;
  145. break;
  146. case NFSD_TEST:
  147. return minorversion <= nfsd_supported_minorversion;
  148. case NFSD_AVAIL:
  149. return minorversion <= NFSD_SUPPORTED_MINOR_VERSION;
  150. }
  151. return 0;
  152. }
  153. /*
  154. * Maximum number of nfsd processes
  155. */
  156. #define NFSD_MAXSERVS 8192
  157. int nfsd_nrthreads(void)
  158. {
  159. int rv = 0;
  160. mutex_lock(&nfsd_mutex);
  161. if (nfsd_serv)
  162. rv = nfsd_serv->sv_nrthreads;
  163. mutex_unlock(&nfsd_mutex);
  164. return rv;
  165. }
  166. static int nfsd_init_socks(int port)
  167. {
  168. int error;
  169. if (!list_empty(&nfsd_serv->sv_permsocks))
  170. return 0;
  171. error = svc_create_xprt(nfsd_serv, "udp", &init_net, PF_INET, port,
  172. SVC_SOCK_DEFAULTS);
  173. if (error < 0)
  174. return error;
  175. error = svc_create_xprt(nfsd_serv, "tcp", &init_net, PF_INET, port,
  176. SVC_SOCK_DEFAULTS);
  177. if (error < 0)
  178. return error;
  179. return 0;
  180. }
  181. static bool nfsd_up = false;
  182. static int nfsd_startup(unsigned short port, int nrservs)
  183. {
  184. int ret;
  185. if (nfsd_up)
  186. return 0;
  187. /*
  188. * Readahead param cache - will no-op if it already exists.
  189. * (Note therefore results will be suboptimal if number of
  190. * threads is modified after nfsd start.)
  191. */
  192. ret = nfsd_racache_init(2*nrservs);
  193. if (ret)
  194. return ret;
  195. ret = nfsd_init_socks(port);
  196. if (ret)
  197. goto out_racache;
  198. ret = lockd_up(&init_net);
  199. if (ret)
  200. goto out_racache;
  201. ret = nfs4_state_start();
  202. if (ret)
  203. goto out_lockd;
  204. nfsd_up = true;
  205. return 0;
  206. out_lockd:
  207. lockd_down(&init_net);
  208. out_racache:
  209. nfsd_racache_shutdown();
  210. return ret;
  211. }
  212. static void nfsd_shutdown(void)
  213. {
  214. /*
  215. * write_ports can create the server without actually starting
  216. * any threads--if we get shut down before any threads are
  217. * started, then nfsd_last_thread will be run before any of this
  218. * other initialization has been done.
  219. */
  220. if (!nfsd_up)
  221. return;
  222. nfs4_state_shutdown();
  223. lockd_down(&init_net);
  224. nfsd_racache_shutdown();
  225. nfsd_up = false;
  226. }
  227. static void nfsd_last_thread(struct svc_serv *serv, struct net *net)
  228. {
  229. nfsd_shutdown();
  230. svc_rpcb_cleanup(serv, net);
  231. printk(KERN_WARNING "nfsd: last server has exited, flushing export "
  232. "cache\n");
  233. nfsd_export_flush(net);
  234. }
  235. void nfsd_reset_versions(void)
  236. {
  237. int found_one = 0;
  238. int i;
  239. for (i = NFSD_MINVERS; i < NFSD_NRVERS; i++) {
  240. if (nfsd_program.pg_vers[i])
  241. found_one = 1;
  242. }
  243. if (!found_one) {
  244. for (i = NFSD_MINVERS; i < NFSD_NRVERS; i++)
  245. nfsd_program.pg_vers[i] = nfsd_version[i];
  246. #if defined(CONFIG_NFSD_V2_ACL) || defined(CONFIG_NFSD_V3_ACL)
  247. for (i = NFSD_ACL_MINVERS; i < NFSD_ACL_NRVERS; i++)
  248. nfsd_acl_program.pg_vers[i] =
  249. nfsd_acl_version[i];
  250. #endif
  251. }
  252. }
  253. /*
  254. * Each session guarantees a negotiated per slot memory cache for replies
  255. * which in turn consumes memory beyond the v2/v3/v4.0 server. A dedicated
  256. * NFSv4.1 server might want to use more memory for a DRC than a machine
  257. * with mutiple services.
  258. *
  259. * Impose a hard limit on the number of pages for the DRC which varies
  260. * according to the machines free pages. This is of course only a default.
  261. *
  262. * For now this is a #defined shift which could be under admin control
  263. * in the future.
  264. */
  265. static void set_max_drc(void)
  266. {
  267. #define NFSD_DRC_SIZE_SHIFT 10
  268. nfsd_drc_max_mem = (nr_free_buffer_pages()
  269. >> NFSD_DRC_SIZE_SHIFT) * PAGE_SIZE;
  270. nfsd_drc_mem_used = 0;
  271. spin_lock_init(&nfsd_drc_lock);
  272. dprintk("%s nfsd_drc_max_mem %u \n", __func__, nfsd_drc_max_mem);
  273. }
  274. static int nfsd_get_default_max_blksize(void)
  275. {
  276. struct sysinfo i;
  277. unsigned long long target;
  278. unsigned long ret;
  279. si_meminfo(&i);
  280. target = (i.totalram - i.totalhigh) << PAGE_SHIFT;
  281. /*
  282. * Aim for 1/4096 of memory per thread This gives 1MB on 4Gig
  283. * machines, but only uses 32K on 128M machines. Bottom out at
  284. * 8K on 32M and smaller. Of course, this is only a default.
  285. */
  286. target >>= 12;
  287. ret = NFSSVC_MAXBLKSIZE;
  288. while (ret > target && ret >= 8*1024*2)
  289. ret /= 2;
  290. return ret;
  291. }
  292. int nfsd_create_serv(void)
  293. {
  294. int error;
  295. struct net *net = current->nsproxy->net_ns;
  296. WARN_ON(!mutex_is_locked(&nfsd_mutex));
  297. if (nfsd_serv) {
  298. svc_get(nfsd_serv);
  299. return 0;
  300. }
  301. if (nfsd_max_blksize == 0)
  302. nfsd_max_blksize = nfsd_get_default_max_blksize();
  303. nfsd_reset_versions();
  304. nfsd_serv = svc_create_pooled(&nfsd_program, nfsd_max_blksize,
  305. nfsd_last_thread, nfsd, THIS_MODULE);
  306. if (nfsd_serv == NULL)
  307. return -ENOMEM;
  308. error = svc_bind(nfsd_serv, net);
  309. if (error < 0) {
  310. svc_destroy(nfsd_serv);
  311. return error;
  312. }
  313. set_max_drc();
  314. do_gettimeofday(&nfssvc_boot); /* record boot time */
  315. return 0;
  316. }
  317. int nfsd_nrpools(void)
  318. {
  319. if (nfsd_serv == NULL)
  320. return 0;
  321. else
  322. return nfsd_serv->sv_nrpools;
  323. }
  324. int nfsd_get_nrthreads(int n, int *nthreads)
  325. {
  326. int i = 0;
  327. if (nfsd_serv != NULL) {
  328. for (i = 0; i < nfsd_serv->sv_nrpools && i < n; i++)
  329. nthreads[i] = nfsd_serv->sv_pools[i].sp_nrthreads;
  330. }
  331. return 0;
  332. }
  333. int nfsd_set_nrthreads(int n, int *nthreads)
  334. {
  335. int i = 0;
  336. int tot = 0;
  337. int err = 0;
  338. struct net *net = &init_net;
  339. WARN_ON(!mutex_is_locked(&nfsd_mutex));
  340. if (nfsd_serv == NULL || n <= 0)
  341. return 0;
  342. if (n > nfsd_serv->sv_nrpools)
  343. n = nfsd_serv->sv_nrpools;
  344. /* enforce a global maximum number of threads */
  345. tot = 0;
  346. for (i = 0; i < n; i++) {
  347. if (nthreads[i] > NFSD_MAXSERVS)
  348. nthreads[i] = NFSD_MAXSERVS;
  349. tot += nthreads[i];
  350. }
  351. if (tot > NFSD_MAXSERVS) {
  352. /* total too large: scale down requested numbers */
  353. for (i = 0; i < n && tot > 0; i++) {
  354. int new = nthreads[i] * NFSD_MAXSERVS / tot;
  355. tot -= (nthreads[i] - new);
  356. nthreads[i] = new;
  357. }
  358. for (i = 0; i < n && tot > 0; i++) {
  359. nthreads[i]--;
  360. tot--;
  361. }
  362. }
  363. /*
  364. * There must always be a thread in pool 0; the admin
  365. * can't shut down NFS completely using pool_threads.
  366. */
  367. if (nthreads[0] == 0)
  368. nthreads[0] = 1;
  369. /* apply the new numbers */
  370. svc_get(nfsd_serv);
  371. for (i = 0; i < n; i++) {
  372. err = svc_set_num_threads(nfsd_serv, &nfsd_serv->sv_pools[i],
  373. nthreads[i]);
  374. if (err)
  375. break;
  376. }
  377. nfsd_destroy(net);
  378. return err;
  379. }
  380. /*
  381. * Adjust the number of threads and return the new number of threads.
  382. * This is also the function that starts the server if necessary, if
  383. * this is the first time nrservs is nonzero.
  384. */
  385. int
  386. nfsd_svc(unsigned short port, int nrservs)
  387. {
  388. int error;
  389. bool nfsd_up_before;
  390. struct net *net = &init_net;
  391. mutex_lock(&nfsd_mutex);
  392. dprintk("nfsd: creating service\n");
  393. if (nrservs <= 0)
  394. nrservs = 0;
  395. if (nrservs > NFSD_MAXSERVS)
  396. nrservs = NFSD_MAXSERVS;
  397. error = 0;
  398. if (nrservs == 0 && nfsd_serv == NULL)
  399. goto out;
  400. error = nfsd_create_serv();
  401. if (error)
  402. goto out;
  403. nfsd_up_before = nfsd_up;
  404. error = nfsd_startup(port, nrservs);
  405. if (error)
  406. goto out_destroy;
  407. error = svc_set_num_threads(nfsd_serv, NULL, nrservs);
  408. if (error)
  409. goto out_shutdown;
  410. /* We are holding a reference to nfsd_serv which
  411. * we don't want to count in the return value,
  412. * so subtract 1
  413. */
  414. error = nfsd_serv->sv_nrthreads - 1;
  415. out_shutdown:
  416. if (error < 0 && !nfsd_up_before)
  417. nfsd_shutdown();
  418. out_destroy:
  419. nfsd_destroy(net); /* Release server */
  420. out:
  421. mutex_unlock(&nfsd_mutex);
  422. return error;
  423. }
  424. /*
  425. * This is the NFS server kernel thread
  426. */
  427. static int
  428. nfsd(void *vrqstp)
  429. {
  430. struct svc_rqst *rqstp = (struct svc_rqst *) vrqstp;
  431. int err, preverr = 0;
  432. /* Lock module and set up kernel thread */
  433. mutex_lock(&nfsd_mutex);
  434. /* At this point, the thread shares current->fs
  435. * with the init process. We need to create files with a
  436. * umask of 0 instead of init's umask. */
  437. if (unshare_fs_struct() < 0) {
  438. printk("Unable to start nfsd thread: out of memory\n");
  439. goto out;
  440. }
  441. current->fs->umask = 0;
  442. /*
  443. * thread is spawned with all signals set to SIG_IGN, re-enable
  444. * the ones that will bring down the thread
  445. */
  446. allow_signal(SIGKILL);
  447. allow_signal(SIGHUP);
  448. allow_signal(SIGINT);
  449. allow_signal(SIGQUIT);
  450. nfsdstats.th_cnt++;
  451. mutex_unlock(&nfsd_mutex);
  452. /*
  453. * We want less throttling in balance_dirty_pages() so that nfs to
  454. * localhost doesn't cause nfsd to lock up due to all the client's
  455. * dirty pages.
  456. */
  457. current->flags |= PF_LESS_THROTTLE;
  458. set_freezable();
  459. /*
  460. * The main request loop
  461. */
  462. for (;;) {
  463. /*
  464. * Find a socket with data available and call its
  465. * recvfrom routine.
  466. */
  467. while ((err = svc_recv(rqstp, 60*60*HZ)) == -EAGAIN)
  468. ;
  469. if (err == -EINTR)
  470. break;
  471. else if (err < 0) {
  472. if (err != preverr) {
  473. printk(KERN_WARNING "%s: unexpected error "
  474. "from svc_recv (%d)\n", __func__, -err);
  475. preverr = err;
  476. }
  477. schedule_timeout_uninterruptible(HZ);
  478. continue;
  479. }
  480. validate_process_creds();
  481. svc_process(rqstp);
  482. validate_process_creds();
  483. }
  484. /* Clear signals before calling svc_exit_thread() */
  485. flush_signals(current);
  486. mutex_lock(&nfsd_mutex);
  487. nfsdstats.th_cnt --;
  488. out:
  489. rqstp->rq_server = NULL;
  490. /* Release the thread */
  491. svc_exit_thread(rqstp);
  492. nfsd_destroy(&init_net);
  493. /* Release module */
  494. mutex_unlock(&nfsd_mutex);
  495. module_put_and_exit(0);
  496. return 0;
  497. }
  498. static __be32 map_new_errors(u32 vers, __be32 nfserr)
  499. {
  500. if (nfserr == nfserr_jukebox && vers == 2)
  501. return nfserr_dropit;
  502. if (nfserr == nfserr_wrongsec && vers < 4)
  503. return nfserr_acces;
  504. return nfserr;
  505. }
  506. int
  507. nfsd_dispatch(struct svc_rqst *rqstp, __be32 *statp)
  508. {
  509. struct svc_procedure *proc;
  510. kxdrproc_t xdr;
  511. __be32 nfserr;
  512. __be32 *nfserrp;
  513. dprintk("nfsd_dispatch: vers %d proc %d\n",
  514. rqstp->rq_vers, rqstp->rq_proc);
  515. proc = rqstp->rq_procinfo;
  516. /*
  517. * Give the xdr decoder a chance to change this if it wants
  518. * (necessary in the NFSv4.0 compound case)
  519. */
  520. rqstp->rq_cachetype = proc->pc_cachetype;
  521. /* Decode arguments */
  522. xdr = proc->pc_decode;
  523. if (xdr && !xdr(rqstp, (__be32*)rqstp->rq_arg.head[0].iov_base,
  524. rqstp->rq_argp)) {
  525. dprintk("nfsd: failed to decode arguments!\n");
  526. *statp = rpc_garbage_args;
  527. return 1;
  528. }
  529. /* Check whether we have this call in the cache. */
  530. switch (nfsd_cache_lookup(rqstp)) {
  531. case RC_INTR:
  532. case RC_DROPIT:
  533. return 0;
  534. case RC_REPLY:
  535. return 1;
  536. case RC_DOIT:;
  537. /* do it */
  538. }
  539. /* need to grab the location to store the status, as
  540. * nfsv4 does some encoding while processing
  541. */
  542. nfserrp = rqstp->rq_res.head[0].iov_base
  543. + rqstp->rq_res.head[0].iov_len;
  544. rqstp->rq_res.head[0].iov_len += sizeof(__be32);
  545. /* Now call the procedure handler, and encode NFS status. */
  546. nfserr = proc->pc_func(rqstp, rqstp->rq_argp, rqstp->rq_resp);
  547. nfserr = map_new_errors(rqstp->rq_vers, nfserr);
  548. if (nfserr == nfserr_dropit || rqstp->rq_dropme) {
  549. dprintk("nfsd: Dropping request; may be revisited later\n");
  550. nfsd_cache_update(rqstp, RC_NOCACHE, NULL);
  551. return 0;
  552. }
  553. if (rqstp->rq_proc != 0)
  554. *nfserrp++ = nfserr;
  555. /* Encode result.
  556. * For NFSv2, additional info is never returned in case of an error.
  557. */
  558. if (!(nfserr && rqstp->rq_vers == 2)) {
  559. xdr = proc->pc_encode;
  560. if (xdr && !xdr(rqstp, nfserrp,
  561. rqstp->rq_resp)) {
  562. /* Failed to encode result. Release cache entry */
  563. dprintk("nfsd: failed to encode result!\n");
  564. nfsd_cache_update(rqstp, RC_NOCACHE, NULL);
  565. *statp = rpc_system_err;
  566. return 1;
  567. }
  568. }
  569. /* Store reply in cache. */
  570. nfsd_cache_update(rqstp, proc->pc_cachetype, statp + 1);
  571. return 1;
  572. }
  573. int nfsd_pool_stats_open(struct inode *inode, struct file *file)
  574. {
  575. int ret;
  576. mutex_lock(&nfsd_mutex);
  577. if (nfsd_serv == NULL) {
  578. mutex_unlock(&nfsd_mutex);
  579. return -ENODEV;
  580. }
  581. /* bump up the psudo refcount while traversing */
  582. svc_get(nfsd_serv);
  583. ret = svc_pool_stats_open(nfsd_serv, file);
  584. mutex_unlock(&nfsd_mutex);
  585. return ret;
  586. }
  587. int nfsd_pool_stats_release(struct inode *inode, struct file *file)
  588. {
  589. int ret = seq_release(inode, file);
  590. struct net *net = &init_net;
  591. mutex_lock(&nfsd_mutex);
  592. /* this function really, really should have been called svc_put() */
  593. nfsd_destroy(net);
  594. mutex_unlock(&nfsd_mutex);
  595. return ret;
  596. }