nfs4state.c 31 KB

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