nfs4state.c 31 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198
  1. /*
  2. * fs/nfs/nfs4state.c
  3. *
  4. * Client-side XDR for NFSv4.
  5. *
  6. * Copyright (c) 2002 The Regents of the University of Michigan.
  7. * All rights reserved.
  8. *
  9. * Kendrick Smith <kmsmith@umich.edu>
  10. *
  11. * Redistribution and use in source and binary forms, with or without
  12. * modification, are permitted provided that the following conditions
  13. * are met:
  14. *
  15. * 1. Redistributions of source code must retain the above copyright
  16. * notice, this list of conditions and the following disclaimer.
  17. * 2. Redistributions in binary form must reproduce the above copyright
  18. * notice, this list of conditions and the following disclaimer in the
  19. * documentation and/or other materials provided with the distribution.
  20. * 3. Neither the name of the University nor the names of its
  21. * contributors may be used to endorse or promote products derived
  22. * from this software without specific prior written permission.
  23. *
  24. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
  25. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  26. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  27. * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  28. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  29. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  30. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
  31. * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  32. * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  33. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  34. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  35. *
  36. * Implementation of the NFSv4 state model. For the time being,
  37. * this is minimal, but will be made much more complex in a
  38. * subsequent patch.
  39. */
  40. #include <linux/kernel.h>
  41. #include <linux/slab.h>
  42. #include <linux/smp_lock.h>
  43. #include <linux/nfs_fs.h>
  44. #include <linux/nfs_idmap.h>
  45. #include <linux/kthread.h>
  46. #include <linux/module.h>
  47. #include <linux/random.h>
  48. #include <linux/workqueue.h>
  49. #include <linux/bitops.h>
  50. #include "nfs4_fs.h"
  51. #include "callback.h"
  52. #include "delegation.h"
  53. #include "internal.h"
  54. #define OPENOWNER_POOL_SIZE 8
  55. const nfs4_stateid zero_stateid;
  56. static LIST_HEAD(nfs4_clientid_list);
  57. static int nfs4_init_client(struct nfs_client *clp, struct rpc_cred *cred)
  58. {
  59. unsigned short port;
  60. int status;
  61. port = nfs_callback_tcpport;
  62. if (clp->cl_addr.ss_family == AF_INET6)
  63. port = nfs_callback_tcpport6;
  64. status = nfs4_proc_setclientid(clp, NFS4_CALLBACK, port, cred);
  65. if (status == 0)
  66. status = nfs4_proc_setclientid_confirm(clp, cred);
  67. if (status == 0)
  68. nfs4_schedule_state_renewal(clp);
  69. return status;
  70. }
  71. static struct rpc_cred *nfs4_get_machine_cred_locked(struct nfs_client *clp)
  72. {
  73. struct rpc_cred *cred = NULL;
  74. if (clp->cl_machine_cred != NULL)
  75. cred = get_rpccred(clp->cl_machine_cred);
  76. return cred;
  77. }
  78. static void nfs4_clear_machine_cred(struct nfs_client *clp)
  79. {
  80. struct rpc_cred *cred;
  81. spin_lock(&clp->cl_lock);
  82. cred = clp->cl_machine_cred;
  83. clp->cl_machine_cred = NULL;
  84. spin_unlock(&clp->cl_lock);
  85. if (cred != NULL)
  86. put_rpccred(cred);
  87. }
  88. struct rpc_cred *nfs4_get_renew_cred_locked(struct nfs_client *clp)
  89. {
  90. struct nfs4_state_owner *sp;
  91. struct rb_node *pos;
  92. struct rpc_cred *cred = NULL;
  93. for (pos = rb_first(&clp->cl_state_owners); pos != NULL; pos = rb_next(pos)) {
  94. sp = rb_entry(pos, struct nfs4_state_owner, so_client_node);
  95. if (list_empty(&sp->so_states))
  96. continue;
  97. cred = get_rpccred(sp->so_cred);
  98. break;
  99. }
  100. return cred;
  101. }
  102. static struct rpc_cred *nfs4_get_renew_cred(struct nfs_client *clp)
  103. {
  104. struct rpc_cred *cred;
  105. spin_lock(&clp->cl_lock);
  106. cred = nfs4_get_renew_cred_locked(clp);
  107. spin_unlock(&clp->cl_lock);
  108. return cred;
  109. }
  110. static struct rpc_cred *nfs4_get_setclientid_cred(struct nfs_client *clp)
  111. {
  112. struct nfs4_state_owner *sp;
  113. struct rb_node *pos;
  114. struct rpc_cred *cred;
  115. spin_lock(&clp->cl_lock);
  116. cred = nfs4_get_machine_cred_locked(clp);
  117. if (cred != NULL)
  118. goto out;
  119. pos = rb_first(&clp->cl_state_owners);
  120. if (pos != NULL) {
  121. sp = rb_entry(pos, struct nfs4_state_owner, so_client_node);
  122. cred = get_rpccred(sp->so_cred);
  123. }
  124. out:
  125. spin_unlock(&clp->cl_lock);
  126. return cred;
  127. }
  128. static void nfs_alloc_unique_id(struct rb_root *root, struct nfs_unique_id *new,
  129. __u64 minval, int maxbits)
  130. {
  131. struct rb_node **p, *parent;
  132. struct nfs_unique_id *pos;
  133. __u64 mask = ~0ULL;
  134. if (maxbits < 64)
  135. mask = (1ULL << maxbits) - 1ULL;
  136. /* Ensure distribution is more or less flat */
  137. get_random_bytes(&new->id, sizeof(new->id));
  138. new->id &= mask;
  139. if (new->id < minval)
  140. new->id += minval;
  141. retry:
  142. p = &root->rb_node;
  143. parent = NULL;
  144. while (*p != NULL) {
  145. parent = *p;
  146. pos = rb_entry(parent, struct nfs_unique_id, rb_node);
  147. if (new->id < pos->id)
  148. p = &(*p)->rb_left;
  149. else if (new->id > pos->id)
  150. p = &(*p)->rb_right;
  151. else
  152. goto id_exists;
  153. }
  154. rb_link_node(&new->rb_node, parent, p);
  155. rb_insert_color(&new->rb_node, root);
  156. return;
  157. id_exists:
  158. for (;;) {
  159. new->id++;
  160. if (new->id < minval || (new->id & mask) != new->id) {
  161. new->id = minval;
  162. break;
  163. }
  164. parent = rb_next(parent);
  165. if (parent == NULL)
  166. break;
  167. pos = rb_entry(parent, struct nfs_unique_id, rb_node);
  168. if (new->id < pos->id)
  169. break;
  170. }
  171. goto retry;
  172. }
  173. static void nfs_free_unique_id(struct rb_root *root, struct nfs_unique_id *id)
  174. {
  175. rb_erase(&id->rb_node, root);
  176. }
  177. static struct nfs4_state_owner *
  178. nfs4_find_state_owner(struct nfs_server *server, struct rpc_cred *cred)
  179. {
  180. struct nfs_client *clp = server->nfs_client;
  181. struct rb_node **p = &clp->cl_state_owners.rb_node,
  182. *parent = NULL;
  183. struct nfs4_state_owner *sp, *res = NULL;
  184. while (*p != NULL) {
  185. parent = *p;
  186. sp = rb_entry(parent, struct nfs4_state_owner, so_client_node);
  187. if (server < sp->so_server) {
  188. p = &parent->rb_left;
  189. continue;
  190. }
  191. if (server > sp->so_server) {
  192. p = &parent->rb_right;
  193. continue;
  194. }
  195. if (cred < sp->so_cred)
  196. p = &parent->rb_left;
  197. else if (cred > sp->so_cred)
  198. p = &parent->rb_right;
  199. else {
  200. atomic_inc(&sp->so_count);
  201. res = sp;
  202. break;
  203. }
  204. }
  205. return res;
  206. }
  207. static struct nfs4_state_owner *
  208. nfs4_insert_state_owner(struct nfs_client *clp, struct nfs4_state_owner *new)
  209. {
  210. struct rb_node **p = &clp->cl_state_owners.rb_node,
  211. *parent = NULL;
  212. struct nfs4_state_owner *sp;
  213. while (*p != NULL) {
  214. parent = *p;
  215. sp = rb_entry(parent, struct nfs4_state_owner, so_client_node);
  216. if (new->so_server < sp->so_server) {
  217. p = &parent->rb_left;
  218. continue;
  219. }
  220. if (new->so_server > sp->so_server) {
  221. p = &parent->rb_right;
  222. continue;
  223. }
  224. if (new->so_cred < sp->so_cred)
  225. p = &parent->rb_left;
  226. else if (new->so_cred > sp->so_cred)
  227. p = &parent->rb_right;
  228. else {
  229. atomic_inc(&sp->so_count);
  230. return sp;
  231. }
  232. }
  233. nfs_alloc_unique_id(&clp->cl_openowner_id, &new->so_owner_id, 1, 64);
  234. rb_link_node(&new->so_client_node, parent, p);
  235. rb_insert_color(&new->so_client_node, &clp->cl_state_owners);
  236. return new;
  237. }
  238. static void
  239. nfs4_remove_state_owner(struct nfs_client *clp, struct nfs4_state_owner *sp)
  240. {
  241. if (!RB_EMPTY_NODE(&sp->so_client_node))
  242. rb_erase(&sp->so_client_node, &clp->cl_state_owners);
  243. nfs_free_unique_id(&clp->cl_openowner_id, &sp->so_owner_id);
  244. }
  245. /*
  246. * nfs4_alloc_state_owner(): this is called on the OPEN or CREATE path to
  247. * create a new state_owner.
  248. *
  249. */
  250. static struct nfs4_state_owner *
  251. nfs4_alloc_state_owner(void)
  252. {
  253. struct nfs4_state_owner *sp;
  254. sp = kzalloc(sizeof(*sp),GFP_KERNEL);
  255. if (!sp)
  256. return NULL;
  257. spin_lock_init(&sp->so_lock);
  258. INIT_LIST_HEAD(&sp->so_states);
  259. INIT_LIST_HEAD(&sp->so_delegations);
  260. rpc_init_wait_queue(&sp->so_sequence.wait, "Seqid_waitqueue");
  261. sp->so_seqid.sequence = &sp->so_sequence;
  262. spin_lock_init(&sp->so_sequence.lock);
  263. INIT_LIST_HEAD(&sp->so_sequence.list);
  264. atomic_set(&sp->so_count, 1);
  265. return sp;
  266. }
  267. static void
  268. nfs4_drop_state_owner(struct nfs4_state_owner *sp)
  269. {
  270. if (!RB_EMPTY_NODE(&sp->so_client_node)) {
  271. struct nfs_client *clp = sp->so_client;
  272. spin_lock(&clp->cl_lock);
  273. rb_erase(&sp->so_client_node, &clp->cl_state_owners);
  274. RB_CLEAR_NODE(&sp->so_client_node);
  275. spin_unlock(&clp->cl_lock);
  276. }
  277. }
  278. struct nfs4_state_owner *nfs4_get_state_owner(struct nfs_server *server, struct rpc_cred *cred)
  279. {
  280. struct nfs_client *clp = server->nfs_client;
  281. struct nfs4_state_owner *sp, *new;
  282. spin_lock(&clp->cl_lock);
  283. sp = nfs4_find_state_owner(server, cred);
  284. spin_unlock(&clp->cl_lock);
  285. if (sp != NULL)
  286. return sp;
  287. new = nfs4_alloc_state_owner();
  288. if (new == NULL)
  289. return NULL;
  290. new->so_client = clp;
  291. new->so_server = server;
  292. new->so_cred = cred;
  293. spin_lock(&clp->cl_lock);
  294. sp = nfs4_insert_state_owner(clp, new);
  295. spin_unlock(&clp->cl_lock);
  296. if (sp == new)
  297. get_rpccred(cred);
  298. else {
  299. rpc_destroy_wait_queue(&new->so_sequence.wait);
  300. kfree(new);
  301. }
  302. return sp;
  303. }
  304. void nfs4_put_state_owner(struct nfs4_state_owner *sp)
  305. {
  306. struct nfs_client *clp = sp->so_client;
  307. struct rpc_cred *cred = sp->so_cred;
  308. if (!atomic_dec_and_lock(&sp->so_count, &clp->cl_lock))
  309. return;
  310. nfs4_remove_state_owner(clp, sp);
  311. spin_unlock(&clp->cl_lock);
  312. rpc_destroy_wait_queue(&sp->so_sequence.wait);
  313. put_rpccred(cred);
  314. kfree(sp);
  315. }
  316. static struct nfs4_state *
  317. nfs4_alloc_open_state(void)
  318. {
  319. struct nfs4_state *state;
  320. state = kzalloc(sizeof(*state), GFP_KERNEL);
  321. if (!state)
  322. return NULL;
  323. atomic_set(&state->count, 1);
  324. INIT_LIST_HEAD(&state->lock_states);
  325. spin_lock_init(&state->state_lock);
  326. seqlock_init(&state->seqlock);
  327. return state;
  328. }
  329. void
  330. nfs4_state_set_mode_locked(struct nfs4_state *state, fmode_t fmode)
  331. {
  332. if (state->state == fmode)
  333. return;
  334. /* NB! List reordering - see the reclaim code for why. */
  335. if ((fmode & FMODE_WRITE) != (state->state & FMODE_WRITE)) {
  336. if (fmode & FMODE_WRITE)
  337. list_move(&state->open_states, &state->owner->so_states);
  338. else
  339. list_move_tail(&state->open_states, &state->owner->so_states);
  340. }
  341. state->state = fmode;
  342. }
  343. static struct nfs4_state *
  344. __nfs4_find_state_byowner(struct inode *inode, struct nfs4_state_owner *owner)
  345. {
  346. struct nfs_inode *nfsi = NFS_I(inode);
  347. struct nfs4_state *state;
  348. list_for_each_entry(state, &nfsi->open_states, inode_states) {
  349. if (state->owner != owner)
  350. continue;
  351. if (atomic_inc_not_zero(&state->count))
  352. return state;
  353. }
  354. return NULL;
  355. }
  356. static void
  357. nfs4_free_open_state(struct nfs4_state *state)
  358. {
  359. kfree(state);
  360. }
  361. struct nfs4_state *
  362. nfs4_get_open_state(struct inode *inode, struct nfs4_state_owner *owner)
  363. {
  364. struct nfs4_state *state, *new;
  365. struct nfs_inode *nfsi = NFS_I(inode);
  366. spin_lock(&inode->i_lock);
  367. state = __nfs4_find_state_byowner(inode, owner);
  368. spin_unlock(&inode->i_lock);
  369. if (state)
  370. goto out;
  371. new = nfs4_alloc_open_state();
  372. spin_lock(&owner->so_lock);
  373. spin_lock(&inode->i_lock);
  374. state = __nfs4_find_state_byowner(inode, owner);
  375. if (state == NULL && new != NULL) {
  376. state = new;
  377. state->owner = owner;
  378. atomic_inc(&owner->so_count);
  379. list_add(&state->inode_states, &nfsi->open_states);
  380. state->inode = igrab(inode);
  381. spin_unlock(&inode->i_lock);
  382. /* Note: The reclaim code dictates that we add stateless
  383. * and read-only stateids to the end of the list */
  384. list_add_tail(&state->open_states, &owner->so_states);
  385. spin_unlock(&owner->so_lock);
  386. } else {
  387. spin_unlock(&inode->i_lock);
  388. spin_unlock(&owner->so_lock);
  389. if (new)
  390. nfs4_free_open_state(new);
  391. }
  392. out:
  393. return state;
  394. }
  395. void nfs4_put_open_state(struct nfs4_state *state)
  396. {
  397. struct inode *inode = state->inode;
  398. struct nfs4_state_owner *owner = state->owner;
  399. if (!atomic_dec_and_lock(&state->count, &owner->so_lock))
  400. return;
  401. spin_lock(&inode->i_lock);
  402. list_del(&state->inode_states);
  403. list_del(&state->open_states);
  404. spin_unlock(&inode->i_lock);
  405. spin_unlock(&owner->so_lock);
  406. iput(inode);
  407. nfs4_free_open_state(state);
  408. nfs4_put_state_owner(owner);
  409. }
  410. /*
  411. * Close the current file.
  412. */
  413. static void __nfs4_close(struct path *path, struct nfs4_state *state, fmode_t fmode, int wait)
  414. {
  415. struct nfs4_state_owner *owner = state->owner;
  416. int call_close = 0;
  417. fmode_t newstate;
  418. atomic_inc(&owner->so_count);
  419. /* Protect against nfs4_find_state() */
  420. spin_lock(&owner->so_lock);
  421. switch (fmode & (FMODE_READ | FMODE_WRITE)) {
  422. case FMODE_READ:
  423. state->n_rdonly--;
  424. break;
  425. case FMODE_WRITE:
  426. state->n_wronly--;
  427. break;
  428. case FMODE_READ|FMODE_WRITE:
  429. state->n_rdwr--;
  430. }
  431. newstate = FMODE_READ|FMODE_WRITE;
  432. if (state->n_rdwr == 0) {
  433. if (state->n_rdonly == 0) {
  434. newstate &= ~FMODE_READ;
  435. call_close |= test_bit(NFS_O_RDONLY_STATE, &state->flags);
  436. call_close |= test_bit(NFS_O_RDWR_STATE, &state->flags);
  437. }
  438. if (state->n_wronly == 0) {
  439. newstate &= ~FMODE_WRITE;
  440. call_close |= test_bit(NFS_O_WRONLY_STATE, &state->flags);
  441. call_close |= test_bit(NFS_O_RDWR_STATE, &state->flags);
  442. }
  443. if (newstate == 0)
  444. clear_bit(NFS_DELEGATED_STATE, &state->flags);
  445. }
  446. nfs4_state_set_mode_locked(state, newstate);
  447. spin_unlock(&owner->so_lock);
  448. if (!call_close) {
  449. nfs4_put_open_state(state);
  450. nfs4_put_state_owner(owner);
  451. } else
  452. nfs4_do_close(path, state, wait);
  453. }
  454. void nfs4_close_state(struct path *path, struct nfs4_state *state, fmode_t fmode)
  455. {
  456. __nfs4_close(path, state, fmode, 0);
  457. }
  458. void nfs4_close_sync(struct path *path, struct nfs4_state *state, fmode_t fmode)
  459. {
  460. __nfs4_close(path, state, fmode, 1);
  461. }
  462. /*
  463. * Search the state->lock_states for an existing lock_owner
  464. * that is compatible with current->files
  465. */
  466. static struct nfs4_lock_state *
  467. __nfs4_find_lock_state(struct nfs4_state *state, fl_owner_t fl_owner)
  468. {
  469. struct nfs4_lock_state *pos;
  470. list_for_each_entry(pos, &state->lock_states, ls_locks) {
  471. if (pos->ls_owner != fl_owner)
  472. continue;
  473. atomic_inc(&pos->ls_count);
  474. return pos;
  475. }
  476. return NULL;
  477. }
  478. /*
  479. * Return a compatible lock_state. If no initialized lock_state structure
  480. * exists, return an uninitialized one.
  481. *
  482. */
  483. static struct nfs4_lock_state *nfs4_alloc_lock_state(struct nfs4_state *state, fl_owner_t fl_owner)
  484. {
  485. struct nfs4_lock_state *lsp;
  486. struct nfs_client *clp = state->owner->so_client;
  487. lsp = kzalloc(sizeof(*lsp), GFP_KERNEL);
  488. if (lsp == NULL)
  489. return NULL;
  490. rpc_init_wait_queue(&lsp->ls_sequence.wait, "lock_seqid_waitqueue");
  491. spin_lock_init(&lsp->ls_sequence.lock);
  492. INIT_LIST_HEAD(&lsp->ls_sequence.list);
  493. lsp->ls_seqid.sequence = &lsp->ls_sequence;
  494. atomic_set(&lsp->ls_count, 1);
  495. lsp->ls_owner = fl_owner;
  496. spin_lock(&clp->cl_lock);
  497. nfs_alloc_unique_id(&clp->cl_lockowner_id, &lsp->ls_id, 1, 64);
  498. spin_unlock(&clp->cl_lock);
  499. INIT_LIST_HEAD(&lsp->ls_locks);
  500. return lsp;
  501. }
  502. static void nfs4_free_lock_state(struct nfs4_lock_state *lsp)
  503. {
  504. struct nfs_client *clp = lsp->ls_state->owner->so_client;
  505. spin_lock(&clp->cl_lock);
  506. nfs_free_unique_id(&clp->cl_lockowner_id, &lsp->ls_id);
  507. spin_unlock(&clp->cl_lock);
  508. rpc_destroy_wait_queue(&lsp->ls_sequence.wait);
  509. kfree(lsp);
  510. }
  511. /*
  512. * Return a compatible lock_state. If no initialized lock_state structure
  513. * exists, return an uninitialized one.
  514. *
  515. */
  516. static struct nfs4_lock_state *nfs4_get_lock_state(struct nfs4_state *state, fl_owner_t owner)
  517. {
  518. struct nfs4_lock_state *lsp, *new = NULL;
  519. for(;;) {
  520. spin_lock(&state->state_lock);
  521. lsp = __nfs4_find_lock_state(state, owner);
  522. if (lsp != NULL)
  523. break;
  524. if (new != NULL) {
  525. new->ls_state = state;
  526. list_add(&new->ls_locks, &state->lock_states);
  527. set_bit(LK_STATE_IN_USE, &state->flags);
  528. lsp = new;
  529. new = NULL;
  530. break;
  531. }
  532. spin_unlock(&state->state_lock);
  533. new = nfs4_alloc_lock_state(state, owner);
  534. if (new == NULL)
  535. return NULL;
  536. }
  537. spin_unlock(&state->state_lock);
  538. if (new != NULL)
  539. nfs4_free_lock_state(new);
  540. return lsp;
  541. }
  542. /*
  543. * Release reference to lock_state, and free it if we see that
  544. * it is no longer in use
  545. */
  546. void nfs4_put_lock_state(struct nfs4_lock_state *lsp)
  547. {
  548. struct nfs4_state *state;
  549. if (lsp == NULL)
  550. return;
  551. state = lsp->ls_state;
  552. if (!atomic_dec_and_lock(&lsp->ls_count, &state->state_lock))
  553. return;
  554. list_del(&lsp->ls_locks);
  555. if (list_empty(&state->lock_states))
  556. clear_bit(LK_STATE_IN_USE, &state->flags);
  557. spin_unlock(&state->state_lock);
  558. nfs4_free_lock_state(lsp);
  559. }
  560. static void nfs4_fl_copy_lock(struct file_lock *dst, struct file_lock *src)
  561. {
  562. struct nfs4_lock_state *lsp = src->fl_u.nfs4_fl.owner;
  563. dst->fl_u.nfs4_fl.owner = lsp;
  564. atomic_inc(&lsp->ls_count);
  565. }
  566. static void nfs4_fl_release_lock(struct file_lock *fl)
  567. {
  568. nfs4_put_lock_state(fl->fl_u.nfs4_fl.owner);
  569. }
  570. static struct file_lock_operations nfs4_fl_lock_ops = {
  571. .fl_copy_lock = nfs4_fl_copy_lock,
  572. .fl_release_private = nfs4_fl_release_lock,
  573. };
  574. int nfs4_set_lock_state(struct nfs4_state *state, struct file_lock *fl)
  575. {
  576. struct nfs4_lock_state *lsp;
  577. if (fl->fl_ops != NULL)
  578. return 0;
  579. lsp = nfs4_get_lock_state(state, fl->fl_owner);
  580. if (lsp == NULL)
  581. return -ENOMEM;
  582. fl->fl_u.nfs4_fl.owner = lsp;
  583. fl->fl_ops = &nfs4_fl_lock_ops;
  584. return 0;
  585. }
  586. /*
  587. * Byte-range lock aware utility to initialize the stateid of read/write
  588. * requests.
  589. */
  590. void nfs4_copy_stateid(nfs4_stateid *dst, struct nfs4_state *state, fl_owner_t fl_owner)
  591. {
  592. struct nfs4_lock_state *lsp;
  593. int seq;
  594. do {
  595. seq = read_seqbegin(&state->seqlock);
  596. memcpy(dst, &state->stateid, sizeof(*dst));
  597. } while (read_seqretry(&state->seqlock, seq));
  598. if (test_bit(LK_STATE_IN_USE, &state->flags) == 0)
  599. return;
  600. spin_lock(&state->state_lock);
  601. lsp = __nfs4_find_lock_state(state, fl_owner);
  602. if (lsp != NULL && (lsp->ls_flags & NFS_LOCK_INITIALIZED) != 0)
  603. memcpy(dst, &lsp->ls_stateid, sizeof(*dst));
  604. spin_unlock(&state->state_lock);
  605. nfs4_put_lock_state(lsp);
  606. }
  607. struct nfs_seqid *nfs_alloc_seqid(struct nfs_seqid_counter *counter)
  608. {
  609. struct nfs_seqid *new;
  610. new = kmalloc(sizeof(*new), GFP_KERNEL);
  611. if (new != NULL) {
  612. new->sequence = counter;
  613. INIT_LIST_HEAD(&new->list);
  614. }
  615. return new;
  616. }
  617. void nfs_free_seqid(struct nfs_seqid *seqid)
  618. {
  619. if (!list_empty(&seqid->list)) {
  620. struct rpc_sequence *sequence = seqid->sequence->sequence;
  621. spin_lock(&sequence->lock);
  622. list_del(&seqid->list);
  623. spin_unlock(&sequence->lock);
  624. rpc_wake_up(&sequence->wait);
  625. }
  626. kfree(seqid);
  627. }
  628. /*
  629. * Increment the seqid if the OPEN/OPEN_DOWNGRADE/CLOSE succeeded, or
  630. * failed with a seqid incrementing error -
  631. * see comments nfs_fs.h:seqid_mutating_error()
  632. */
  633. static void nfs_increment_seqid(int status, struct nfs_seqid *seqid)
  634. {
  635. BUG_ON(list_first_entry(&seqid->sequence->sequence->list, struct nfs_seqid, list) != seqid);
  636. switch (status) {
  637. case 0:
  638. break;
  639. case -NFS4ERR_BAD_SEQID:
  640. if (seqid->sequence->flags & NFS_SEQID_CONFIRMED)
  641. return;
  642. printk(KERN_WARNING "NFS: v4 server returned a bad"
  643. " sequence-id error on an"
  644. " unconfirmed sequence %p!\n",
  645. seqid->sequence);
  646. case -NFS4ERR_STALE_CLIENTID:
  647. case -NFS4ERR_STALE_STATEID:
  648. case -NFS4ERR_BAD_STATEID:
  649. case -NFS4ERR_BADXDR:
  650. case -NFS4ERR_RESOURCE:
  651. case -NFS4ERR_NOFILEHANDLE:
  652. /* Non-seqid mutating errors */
  653. return;
  654. };
  655. /*
  656. * Note: no locking needed as we are guaranteed to be first
  657. * on the sequence list
  658. */
  659. seqid->sequence->counter++;
  660. }
  661. void nfs_increment_open_seqid(int status, struct nfs_seqid *seqid)
  662. {
  663. if (status == -NFS4ERR_BAD_SEQID) {
  664. struct nfs4_state_owner *sp = container_of(seqid->sequence,
  665. struct nfs4_state_owner, so_seqid);
  666. nfs4_drop_state_owner(sp);
  667. }
  668. nfs_increment_seqid(status, seqid);
  669. }
  670. /*
  671. * Increment the seqid if the LOCK/LOCKU succeeded, or
  672. * failed with a seqid incrementing error -
  673. * see comments nfs_fs.h:seqid_mutating_error()
  674. */
  675. void nfs_increment_lock_seqid(int status, struct nfs_seqid *seqid)
  676. {
  677. nfs_increment_seqid(status, seqid);
  678. }
  679. int nfs_wait_on_sequence(struct nfs_seqid *seqid, struct rpc_task *task)
  680. {
  681. struct rpc_sequence *sequence = seqid->sequence->sequence;
  682. int status = 0;
  683. spin_lock(&sequence->lock);
  684. if (list_empty(&seqid->list))
  685. list_add_tail(&seqid->list, &sequence->list);
  686. if (list_first_entry(&sequence->list, struct nfs_seqid, list) == seqid)
  687. goto unlock;
  688. rpc_sleep_on(&sequence->wait, task, NULL);
  689. status = -EAGAIN;
  690. unlock:
  691. spin_unlock(&sequence->lock);
  692. return status;
  693. }
  694. static int nfs4_run_state_manager(void *);
  695. static void nfs4_clear_state_manager_bit(struct nfs_client *clp)
  696. {
  697. smp_mb__before_clear_bit();
  698. clear_bit(NFS4CLNT_MANAGER_RUNNING, &clp->cl_state);
  699. smp_mb__after_clear_bit();
  700. wake_up_bit(&clp->cl_state, NFS4CLNT_MANAGER_RUNNING);
  701. rpc_wake_up(&clp->cl_rpcwaitq);
  702. }
  703. /*
  704. * Schedule the nfs_client asynchronous state management routine
  705. */
  706. void nfs4_schedule_state_manager(struct nfs_client *clp)
  707. {
  708. struct task_struct *task;
  709. if (test_and_set_bit(NFS4CLNT_MANAGER_RUNNING, &clp->cl_state) != 0)
  710. return;
  711. __module_get(THIS_MODULE);
  712. atomic_inc(&clp->cl_count);
  713. task = kthread_run(nfs4_run_state_manager, clp, "%s-manager",
  714. rpc_peeraddr2str(clp->cl_rpcclient,
  715. RPC_DISPLAY_ADDR));
  716. if (!IS_ERR(task))
  717. return;
  718. nfs4_clear_state_manager_bit(clp);
  719. nfs_put_client(clp);
  720. module_put(THIS_MODULE);
  721. }
  722. /*
  723. * Schedule a state recovery attempt
  724. */
  725. void nfs4_schedule_state_recovery(struct nfs_client *clp)
  726. {
  727. if (!clp)
  728. return;
  729. if (!test_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state))
  730. set_bit(NFS4CLNT_CHECK_LEASE, &clp->cl_state);
  731. nfs4_schedule_state_manager(clp);
  732. }
  733. static int nfs4_state_mark_reclaim_reboot(struct nfs_client *clp, struct nfs4_state *state)
  734. {
  735. set_bit(NFS_STATE_RECLAIM_REBOOT, &state->flags);
  736. /* Don't recover state that expired before the reboot */
  737. if (test_bit(NFS_STATE_RECLAIM_NOGRACE, &state->flags)) {
  738. clear_bit(NFS_STATE_RECLAIM_REBOOT, &state->flags);
  739. return 0;
  740. }
  741. set_bit(NFS_OWNER_RECLAIM_REBOOT, &state->owner->so_flags);
  742. set_bit(NFS4CLNT_RECLAIM_REBOOT, &clp->cl_state);
  743. return 1;
  744. }
  745. int nfs4_state_mark_reclaim_nograce(struct nfs_client *clp, struct nfs4_state *state)
  746. {
  747. set_bit(NFS_STATE_RECLAIM_NOGRACE, &state->flags);
  748. clear_bit(NFS_STATE_RECLAIM_REBOOT, &state->flags);
  749. set_bit(NFS_OWNER_RECLAIM_NOGRACE, &state->owner->so_flags);
  750. set_bit(NFS4CLNT_RECLAIM_NOGRACE, &clp->cl_state);
  751. return 1;
  752. }
  753. static int nfs4_reclaim_locks(struct nfs4_state *state, const struct nfs4_state_recovery_ops *ops)
  754. {
  755. struct inode *inode = state->inode;
  756. struct nfs_inode *nfsi = NFS_I(inode);
  757. struct file_lock *fl;
  758. int status = 0;
  759. down_write(&nfsi->rwsem);
  760. for (fl = inode->i_flock; fl != NULL; fl = fl->fl_next) {
  761. if (!(fl->fl_flags & (FL_POSIX|FL_FLOCK)))
  762. continue;
  763. if (nfs_file_open_context(fl->fl_file)->state != state)
  764. continue;
  765. status = ops->recover_lock(state, fl);
  766. if (status >= 0)
  767. continue;
  768. switch (status) {
  769. default:
  770. printk(KERN_ERR "%s: unhandled error %d. Zeroing state\n",
  771. __func__, status);
  772. case -NFS4ERR_EXPIRED:
  773. case -NFS4ERR_NO_GRACE:
  774. case -NFS4ERR_RECLAIM_BAD:
  775. case -NFS4ERR_RECLAIM_CONFLICT:
  776. /* kill_proc(fl->fl_pid, SIGLOST, 1); */
  777. break;
  778. case -NFS4ERR_STALE_CLIENTID:
  779. goto out_err;
  780. }
  781. }
  782. up_write(&nfsi->rwsem);
  783. return 0;
  784. out_err:
  785. up_write(&nfsi->rwsem);
  786. return status;
  787. }
  788. static int nfs4_reclaim_open_state(struct nfs4_state_owner *sp, const struct nfs4_state_recovery_ops *ops)
  789. {
  790. struct nfs4_state *state;
  791. struct nfs4_lock_state *lock;
  792. int status = 0;
  793. /* Note: we rely on the sp->so_states list being ordered
  794. * so that we always reclaim open(O_RDWR) and/or open(O_WRITE)
  795. * states first.
  796. * This is needed to ensure that the server won't give us any
  797. * read delegations that we have to return if, say, we are
  798. * recovering after a network partition or a reboot from a
  799. * server that doesn't support a grace period.
  800. */
  801. restart:
  802. spin_lock(&sp->so_lock);
  803. list_for_each_entry(state, &sp->so_states, open_states) {
  804. if (!test_and_clear_bit(ops->state_flag_bit, &state->flags))
  805. continue;
  806. if (state->state == 0)
  807. continue;
  808. atomic_inc(&state->count);
  809. spin_unlock(&sp->so_lock);
  810. status = ops->recover_open(sp, state);
  811. if (status >= 0) {
  812. status = nfs4_reclaim_locks(state, ops);
  813. if (status >= 0) {
  814. list_for_each_entry(lock, &state->lock_states, ls_locks) {
  815. if (!(lock->ls_flags & NFS_LOCK_INITIALIZED))
  816. printk("%s: Lock reclaim failed!\n",
  817. __func__);
  818. }
  819. nfs4_put_open_state(state);
  820. goto restart;
  821. }
  822. }
  823. switch (status) {
  824. default:
  825. printk(KERN_ERR "%s: unhandled error %d. Zeroing state\n",
  826. __func__, status);
  827. case -ENOENT:
  828. case -ESTALE:
  829. /*
  830. * Open state on this file cannot be recovered
  831. * All we can do is revert to using the zero stateid.
  832. */
  833. memset(state->stateid.data, 0,
  834. sizeof(state->stateid.data));
  835. /* Mark the file as being 'closed' */
  836. state->state = 0;
  837. break;
  838. case -NFS4ERR_RECLAIM_BAD:
  839. case -NFS4ERR_RECLAIM_CONFLICT:
  840. nfs4_state_mark_reclaim_nograce(sp->so_client, state);
  841. break;
  842. case -NFS4ERR_EXPIRED:
  843. case -NFS4ERR_NO_GRACE:
  844. nfs4_state_mark_reclaim_nograce(sp->so_client, state);
  845. case -NFS4ERR_STALE_CLIENTID:
  846. goto out_err;
  847. }
  848. nfs4_put_open_state(state);
  849. goto restart;
  850. }
  851. spin_unlock(&sp->so_lock);
  852. return 0;
  853. out_err:
  854. nfs4_put_open_state(state);
  855. return status;
  856. }
  857. static void nfs4_clear_open_state(struct nfs4_state *state)
  858. {
  859. struct nfs4_lock_state *lock;
  860. clear_bit(NFS_DELEGATED_STATE, &state->flags);
  861. clear_bit(NFS_O_RDONLY_STATE, &state->flags);
  862. clear_bit(NFS_O_WRONLY_STATE, &state->flags);
  863. clear_bit(NFS_O_RDWR_STATE, &state->flags);
  864. list_for_each_entry(lock, &state->lock_states, ls_locks) {
  865. lock->ls_seqid.flags = 0;
  866. lock->ls_flags &= ~NFS_LOCK_INITIALIZED;
  867. }
  868. }
  869. static void nfs4_state_mark_reclaim_helper(struct nfs_client *clp, int (*mark_reclaim)(struct nfs_client *clp, struct nfs4_state *state))
  870. {
  871. struct nfs4_state_owner *sp;
  872. struct rb_node *pos;
  873. struct nfs4_state *state;
  874. /* Reset all sequence ids to zero */
  875. for (pos = rb_first(&clp->cl_state_owners); pos != NULL; pos = rb_next(pos)) {
  876. sp = rb_entry(pos, struct nfs4_state_owner, so_client_node);
  877. sp->so_seqid.flags = 0;
  878. spin_lock(&sp->so_lock);
  879. list_for_each_entry(state, &sp->so_states, open_states) {
  880. if (mark_reclaim(clp, state))
  881. nfs4_clear_open_state(state);
  882. }
  883. spin_unlock(&sp->so_lock);
  884. }
  885. }
  886. static void nfs4_state_start_reclaim_reboot(struct nfs_client *clp)
  887. {
  888. /* Mark all delegations for reclaim */
  889. nfs_delegation_mark_reclaim(clp);
  890. nfs4_state_mark_reclaim_helper(clp, nfs4_state_mark_reclaim_reboot);
  891. }
  892. static void nfs4_state_end_reclaim_reboot(struct nfs_client *clp)
  893. {
  894. struct nfs4_state_owner *sp;
  895. struct rb_node *pos;
  896. struct nfs4_state *state;
  897. if (!test_and_clear_bit(NFS4CLNT_RECLAIM_REBOOT, &clp->cl_state))
  898. return;
  899. for (pos = rb_first(&clp->cl_state_owners); pos != NULL; pos = rb_next(pos)) {
  900. sp = rb_entry(pos, struct nfs4_state_owner, so_client_node);
  901. spin_lock(&sp->so_lock);
  902. list_for_each_entry(state, &sp->so_states, open_states) {
  903. if (!test_and_clear_bit(NFS_STATE_RECLAIM_REBOOT, &state->flags))
  904. continue;
  905. nfs4_state_mark_reclaim_nograce(clp, state);
  906. }
  907. spin_unlock(&sp->so_lock);
  908. }
  909. nfs_delegation_reap_unclaimed(clp);
  910. }
  911. static void nfs_delegation_clear_all(struct nfs_client *clp)
  912. {
  913. nfs_delegation_mark_reclaim(clp);
  914. nfs_delegation_reap_unclaimed(clp);
  915. }
  916. static void nfs4_state_start_reclaim_nograce(struct nfs_client *clp)
  917. {
  918. nfs_delegation_clear_all(clp);
  919. nfs4_state_mark_reclaim_helper(clp, nfs4_state_mark_reclaim_nograce);
  920. }
  921. static void nfs4_state_end_reclaim_nograce(struct nfs_client *clp)
  922. {
  923. clear_bit(NFS4CLNT_RECLAIM_NOGRACE, &clp->cl_state);
  924. }
  925. static void nfs4_recovery_handle_error(struct nfs_client *clp, int error)
  926. {
  927. switch (error) {
  928. case -NFS4ERR_CB_PATH_DOWN:
  929. nfs_handle_cb_pathdown(clp);
  930. break;
  931. case -NFS4ERR_STALE_CLIENTID:
  932. case -NFS4ERR_LEASE_MOVED:
  933. set_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state);
  934. nfs4_state_start_reclaim_reboot(clp);
  935. break;
  936. case -NFS4ERR_EXPIRED:
  937. set_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state);
  938. nfs4_state_start_reclaim_nograce(clp);
  939. }
  940. }
  941. static int nfs4_do_reclaim(struct nfs_client *clp, const struct nfs4_state_recovery_ops *ops)
  942. {
  943. struct rb_node *pos;
  944. int status = 0;
  945. restart:
  946. spin_lock(&clp->cl_lock);
  947. for (pos = rb_first(&clp->cl_state_owners); pos != NULL; pos = rb_next(pos)) {
  948. struct nfs4_state_owner *sp = rb_entry(pos, struct nfs4_state_owner, so_client_node);
  949. if (!test_and_clear_bit(ops->owner_flag_bit, &sp->so_flags))
  950. continue;
  951. atomic_inc(&sp->so_count);
  952. spin_unlock(&clp->cl_lock);
  953. status = nfs4_reclaim_open_state(sp, ops);
  954. if (status < 0) {
  955. set_bit(ops->owner_flag_bit, &sp->so_flags);
  956. nfs4_put_state_owner(sp);
  957. nfs4_recovery_handle_error(clp, status);
  958. return status;
  959. }
  960. nfs4_put_state_owner(sp);
  961. goto restart;
  962. }
  963. spin_unlock(&clp->cl_lock);
  964. return status;
  965. }
  966. static int nfs4_check_lease(struct nfs_client *clp)
  967. {
  968. struct rpc_cred *cred;
  969. int status = -NFS4ERR_EXPIRED;
  970. /* Is the client already known to have an expired lease? */
  971. if (test_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state))
  972. return 0;
  973. cred = nfs4_get_renew_cred(clp);
  974. if (cred == NULL) {
  975. cred = nfs4_get_setclientid_cred(clp);
  976. if (cred == NULL)
  977. goto out;
  978. }
  979. status = nfs4_proc_renew(clp, cred);
  980. put_rpccred(cred);
  981. out:
  982. nfs4_recovery_handle_error(clp, status);
  983. return status;
  984. }
  985. static int nfs4_reclaim_lease(struct nfs_client *clp)
  986. {
  987. struct rpc_cred *cred;
  988. int status = -ENOENT;
  989. cred = nfs4_get_setclientid_cred(clp);
  990. if (cred != NULL) {
  991. status = nfs4_init_client(clp, cred);
  992. put_rpccred(cred);
  993. /* Handle case where the user hasn't set up machine creds */
  994. if (status == -EACCES && cred == clp->cl_machine_cred) {
  995. nfs4_clear_machine_cred(clp);
  996. status = -EAGAIN;
  997. }
  998. }
  999. return status;
  1000. }
  1001. static void nfs4_state_manager(struct nfs_client *clp)
  1002. {
  1003. int status = 0;
  1004. /* Ensure exclusive access to NFSv4 state */
  1005. for(;;) {
  1006. if (test_and_clear_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state)) {
  1007. /* We're going to have to re-establish a clientid */
  1008. status = nfs4_reclaim_lease(clp);
  1009. if (status) {
  1010. set_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state);
  1011. if (status == -EAGAIN)
  1012. continue;
  1013. goto out_error;
  1014. }
  1015. clear_bit(NFS4CLNT_CHECK_LEASE, &clp->cl_state);
  1016. }
  1017. if (test_and_clear_bit(NFS4CLNT_CHECK_LEASE, &clp->cl_state)) {
  1018. status = nfs4_check_lease(clp);
  1019. if (status != 0)
  1020. continue;
  1021. }
  1022. /* First recover reboot state... */
  1023. if (test_and_clear_bit(NFS4CLNT_RECLAIM_REBOOT, &clp->cl_state)) {
  1024. status = nfs4_do_reclaim(clp, &nfs4_reboot_recovery_ops);
  1025. if (status == -NFS4ERR_STALE_CLIENTID)
  1026. continue;
  1027. nfs4_state_end_reclaim_reboot(clp);
  1028. continue;
  1029. }
  1030. /* Now recover expired state... */
  1031. if (test_and_clear_bit(NFS4CLNT_RECLAIM_NOGRACE, &clp->cl_state)) {
  1032. status = nfs4_do_reclaim(clp, &nfs4_nograce_recovery_ops);
  1033. if (status < 0) {
  1034. set_bit(NFS4CLNT_RECLAIM_NOGRACE, &clp->cl_state);
  1035. if (status == -NFS4ERR_STALE_CLIENTID)
  1036. continue;
  1037. if (status == -NFS4ERR_EXPIRED)
  1038. continue;
  1039. goto out_error;
  1040. } else
  1041. nfs4_state_end_reclaim_nograce(clp);
  1042. continue;
  1043. }
  1044. if (test_and_clear_bit(NFS4CLNT_DELEGRETURN, &clp->cl_state)) {
  1045. nfs_client_return_marked_delegations(clp);
  1046. continue;
  1047. }
  1048. nfs4_clear_state_manager_bit(clp);
  1049. /* Did we race with an attempt to give us more work? */
  1050. if (clp->cl_state == 0)
  1051. break;
  1052. if (test_and_set_bit(NFS4CLNT_MANAGER_RUNNING, &clp->cl_state) != 0)
  1053. break;
  1054. }
  1055. return;
  1056. out_error:
  1057. printk(KERN_WARNING "Error: state manager failed on NFSv4 server %s"
  1058. " with error %d\n", clp->cl_hostname, -status);
  1059. if (test_bit(NFS4CLNT_RECLAIM_REBOOT, &clp->cl_state))
  1060. nfs4_state_end_reclaim_reboot(clp);
  1061. nfs4_clear_state_manager_bit(clp);
  1062. }
  1063. static int nfs4_run_state_manager(void *ptr)
  1064. {
  1065. struct nfs_client *clp = ptr;
  1066. allow_signal(SIGKILL);
  1067. nfs4_state_manager(clp);
  1068. nfs_put_client(clp);
  1069. module_put_and_exit(0);
  1070. return 0;
  1071. }
  1072. /*
  1073. * Local variables:
  1074. * c-basic-offset: 8
  1075. * End:
  1076. */