.. | .. |
---|
49 | 49 | #include <linux/workqueue.h> |
---|
50 | 50 | #include <linux/bitops.h> |
---|
51 | 51 | #include <linux/jiffies.h> |
---|
| 52 | +#include <linux/sched/mm.h> |
---|
52 | 53 | |
---|
53 | 54 | #include <linux/sunrpc/clnt.h> |
---|
54 | 55 | |
---|
.. | .. |
---|
60 | 61 | #include "nfs4session.h" |
---|
61 | 62 | #include "pnfs.h" |
---|
62 | 63 | #include "netns.h" |
---|
| 64 | +#include "nfs4trace.h" |
---|
63 | 65 | |
---|
64 | 66 | #define NFSDBG_FACILITY NFSDBG_STATE |
---|
65 | 67 | |
---|
66 | 68 | #define OPENOWNER_POOL_SIZE 8 |
---|
| 69 | + |
---|
| 70 | +static void nfs4_state_start_reclaim_reboot(struct nfs_client *clp); |
---|
67 | 71 | |
---|
68 | 72 | const nfs4_stateid zero_stateid = { |
---|
69 | 73 | { .data = { 0 } }, |
---|
.. | .. |
---|
87 | 91 | |
---|
88 | 92 | static DEFINE_MUTEX(nfs_clid_init_mutex); |
---|
89 | 93 | |
---|
90 | | -int nfs4_init_clientid(struct nfs_client *clp, struct rpc_cred *cred) |
---|
| 94 | +static int nfs4_setup_state_renewal(struct nfs_client *clp) |
---|
| 95 | +{ |
---|
| 96 | + int status; |
---|
| 97 | + struct nfs_fsinfo fsinfo; |
---|
| 98 | + |
---|
| 99 | + if (!test_bit(NFS_CS_CHECK_LEASE_TIME, &clp->cl_res_state)) { |
---|
| 100 | + nfs4_schedule_state_renewal(clp); |
---|
| 101 | + return 0; |
---|
| 102 | + } |
---|
| 103 | + |
---|
| 104 | + status = nfs4_proc_get_lease_time(clp, &fsinfo); |
---|
| 105 | + if (status == 0) { |
---|
| 106 | + nfs4_set_lease_period(clp, fsinfo.lease_time * HZ); |
---|
| 107 | + nfs4_schedule_state_renewal(clp); |
---|
| 108 | + } |
---|
| 109 | + |
---|
| 110 | + return status; |
---|
| 111 | +} |
---|
| 112 | + |
---|
| 113 | +int nfs4_init_clientid(struct nfs_client *clp, const struct cred *cred) |
---|
91 | 114 | { |
---|
92 | 115 | struct nfs4_setclientid_res clid = { |
---|
93 | 116 | .clientid = clp->cl_clientid, |
---|
.. | .. |
---|
114 | 137 | if (status != 0) |
---|
115 | 138 | goto out; |
---|
116 | 139 | clear_bit(NFS4CLNT_LEASE_CONFIRM, &clp->cl_state); |
---|
117 | | - nfs4_schedule_state_renewal(clp); |
---|
| 140 | + nfs4_setup_state_renewal(clp); |
---|
118 | 141 | out: |
---|
119 | 142 | return status; |
---|
120 | 143 | } |
---|
.. | .. |
---|
134 | 157 | */ |
---|
135 | 158 | int nfs40_discover_server_trunking(struct nfs_client *clp, |
---|
136 | 159 | struct nfs_client **result, |
---|
137 | | - struct rpc_cred *cred) |
---|
| 160 | + const struct cred *cred) |
---|
138 | 161 | { |
---|
139 | 162 | struct nfs4_setclientid_res clid = { |
---|
140 | 163 | .clientid = clp->cl_clientid, |
---|
.. | .. |
---|
168 | 191 | return status; |
---|
169 | 192 | } |
---|
170 | 193 | |
---|
171 | | -struct rpc_cred *nfs4_get_machine_cred_locked(struct nfs_client *clp) |
---|
| 194 | +const struct cred *nfs4_get_machine_cred(struct nfs_client *clp) |
---|
172 | 195 | { |
---|
173 | | - struct rpc_cred *cred = NULL; |
---|
174 | | - |
---|
175 | | - if (clp->cl_machine_cred != NULL) |
---|
176 | | - cred = get_rpccred(clp->cl_machine_cred); |
---|
177 | | - return cred; |
---|
| 196 | + return get_cred(rpc_machine_cred()); |
---|
178 | 197 | } |
---|
179 | 198 | |
---|
180 | 199 | static void nfs4_root_machine_cred(struct nfs_client *clp) |
---|
181 | 200 | { |
---|
182 | | - struct rpc_cred *cred, *new; |
---|
183 | 201 | |
---|
184 | | - new = rpc_lookup_machine_cred(NULL); |
---|
185 | | - spin_lock(&clp->cl_lock); |
---|
186 | | - cred = clp->cl_machine_cred; |
---|
187 | | - clp->cl_machine_cred = new; |
---|
188 | | - spin_unlock(&clp->cl_lock); |
---|
189 | | - if (cred != NULL) |
---|
190 | | - put_rpccred(cred); |
---|
| 202 | + /* Force root creds instead of machine */ |
---|
| 203 | + clp->cl_principal = NULL; |
---|
| 204 | + clp->cl_rpcclient->cl_principal = NULL; |
---|
191 | 205 | } |
---|
192 | 206 | |
---|
193 | | -static struct rpc_cred * |
---|
| 207 | +static const struct cred * |
---|
194 | 208 | nfs4_get_renew_cred_server_locked(struct nfs_server *server) |
---|
195 | 209 | { |
---|
196 | | - struct rpc_cred *cred = NULL; |
---|
| 210 | + const struct cred *cred = NULL; |
---|
197 | 211 | struct nfs4_state_owner *sp; |
---|
198 | 212 | struct rb_node *pos; |
---|
199 | 213 | |
---|
.. | .. |
---|
203 | 217 | sp = rb_entry(pos, struct nfs4_state_owner, so_server_node); |
---|
204 | 218 | if (list_empty(&sp->so_states)) |
---|
205 | 219 | continue; |
---|
206 | | - cred = get_rpccred(sp->so_cred); |
---|
| 220 | + cred = get_cred(sp->so_cred); |
---|
207 | 221 | break; |
---|
208 | 222 | } |
---|
209 | 223 | return cred; |
---|
210 | 224 | } |
---|
211 | 225 | |
---|
212 | 226 | /** |
---|
213 | | - * nfs4_get_renew_cred_locked - Acquire credential for a renew operation |
---|
| 227 | + * nfs4_get_renew_cred - Acquire credential for a renew operation |
---|
214 | 228 | * @clp: client state handle |
---|
215 | 229 | * |
---|
216 | 230 | * Returns an rpc_cred with reference count bumped, or NULL. |
---|
217 | 231 | * Caller must hold clp->cl_lock. |
---|
218 | 232 | */ |
---|
219 | | -struct rpc_cred *nfs4_get_renew_cred_locked(struct nfs_client *clp) |
---|
| 233 | +const struct cred *nfs4_get_renew_cred(struct nfs_client *clp) |
---|
220 | 234 | { |
---|
221 | | - struct rpc_cred *cred = NULL; |
---|
| 235 | + const struct cred *cred = NULL; |
---|
222 | 236 | struct nfs_server *server; |
---|
223 | 237 | |
---|
224 | 238 | /* Use machine credentials if available */ |
---|
225 | | - cred = nfs4_get_machine_cred_locked(clp); |
---|
| 239 | + cred = nfs4_get_machine_cred(clp); |
---|
226 | 240 | if (cred != NULL) |
---|
227 | 241 | goto out; |
---|
228 | 242 | |
---|
| 243 | + spin_lock(&clp->cl_lock); |
---|
229 | 244 | rcu_read_lock(); |
---|
230 | 245 | list_for_each_entry_rcu(server, &clp->cl_superblocks, client_link) { |
---|
231 | 246 | cred = nfs4_get_renew_cred_server_locked(server); |
---|
.. | .. |
---|
233 | 248 | break; |
---|
234 | 249 | } |
---|
235 | 250 | rcu_read_unlock(); |
---|
| 251 | + spin_unlock(&clp->cl_lock); |
---|
236 | 252 | |
---|
237 | 253 | out: |
---|
238 | 254 | return cred; |
---|
.. | .. |
---|
293 | 309 | |
---|
294 | 310 | #if defined(CONFIG_NFS_V4_1) |
---|
295 | 311 | |
---|
296 | | -static int nfs41_setup_state_renewal(struct nfs_client *clp) |
---|
297 | | -{ |
---|
298 | | - int status; |
---|
299 | | - struct nfs_fsinfo fsinfo; |
---|
300 | | - unsigned long now; |
---|
301 | | - |
---|
302 | | - if (!test_bit(NFS_CS_CHECK_LEASE_TIME, &clp->cl_res_state)) { |
---|
303 | | - nfs4_schedule_state_renewal(clp); |
---|
304 | | - return 0; |
---|
305 | | - } |
---|
306 | | - |
---|
307 | | - now = jiffies; |
---|
308 | | - status = nfs4_proc_get_lease_time(clp, &fsinfo); |
---|
309 | | - if (status == 0) { |
---|
310 | | - nfs4_set_lease_period(clp, fsinfo.lease_time * HZ, now); |
---|
311 | | - nfs4_schedule_state_renewal(clp); |
---|
312 | | - } |
---|
313 | | - |
---|
314 | | - return status; |
---|
315 | | -} |
---|
316 | | - |
---|
317 | 312 | static void nfs41_finish_session_reset(struct nfs_client *clp) |
---|
318 | 313 | { |
---|
319 | 314 | clear_bit(NFS4CLNT_LEASE_CONFIRM, &clp->cl_state); |
---|
320 | 315 | clear_bit(NFS4CLNT_SESSION_RESET, &clp->cl_state); |
---|
321 | 316 | /* create_session negotiated new slot table */ |
---|
322 | 317 | clear_bit(NFS4CLNT_BIND_CONN_TO_SESSION, &clp->cl_state); |
---|
323 | | - nfs41_setup_state_renewal(clp); |
---|
| 318 | + nfs4_setup_state_renewal(clp); |
---|
324 | 319 | } |
---|
325 | 320 | |
---|
326 | | -int nfs41_init_clientid(struct nfs_client *clp, struct rpc_cred *cred) |
---|
| 321 | +int nfs41_init_clientid(struct nfs_client *clp, const struct cred *cred) |
---|
327 | 322 | { |
---|
328 | 323 | int status; |
---|
329 | 324 | |
---|
.. | .. |
---|
337 | 332 | status = nfs4_proc_create_session(clp, cred); |
---|
338 | 333 | if (status != 0) |
---|
339 | 334 | goto out; |
---|
| 335 | + if (!(clp->cl_exchange_flags & EXCHGID4_FLAG_CONFIRMED_R)) |
---|
| 336 | + nfs4_state_start_reclaim_reboot(clp); |
---|
340 | 337 | nfs41_finish_session_reset(clp); |
---|
341 | 338 | nfs_mark_client_ready(clp, NFS_CS_READY); |
---|
342 | 339 | out: |
---|
.. | .. |
---|
358 | 355 | */ |
---|
359 | 356 | int nfs41_discover_server_trunking(struct nfs_client *clp, |
---|
360 | 357 | struct nfs_client **result, |
---|
361 | | - struct rpc_cred *cred) |
---|
| 358 | + const struct cred *cred) |
---|
362 | 359 | { |
---|
363 | 360 | int status; |
---|
364 | 361 | |
---|
.. | .. |
---|
396 | 393 | * nfs4_get_clid_cred - Acquire credential for a setclientid operation |
---|
397 | 394 | * @clp: client state handle |
---|
398 | 395 | * |
---|
399 | | - * Returns an rpc_cred with reference count bumped, or NULL. |
---|
| 396 | + * Returns a cred with reference count bumped, or NULL. |
---|
400 | 397 | */ |
---|
401 | | -struct rpc_cred *nfs4_get_clid_cred(struct nfs_client *clp) |
---|
| 398 | +const struct cred *nfs4_get_clid_cred(struct nfs_client *clp) |
---|
402 | 399 | { |
---|
403 | | - struct rpc_cred *cred; |
---|
| 400 | + const struct cred *cred; |
---|
404 | 401 | |
---|
405 | | - spin_lock(&clp->cl_lock); |
---|
406 | | - cred = nfs4_get_machine_cred_locked(clp); |
---|
407 | | - spin_unlock(&clp->cl_lock); |
---|
| 402 | + cred = nfs4_get_machine_cred(clp); |
---|
408 | 403 | return cred; |
---|
409 | 404 | } |
---|
410 | 405 | |
---|
411 | 406 | static struct nfs4_state_owner * |
---|
412 | | -nfs4_find_state_owner_locked(struct nfs_server *server, struct rpc_cred *cred) |
---|
| 407 | +nfs4_find_state_owner_locked(struct nfs_server *server, const struct cred *cred) |
---|
413 | 408 | { |
---|
414 | 409 | struct rb_node **p = &server->state_owners.rb_node, |
---|
415 | 410 | *parent = NULL; |
---|
416 | 411 | struct nfs4_state_owner *sp; |
---|
| 412 | + int cmp; |
---|
417 | 413 | |
---|
418 | 414 | while (*p != NULL) { |
---|
419 | 415 | parent = *p; |
---|
420 | 416 | sp = rb_entry(parent, struct nfs4_state_owner, so_server_node); |
---|
| 417 | + cmp = cred_fscmp(cred, sp->so_cred); |
---|
421 | 418 | |
---|
422 | | - if (cred < sp->so_cred) |
---|
| 419 | + if (cmp < 0) |
---|
423 | 420 | p = &parent->rb_left; |
---|
424 | | - else if (cred > sp->so_cred) |
---|
| 421 | + else if (cmp > 0) |
---|
425 | 422 | p = &parent->rb_right; |
---|
426 | 423 | else { |
---|
427 | 424 | if (!list_empty(&sp->so_lru)) |
---|
.. | .. |
---|
440 | 437 | struct rb_node **p = &server->state_owners.rb_node, |
---|
441 | 438 | *parent = NULL; |
---|
442 | 439 | struct nfs4_state_owner *sp; |
---|
| 440 | + int cmp; |
---|
443 | 441 | |
---|
444 | 442 | while (*p != NULL) { |
---|
445 | 443 | parent = *p; |
---|
446 | 444 | sp = rb_entry(parent, struct nfs4_state_owner, so_server_node); |
---|
| 445 | + cmp = cred_fscmp(new->so_cred, sp->so_cred); |
---|
447 | 446 | |
---|
448 | | - if (new->so_cred < sp->so_cred) |
---|
| 447 | + if (cmp < 0) |
---|
449 | 448 | p = &parent->rb_left; |
---|
450 | | - else if (new->so_cred > sp->so_cred) |
---|
| 449 | + else if (cmp > 0) |
---|
451 | 450 | p = &parent->rb_right; |
---|
452 | 451 | else { |
---|
453 | 452 | if (!list_empty(&sp->so_lru)) |
---|
.. | .. |
---|
494 | 493 | */ |
---|
495 | 494 | static struct nfs4_state_owner * |
---|
496 | 495 | nfs4_alloc_state_owner(struct nfs_server *server, |
---|
497 | | - struct rpc_cred *cred, |
---|
| 496 | + const struct cred *cred, |
---|
498 | 497 | gfp_t gfp_flags) |
---|
499 | 498 | { |
---|
500 | 499 | struct nfs4_state_owner *sp; |
---|
.. | .. |
---|
509 | 508 | return NULL; |
---|
510 | 509 | } |
---|
511 | 510 | sp->so_server = server; |
---|
512 | | - sp->so_cred = get_rpccred(cred); |
---|
| 511 | + sp->so_cred = get_cred(cred); |
---|
513 | 512 | spin_lock_init(&sp->so_lock); |
---|
514 | 513 | INIT_LIST_HEAD(&sp->so_states); |
---|
515 | 514 | nfs4_init_seqid_counter(&sp->so_seqid); |
---|
516 | 515 | atomic_set(&sp->so_count, 1); |
---|
517 | 516 | INIT_LIST_HEAD(&sp->so_lru); |
---|
518 | | - seqcount_init(&sp->so_reclaim_seqcount); |
---|
| 517 | + seqcount_spinlock_init(&sp->so_reclaim_seqcount, &sp->so_lock); |
---|
519 | 518 | mutex_init(&sp->so_delegreturn_mutex); |
---|
520 | 519 | return sp; |
---|
521 | 520 | } |
---|
.. | .. |
---|
538 | 537 | static void nfs4_free_state_owner(struct nfs4_state_owner *sp) |
---|
539 | 538 | { |
---|
540 | 539 | nfs4_destroy_seqid_counter(&sp->so_seqid); |
---|
541 | | - put_rpccred(sp->so_cred); |
---|
| 540 | + put_cred(sp->so_cred); |
---|
542 | 541 | ida_simple_remove(&sp->so_server->openowner_id, sp->so_seqid.owner_id); |
---|
543 | 542 | kfree(sp); |
---|
544 | 543 | } |
---|
.. | .. |
---|
572 | 571 | * nfs4_get_state_owner - Look up a state owner given a credential |
---|
573 | 572 | * @server: nfs_server to search |
---|
574 | 573 | * @cred: RPC credential to match |
---|
| 574 | + * @gfp_flags: allocation mode |
---|
575 | 575 | * |
---|
576 | 576 | * Returns a pointer to an instantiated nfs4_state_owner struct, or NULL. |
---|
577 | 577 | */ |
---|
578 | 578 | struct nfs4_state_owner *nfs4_get_state_owner(struct nfs_server *server, |
---|
579 | | - struct rpc_cred *cred, |
---|
| 579 | + const struct cred *cred, |
---|
580 | 580 | gfp_t gfp_flags) |
---|
581 | 581 | { |
---|
582 | 582 | struct nfs_client *clp = server->nfs_client; |
---|
.. | .. |
---|
674 | 674 | state = kzalloc(sizeof(*state), GFP_NOFS); |
---|
675 | 675 | if (!state) |
---|
676 | 676 | return NULL; |
---|
677 | | - atomic_set(&state->count, 1); |
---|
| 677 | + refcount_set(&state->count, 1); |
---|
678 | 678 | INIT_LIST_HEAD(&state->lock_states); |
---|
679 | 679 | spin_lock_init(&state->state_lock); |
---|
680 | 680 | seqlock_init(&state->seqlock); |
---|
.. | .. |
---|
703 | 703 | struct nfs_inode *nfsi = NFS_I(inode); |
---|
704 | 704 | struct nfs4_state *state; |
---|
705 | 705 | |
---|
706 | | - list_for_each_entry(state, &nfsi->open_states, inode_states) { |
---|
| 706 | + list_for_each_entry_rcu(state, &nfsi->open_states, inode_states) { |
---|
707 | 707 | if (state->owner != owner) |
---|
708 | 708 | continue; |
---|
709 | 709 | if (!nfs4_valid_open_stateid(state)) |
---|
710 | 710 | continue; |
---|
711 | | - if (atomic_inc_not_zero(&state->count)) |
---|
| 711 | + if (refcount_inc_not_zero(&state->count)) |
---|
712 | 712 | return state; |
---|
713 | 713 | } |
---|
714 | 714 | return NULL; |
---|
.. | .. |
---|
717 | 717 | static void |
---|
718 | 718 | nfs4_free_open_state(struct nfs4_state *state) |
---|
719 | 719 | { |
---|
720 | | - kfree(state); |
---|
| 720 | + kfree_rcu(state, rcu_head); |
---|
721 | 721 | } |
---|
722 | 722 | |
---|
723 | 723 | struct nfs4_state * |
---|
.. | .. |
---|
726 | 726 | struct nfs4_state *state, *new; |
---|
727 | 727 | struct nfs_inode *nfsi = NFS_I(inode); |
---|
728 | 728 | |
---|
729 | | - spin_lock(&inode->i_lock); |
---|
| 729 | + rcu_read_lock(); |
---|
730 | 730 | state = __nfs4_find_state_byowner(inode, owner); |
---|
731 | | - spin_unlock(&inode->i_lock); |
---|
| 731 | + rcu_read_unlock(); |
---|
732 | 732 | if (state) |
---|
733 | 733 | goto out; |
---|
734 | 734 | new = nfs4_alloc_open_state(); |
---|
.. | .. |
---|
739 | 739 | state = new; |
---|
740 | 740 | state->owner = owner; |
---|
741 | 741 | atomic_inc(&owner->so_count); |
---|
742 | | - list_add(&state->inode_states, &nfsi->open_states); |
---|
743 | 742 | ihold(inode); |
---|
744 | 743 | state->inode = inode; |
---|
| 744 | + list_add_rcu(&state->inode_states, &nfsi->open_states); |
---|
745 | 745 | spin_unlock(&inode->i_lock); |
---|
746 | 746 | /* Note: The reclaim code dictates that we add stateless |
---|
747 | 747 | * and read-only stateids to the end of the list */ |
---|
.. | .. |
---|
762 | 762 | struct inode *inode = state->inode; |
---|
763 | 763 | struct nfs4_state_owner *owner = state->owner; |
---|
764 | 764 | |
---|
765 | | - if (!atomic_dec_and_lock(&state->count, &owner->so_lock)) |
---|
| 765 | + if (!refcount_dec_and_lock(&state->count, &owner->so_lock)) |
---|
766 | 766 | return; |
---|
767 | 767 | spin_lock(&inode->i_lock); |
---|
768 | | - list_del(&state->inode_states); |
---|
| 768 | + list_del_rcu(&state->inode_states); |
---|
769 | 769 | list_del(&state->open_states); |
---|
770 | 770 | spin_unlock(&inode->i_lock); |
---|
771 | 771 | spin_unlock(&owner->so_lock); |
---|
| 772 | + nfs4_inode_return_delegation_on_close(inode); |
---|
772 | 773 | iput(inode); |
---|
773 | 774 | nfs4_free_open_state(state); |
---|
774 | 775 | nfs4_put_state_owner(owner); |
---|
.. | .. |
---|
1019 | 1020 | return ret; |
---|
1020 | 1021 | } |
---|
1021 | 1022 | |
---|
1022 | | -bool nfs4_refresh_open_stateid(nfs4_stateid *dst, struct nfs4_state *state) |
---|
1023 | | -{ |
---|
1024 | | - bool ret; |
---|
1025 | | - int seq; |
---|
1026 | | - |
---|
1027 | | - do { |
---|
1028 | | - ret = false; |
---|
1029 | | - seq = read_seqbegin(&state->seqlock); |
---|
1030 | | - if (nfs4_state_match_open_stateid_other(state, dst)) { |
---|
1031 | | - dst->seqid = state->open_stateid.seqid; |
---|
1032 | | - ret = true; |
---|
1033 | | - } |
---|
1034 | | - } while (read_seqretry(&state->seqlock, seq)); |
---|
1035 | | - return ret; |
---|
1036 | | -} |
---|
1037 | | - |
---|
1038 | 1023 | bool nfs4_copy_open_stateid(nfs4_stateid *dst, struct nfs4_state *state) |
---|
1039 | 1024 | { |
---|
1040 | 1025 | bool ret; |
---|
.. | .. |
---|
1060 | 1045 | */ |
---|
1061 | 1046 | int nfs4_select_rw_stateid(struct nfs4_state *state, |
---|
1062 | 1047 | fmode_t fmode, const struct nfs_lock_context *l_ctx, |
---|
1063 | | - nfs4_stateid *dst, struct rpc_cred **cred) |
---|
| 1048 | + nfs4_stateid *dst, const struct cred **cred) |
---|
1064 | 1049 | { |
---|
1065 | 1050 | int ret; |
---|
1066 | 1051 | |
---|
.. | .. |
---|
1083 | 1068 | * choose to use. |
---|
1084 | 1069 | */ |
---|
1085 | 1070 | goto out; |
---|
1086 | | - nfs4_copy_open_stateid(dst, state); |
---|
1087 | | - ret = 0; |
---|
| 1071 | + ret = nfs4_copy_open_stateid(dst, state) ? 0 : -EAGAIN; |
---|
1088 | 1072 | out: |
---|
1089 | 1073 | if (nfs_server_capable(state->inode, NFS_CAP_STATEID_NFSV41)) |
---|
1090 | 1074 | dst->seqid = 0; |
---|
.. | .. |
---|
1155 | 1139 | case -NFS4ERR_MOVED: |
---|
1156 | 1140 | /* Non-seqid mutating errors */ |
---|
1157 | 1141 | return; |
---|
1158 | | - }; |
---|
| 1142 | + } |
---|
1159 | 1143 | /* |
---|
1160 | 1144 | * Note: no locking needed as we are guaranteed to be first |
---|
1161 | 1145 | * on the sequence list |
---|
.. | .. |
---|
1228 | 1212 | { |
---|
1229 | 1213 | struct task_struct *task; |
---|
1230 | 1214 | char buf[INET6_ADDRSTRLEN + sizeof("-manager") + 1]; |
---|
| 1215 | + struct rpc_clnt *clnt = clp->cl_rpcclient; |
---|
| 1216 | + bool swapon = false; |
---|
1231 | 1217 | |
---|
1232 | 1218 | set_bit(NFS4CLNT_RUN_MANAGER, &clp->cl_state); |
---|
| 1219 | + |
---|
| 1220 | + if (atomic_read(&clnt->cl_swapper)) { |
---|
| 1221 | + swapon = !test_and_set_bit(NFS4CLNT_MANAGER_AVAILABLE, |
---|
| 1222 | + &clp->cl_state); |
---|
| 1223 | + if (!swapon) { |
---|
| 1224 | + wake_up_var(&clp->cl_state); |
---|
| 1225 | + return; |
---|
| 1226 | + } |
---|
| 1227 | + } |
---|
| 1228 | + |
---|
1233 | 1229 | if (test_and_set_bit(NFS4CLNT_MANAGER_RUNNING, &clp->cl_state) != 0) |
---|
1234 | 1230 | return; |
---|
| 1231 | + |
---|
1235 | 1232 | __module_get(THIS_MODULE); |
---|
1236 | 1233 | refcount_inc(&clp->cl_count); |
---|
1237 | 1234 | |
---|
.. | .. |
---|
1246 | 1243 | if (IS_ERR(task)) { |
---|
1247 | 1244 | printk(KERN_ERR "%s: kthread_run: %ld\n", |
---|
1248 | 1245 | __func__, PTR_ERR(task)); |
---|
| 1246 | + if (!nfs_client_init_is_complete(clp)) |
---|
| 1247 | + nfs_mark_client_ready(clp, PTR_ERR(task)); |
---|
| 1248 | + if (swapon) |
---|
| 1249 | + clear_bit(NFS4CLNT_MANAGER_AVAILABLE, &clp->cl_state); |
---|
1249 | 1250 | nfs4_clear_state_manager_bit(clp); |
---|
1250 | 1251 | nfs_put_client(clp); |
---|
1251 | 1252 | module_put(THIS_MODULE); |
---|
.. | .. |
---|
1428 | 1429 | list_for_each_entry(pos, &state->lock_states, ls_locks) { |
---|
1429 | 1430 | if (!test_bit(NFS_LOCK_INITIALIZED, &pos->ls_flags)) |
---|
1430 | 1431 | continue; |
---|
1431 | | - if (nfs4_stateid_match_other(&pos->ls_stateid, stateid)) |
---|
| 1432 | + if (nfs4_stateid_match_or_older(&pos->ls_stateid, stateid)) |
---|
1432 | 1433 | return pos; |
---|
1433 | 1434 | } |
---|
1434 | 1435 | return NULL; |
---|
.. | .. |
---|
1457 | 1458 | struct nfs4_state *state; |
---|
1458 | 1459 | bool found = false; |
---|
1459 | 1460 | |
---|
1460 | | - spin_lock(&inode->i_lock); |
---|
1461 | | - list_for_each_entry(ctx, &nfsi->open_files, list) { |
---|
| 1461 | + rcu_read_lock(); |
---|
| 1462 | + list_for_each_entry_rcu(ctx, &nfsi->open_files, list) { |
---|
1462 | 1463 | state = ctx->state; |
---|
1463 | 1464 | if (state == NULL) |
---|
1464 | 1465 | continue; |
---|
1465 | | - if (nfs4_stateid_match_other(&state->stateid, stateid) && |
---|
| 1466 | + if (nfs4_stateid_match_or_older(&state->stateid, stateid) && |
---|
1466 | 1467 | nfs4_state_mark_reclaim_nograce(clp, state)) { |
---|
1467 | 1468 | found = true; |
---|
1468 | 1469 | continue; |
---|
1469 | 1470 | } |
---|
1470 | | - if (nfs4_stateid_match_other(&state->open_stateid, stateid) && |
---|
| 1471 | + if (test_bit(NFS_OPEN_STATE, &state->flags) && |
---|
| 1472 | + nfs4_stateid_match_or_older(&state->open_stateid, stateid) && |
---|
1471 | 1473 | nfs4_state_mark_reclaim_nograce(clp, state)) { |
---|
1472 | 1474 | found = true; |
---|
1473 | 1475 | continue; |
---|
.. | .. |
---|
1476 | 1478 | nfs4_state_mark_reclaim_nograce(clp, state)) |
---|
1477 | 1479 | found = true; |
---|
1478 | 1480 | } |
---|
1479 | | - spin_unlock(&inode->i_lock); |
---|
| 1481 | + rcu_read_unlock(); |
---|
1480 | 1482 | |
---|
1481 | 1483 | nfs_inode_find_delegation_state_and_recover(inode, stateid); |
---|
1482 | 1484 | if (found) |
---|
1483 | 1485 | nfs4_schedule_state_manager(clp); |
---|
1484 | 1486 | } |
---|
1485 | 1487 | |
---|
1486 | | -static void nfs4_state_mark_open_context_bad(struct nfs4_state *state) |
---|
| 1488 | +static void nfs4_state_mark_open_context_bad(struct nfs4_state *state, int err) |
---|
1487 | 1489 | { |
---|
1488 | 1490 | struct inode *inode = state->inode; |
---|
1489 | 1491 | struct nfs_inode *nfsi = NFS_I(inode); |
---|
1490 | 1492 | struct nfs_open_context *ctx; |
---|
1491 | 1493 | |
---|
1492 | | - spin_lock(&inode->i_lock); |
---|
1493 | | - list_for_each_entry(ctx, &nfsi->open_files, list) { |
---|
| 1494 | + rcu_read_lock(); |
---|
| 1495 | + list_for_each_entry_rcu(ctx, &nfsi->open_files, list) { |
---|
1494 | 1496 | if (ctx->state != state) |
---|
1495 | 1497 | continue; |
---|
1496 | 1498 | set_bit(NFS_CONTEXT_BAD, &ctx->flags); |
---|
| 1499 | + pr_warn("NFSv4: state recovery failed for open file %pd2, " |
---|
| 1500 | + "error = %d\n", ctx->dentry, err); |
---|
1497 | 1501 | } |
---|
1498 | | - spin_unlock(&inode->i_lock); |
---|
| 1502 | + rcu_read_unlock(); |
---|
1499 | 1503 | } |
---|
1500 | 1504 | |
---|
1501 | 1505 | static void nfs4_state_mark_recovery_failed(struct nfs4_state *state, int error) |
---|
1502 | 1506 | { |
---|
1503 | 1507 | set_bit(NFS_STATE_RECOVERY_FAILED, &state->flags); |
---|
1504 | | - nfs4_state_mark_open_context_bad(state); |
---|
| 1508 | + nfs4_state_mark_open_context_bad(state, error); |
---|
1505 | 1509 | } |
---|
1506 | 1510 | |
---|
1507 | 1511 | |
---|
.. | .. |
---|
1532 | 1536 | switch (status) { |
---|
1533 | 1537 | case 0: |
---|
1534 | 1538 | break; |
---|
| 1539 | + case -ETIMEDOUT: |
---|
1535 | 1540 | case -ESTALE: |
---|
1536 | 1541 | case -NFS4ERR_ADMIN_REVOKED: |
---|
1537 | 1542 | case -NFS4ERR_STALE_STATEID: |
---|
.. | .. |
---|
1547 | 1552 | default: |
---|
1548 | 1553 | pr_err("NFS: %s: unhandled error %d\n", |
---|
1549 | 1554 | __func__, status); |
---|
1550 | | - /* Fall through */ |
---|
| 1555 | + fallthrough; |
---|
1551 | 1556 | case -ENOMEM: |
---|
1552 | 1557 | case -NFS4ERR_DENIED: |
---|
1553 | 1558 | case -NFS4ERR_RECLAIM_BAD: |
---|
.. | .. |
---|
1569 | 1574 | return status; |
---|
1570 | 1575 | } |
---|
1571 | 1576 | |
---|
| 1577 | +#ifdef CONFIG_NFS_V4_2 |
---|
| 1578 | +static void nfs42_complete_copies(struct nfs4_state_owner *sp, struct nfs4_state *state) |
---|
| 1579 | +{ |
---|
| 1580 | + struct nfs4_copy_state *copy; |
---|
| 1581 | + |
---|
| 1582 | + if (!test_bit(NFS_CLNT_DST_SSC_COPY_STATE, &state->flags) && |
---|
| 1583 | + !test_bit(NFS_CLNT_SRC_SSC_COPY_STATE, &state->flags)) |
---|
| 1584 | + return; |
---|
| 1585 | + |
---|
| 1586 | + spin_lock(&sp->so_server->nfs_client->cl_lock); |
---|
| 1587 | + list_for_each_entry(copy, &sp->so_server->ss_copies, copies) { |
---|
| 1588 | + if ((test_bit(NFS_CLNT_DST_SSC_COPY_STATE, &state->flags) && |
---|
| 1589 | + !nfs4_stateid_match_other(&state->stateid, |
---|
| 1590 | + ©->parent_dst_state->stateid))) |
---|
| 1591 | + continue; |
---|
| 1592 | + copy->flags = 1; |
---|
| 1593 | + if (test_and_clear_bit(NFS_CLNT_DST_SSC_COPY_STATE, |
---|
| 1594 | + &state->flags)) { |
---|
| 1595 | + clear_bit(NFS_CLNT_SRC_SSC_COPY_STATE, &state->flags); |
---|
| 1596 | + complete(©->completion); |
---|
| 1597 | + } |
---|
| 1598 | + } |
---|
| 1599 | + list_for_each_entry(copy, &sp->so_server->ss_copies, src_copies) { |
---|
| 1600 | + if ((test_bit(NFS_CLNT_SRC_SSC_COPY_STATE, &state->flags) && |
---|
| 1601 | + !nfs4_stateid_match_other(&state->stateid, |
---|
| 1602 | + ©->parent_src_state->stateid))) |
---|
| 1603 | + continue; |
---|
| 1604 | + copy->flags = 1; |
---|
| 1605 | + if (test_and_clear_bit(NFS_CLNT_DST_SSC_COPY_STATE, |
---|
| 1606 | + &state->flags)) |
---|
| 1607 | + complete(©->completion); |
---|
| 1608 | + } |
---|
| 1609 | + spin_unlock(&sp->so_server->nfs_client->cl_lock); |
---|
| 1610 | +} |
---|
| 1611 | +#else /* !CONFIG_NFS_V4_2 */ |
---|
| 1612 | +static inline void nfs42_complete_copies(struct nfs4_state_owner *sp, |
---|
| 1613 | + struct nfs4_state *state) |
---|
| 1614 | +{ |
---|
| 1615 | +} |
---|
| 1616 | +#endif /* CONFIG_NFS_V4_2 */ |
---|
| 1617 | + |
---|
| 1618 | +static int __nfs4_reclaim_open_state(struct nfs4_state_owner *sp, struct nfs4_state *state, |
---|
| 1619 | + const struct nfs4_state_recovery_ops *ops) |
---|
| 1620 | +{ |
---|
| 1621 | + struct nfs4_lock_state *lock; |
---|
| 1622 | + int status; |
---|
| 1623 | + |
---|
| 1624 | + status = ops->recover_open(sp, state); |
---|
| 1625 | + if (status < 0) |
---|
| 1626 | + return status; |
---|
| 1627 | + |
---|
| 1628 | + status = nfs4_reclaim_locks(state, ops); |
---|
| 1629 | + if (status < 0) |
---|
| 1630 | + return status; |
---|
| 1631 | + |
---|
| 1632 | + if (!test_bit(NFS_DELEGATED_STATE, &state->flags)) { |
---|
| 1633 | + spin_lock(&state->state_lock); |
---|
| 1634 | + list_for_each_entry(lock, &state->lock_states, ls_locks) { |
---|
| 1635 | + trace_nfs4_state_lock_reclaim(state, lock); |
---|
| 1636 | + if (!test_bit(NFS_LOCK_INITIALIZED, &lock->ls_flags)) |
---|
| 1637 | + pr_warn_ratelimited("NFS: %s: Lock reclaim failed!\n", __func__); |
---|
| 1638 | + } |
---|
| 1639 | + spin_unlock(&state->state_lock); |
---|
| 1640 | + } |
---|
| 1641 | + |
---|
| 1642 | + nfs42_complete_copies(sp, state); |
---|
| 1643 | + clear_bit(NFS_STATE_RECLAIM_NOGRACE, &state->flags); |
---|
| 1644 | + return status; |
---|
| 1645 | +} |
---|
| 1646 | + |
---|
1572 | 1647 | static int nfs4_reclaim_open_state(struct nfs4_state_owner *sp, const struct nfs4_state_recovery_ops *ops) |
---|
1573 | 1648 | { |
---|
1574 | 1649 | struct nfs4_state *state; |
---|
1575 | | - struct nfs4_lock_state *lock; |
---|
| 1650 | + unsigned int loop = 0; |
---|
1576 | 1651 | int status = 0; |
---|
| 1652 | +#ifdef CONFIG_NFS_V4_2 |
---|
| 1653 | + bool found_ssc_copy_state = false; |
---|
| 1654 | +#endif /* CONFIG_NFS_V4_2 */ |
---|
1577 | 1655 | |
---|
1578 | 1656 | /* Note: we rely on the sp->so_states list being ordered |
---|
1579 | 1657 | * so that we always reclaim open(O_RDWR) and/or open(O_WRITE) |
---|
.. | .. |
---|
1593 | 1671 | continue; |
---|
1594 | 1672 | if (state->state == 0) |
---|
1595 | 1673 | continue; |
---|
1596 | | - atomic_inc(&state->count); |
---|
1597 | | - spin_unlock(&sp->so_lock); |
---|
1598 | | - status = ops->recover_open(sp, state); |
---|
1599 | | - if (status >= 0) { |
---|
1600 | | - status = nfs4_reclaim_locks(state, ops); |
---|
1601 | | - if (status >= 0) { |
---|
1602 | | - if (!test_bit(NFS_DELEGATED_STATE, &state->flags)) { |
---|
1603 | | - spin_lock(&state->state_lock); |
---|
1604 | | - list_for_each_entry(lock, &state->lock_states, ls_locks) { |
---|
1605 | | - if (!test_bit(NFS_LOCK_INITIALIZED, &lock->ls_flags)) |
---|
1606 | | - pr_warn_ratelimited("NFS: " |
---|
1607 | | - "%s: Lock reclaim " |
---|
1608 | | - "failed!\n", __func__); |
---|
1609 | | - } |
---|
1610 | | - spin_unlock(&state->state_lock); |
---|
1611 | | - } |
---|
1612 | | - clear_bit(NFS_STATE_RECLAIM_NOGRACE, |
---|
1613 | | - &state->flags); |
---|
1614 | 1674 | #ifdef CONFIG_NFS_V4_2 |
---|
1615 | | - if (test_bit(NFS_CLNT_DST_SSC_COPY_STATE, &state->flags)) { |
---|
1616 | | - struct nfs4_copy_state *copy; |
---|
1617 | | - |
---|
1618 | | - spin_lock(&sp->so_server->nfs_client->cl_lock); |
---|
1619 | | - list_for_each_entry(copy, &sp->so_server->ss_copies, copies) { |
---|
1620 | | - if (memcmp(&state->stateid.other, ©->parent_state->stateid.other, NFS4_STATEID_SIZE)) |
---|
1621 | | - continue; |
---|
1622 | | - copy->flags = 1; |
---|
1623 | | - complete(©->completion); |
---|
1624 | | - printk("AGLO: server rebooted waking up the copy\n"); |
---|
1625 | | - break; |
---|
1626 | | - } |
---|
1627 | | - spin_unlock(&sp->so_server->nfs_client->cl_lock); |
---|
1628 | | - } |
---|
1629 | | -#endif /* CONFIG_NFS_V4_2 */ |
---|
1630 | | - nfs4_put_open_state(state); |
---|
1631 | | - spin_lock(&sp->so_lock); |
---|
1632 | | - goto restart; |
---|
1633 | | - } |
---|
| 1675 | + if (test_bit(NFS_SRV_SSC_COPY_STATE, &state->flags)) { |
---|
| 1676 | + nfs4_state_mark_recovery_failed(state, -EIO); |
---|
| 1677 | + found_ssc_copy_state = true; |
---|
| 1678 | + continue; |
---|
1634 | 1679 | } |
---|
| 1680 | +#endif /* CONFIG_NFS_V4_2 */ |
---|
| 1681 | + refcount_inc(&state->count); |
---|
| 1682 | + spin_unlock(&sp->so_lock); |
---|
| 1683 | + status = __nfs4_reclaim_open_state(sp, state, ops); |
---|
| 1684 | + |
---|
1635 | 1685 | switch (status) { |
---|
1636 | | - default: |
---|
1637 | | - printk(KERN_ERR "NFS: %s: unhandled error %d\n", |
---|
1638 | | - __func__, status); |
---|
1639 | | - /* Fall through */ |
---|
1640 | | - case -ENOENT: |
---|
1641 | | - case -ENOMEM: |
---|
1642 | | - case -EACCES: |
---|
1643 | | - case -EROFS: |
---|
1644 | | - case -EIO: |
---|
1645 | | - case -ESTALE: |
---|
1646 | | - /* Open state on this file cannot be recovered */ |
---|
1647 | | - nfs4_state_mark_recovery_failed(state, status); |
---|
| 1686 | + default: |
---|
| 1687 | + if (status >= 0) { |
---|
| 1688 | + loop = 0; |
---|
1648 | 1689 | break; |
---|
1649 | | - case -EAGAIN: |
---|
1650 | | - ssleep(1); |
---|
1651 | | - /* Fall through */ |
---|
1652 | | - case -NFS4ERR_ADMIN_REVOKED: |
---|
1653 | | - case -NFS4ERR_STALE_STATEID: |
---|
1654 | | - case -NFS4ERR_OLD_STATEID: |
---|
1655 | | - case -NFS4ERR_BAD_STATEID: |
---|
1656 | | - case -NFS4ERR_RECLAIM_BAD: |
---|
1657 | | - case -NFS4ERR_RECLAIM_CONFLICT: |
---|
1658 | | - nfs4_state_mark_reclaim_nograce(sp->so_server->nfs_client, state); |
---|
| 1690 | + } |
---|
| 1691 | + printk(KERN_ERR "NFS: %s: unhandled error %d\n", __func__, status); |
---|
| 1692 | + fallthrough; |
---|
| 1693 | + case -ENOENT: |
---|
| 1694 | + case -ENOMEM: |
---|
| 1695 | + case -EACCES: |
---|
| 1696 | + case -EROFS: |
---|
| 1697 | + case -EIO: |
---|
| 1698 | + case -ESTALE: |
---|
| 1699 | + /* Open state on this file cannot be recovered */ |
---|
| 1700 | + nfs4_state_mark_recovery_failed(state, status); |
---|
| 1701 | + break; |
---|
| 1702 | + case -EAGAIN: |
---|
| 1703 | + ssleep(1); |
---|
| 1704 | + if (loop++ < 10) { |
---|
| 1705 | + set_bit(ops->state_flag_bit, &state->flags); |
---|
1659 | 1706 | break; |
---|
1660 | | - case -NFS4ERR_EXPIRED: |
---|
1661 | | - case -NFS4ERR_NO_GRACE: |
---|
1662 | | - nfs4_state_mark_reclaim_nograce(sp->so_server->nfs_client, state); |
---|
1663 | | - case -NFS4ERR_STALE_CLIENTID: |
---|
1664 | | - case -NFS4ERR_BADSESSION: |
---|
1665 | | - case -NFS4ERR_BADSLOT: |
---|
1666 | | - case -NFS4ERR_BAD_HIGH_SLOT: |
---|
1667 | | - case -NFS4ERR_CONN_NOT_BOUND_TO_SESSION: |
---|
1668 | | - goto out_err; |
---|
| 1707 | + } |
---|
| 1708 | + fallthrough; |
---|
| 1709 | + case -NFS4ERR_ADMIN_REVOKED: |
---|
| 1710 | + case -NFS4ERR_STALE_STATEID: |
---|
| 1711 | + case -NFS4ERR_OLD_STATEID: |
---|
| 1712 | + case -NFS4ERR_BAD_STATEID: |
---|
| 1713 | + case -NFS4ERR_RECLAIM_BAD: |
---|
| 1714 | + case -NFS4ERR_RECLAIM_CONFLICT: |
---|
| 1715 | + nfs4_state_mark_reclaim_nograce(sp->so_server->nfs_client, state); |
---|
| 1716 | + break; |
---|
| 1717 | + case -NFS4ERR_EXPIRED: |
---|
| 1718 | + case -NFS4ERR_NO_GRACE: |
---|
| 1719 | + nfs4_state_mark_reclaim_nograce(sp->so_server->nfs_client, state); |
---|
| 1720 | + fallthrough; |
---|
| 1721 | + case -NFS4ERR_STALE_CLIENTID: |
---|
| 1722 | + case -NFS4ERR_BADSESSION: |
---|
| 1723 | + case -NFS4ERR_BADSLOT: |
---|
| 1724 | + case -NFS4ERR_BAD_HIGH_SLOT: |
---|
| 1725 | + case -NFS4ERR_CONN_NOT_BOUND_TO_SESSION: |
---|
| 1726 | + case -ETIMEDOUT: |
---|
| 1727 | + goto out_err; |
---|
1669 | 1728 | } |
---|
1670 | 1729 | nfs4_put_open_state(state); |
---|
1671 | 1730 | spin_lock(&sp->so_lock); |
---|
.. | .. |
---|
1673 | 1732 | } |
---|
1674 | 1733 | raw_write_seqcount_end(&sp->so_reclaim_seqcount); |
---|
1675 | 1734 | spin_unlock(&sp->so_lock); |
---|
| 1735 | +#ifdef CONFIG_NFS_V4_2 |
---|
| 1736 | + if (found_ssc_copy_state) |
---|
| 1737 | + return -EIO; |
---|
| 1738 | +#endif /* CONFIG_NFS_V4_2 */ |
---|
1676 | 1739 | return 0; |
---|
1677 | 1740 | out_err: |
---|
1678 | 1741 | nfs4_put_open_state(state); |
---|
.. | .. |
---|
1735 | 1798 | |
---|
1736 | 1799 | static void nfs4_state_start_reclaim_reboot(struct nfs_client *clp) |
---|
1737 | 1800 | { |
---|
| 1801 | + set_bit(NFS4CLNT_RECLAIM_REBOOT, &clp->cl_state); |
---|
1738 | 1802 | /* Mark all delegations for reclaim */ |
---|
1739 | 1803 | nfs_delegation_mark_reclaim(clp); |
---|
1740 | 1804 | nfs4_state_mark_reclaim_helper(clp, nfs4_state_mark_reclaim_reboot); |
---|
.. | .. |
---|
1742 | 1806 | |
---|
1743 | 1807 | static int nfs4_reclaim_complete(struct nfs_client *clp, |
---|
1744 | 1808 | const struct nfs4_state_recovery_ops *ops, |
---|
1745 | | - struct rpc_cred *cred) |
---|
| 1809 | + const struct cred *cred) |
---|
1746 | 1810 | { |
---|
1747 | 1811 | /* Notify the server we're done reclaiming our state */ |
---|
1748 | 1812 | if (ops->reclaim_complete) |
---|
.. | .. |
---|
1793 | 1857 | static void nfs4_state_end_reclaim_reboot(struct nfs_client *clp) |
---|
1794 | 1858 | { |
---|
1795 | 1859 | const struct nfs4_state_recovery_ops *ops; |
---|
1796 | | - struct rpc_cred *cred; |
---|
| 1860 | + const struct cred *cred; |
---|
1797 | 1861 | int err; |
---|
1798 | 1862 | |
---|
1799 | 1863 | if (!nfs4_state_clear_reclaim_reboot(clp)) |
---|
.. | .. |
---|
1801 | 1865 | ops = clp->cl_mvops->reboot_recovery_ops; |
---|
1802 | 1866 | cred = nfs4_get_clid_cred(clp); |
---|
1803 | 1867 | err = nfs4_reclaim_complete(clp, ops, cred); |
---|
1804 | | - put_rpccred(cred); |
---|
| 1868 | + put_cred(cred); |
---|
1805 | 1869 | if (err == -NFS4ERR_CONN_NOT_BOUND_TO_SESSION) |
---|
1806 | 1870 | set_bit(NFS4CLNT_RECLAIM_REBOOT, &clp->cl_state); |
---|
1807 | 1871 | } |
---|
.. | .. |
---|
1815 | 1879 | static int nfs4_recovery_handle_error(struct nfs_client *clp, int error) |
---|
1816 | 1880 | { |
---|
1817 | 1881 | switch (error) { |
---|
1818 | | - case 0: |
---|
1819 | | - break; |
---|
1820 | | - case -NFS4ERR_CB_PATH_DOWN: |
---|
1821 | | - nfs40_handle_cb_pathdown(clp); |
---|
1822 | | - break; |
---|
1823 | | - case -NFS4ERR_NO_GRACE: |
---|
1824 | | - nfs4_state_end_reclaim_reboot(clp); |
---|
1825 | | - break; |
---|
1826 | | - case -NFS4ERR_STALE_CLIENTID: |
---|
1827 | | - set_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state); |
---|
1828 | | - nfs4_state_start_reclaim_reboot(clp); |
---|
1829 | | - break; |
---|
1830 | | - case -NFS4ERR_EXPIRED: |
---|
1831 | | - set_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state); |
---|
1832 | | - nfs4_state_start_reclaim_nograce(clp); |
---|
1833 | | - break; |
---|
1834 | | - case -NFS4ERR_BADSESSION: |
---|
1835 | | - case -NFS4ERR_BADSLOT: |
---|
1836 | | - case -NFS4ERR_BAD_HIGH_SLOT: |
---|
1837 | | - case -NFS4ERR_DEADSESSION: |
---|
1838 | | - case -NFS4ERR_SEQ_FALSE_RETRY: |
---|
1839 | | - case -NFS4ERR_SEQ_MISORDERED: |
---|
1840 | | - set_bit(NFS4CLNT_SESSION_RESET, &clp->cl_state); |
---|
1841 | | - /* Zero session reset errors */ |
---|
1842 | | - break; |
---|
1843 | | - case -NFS4ERR_CONN_NOT_BOUND_TO_SESSION: |
---|
1844 | | - set_bit(NFS4CLNT_BIND_CONN_TO_SESSION, &clp->cl_state); |
---|
1845 | | - break; |
---|
1846 | | - default: |
---|
1847 | | - dprintk("%s: failed to handle error %d for server %s\n", |
---|
1848 | | - __func__, error, clp->cl_hostname); |
---|
1849 | | - return error; |
---|
| 1882 | + case 0: |
---|
| 1883 | + break; |
---|
| 1884 | + case -NFS4ERR_CB_PATH_DOWN: |
---|
| 1885 | + nfs40_handle_cb_pathdown(clp); |
---|
| 1886 | + break; |
---|
| 1887 | + case -NFS4ERR_NO_GRACE: |
---|
| 1888 | + nfs4_state_end_reclaim_reboot(clp); |
---|
| 1889 | + break; |
---|
| 1890 | + case -NFS4ERR_STALE_CLIENTID: |
---|
| 1891 | + set_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state); |
---|
| 1892 | + nfs4_state_start_reclaim_reboot(clp); |
---|
| 1893 | + break; |
---|
| 1894 | + case -NFS4ERR_EXPIRED: |
---|
| 1895 | + set_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state); |
---|
| 1896 | + nfs4_state_start_reclaim_nograce(clp); |
---|
| 1897 | + break; |
---|
| 1898 | + case -NFS4ERR_BADSESSION: |
---|
| 1899 | + case -NFS4ERR_BADSLOT: |
---|
| 1900 | + case -NFS4ERR_BAD_HIGH_SLOT: |
---|
| 1901 | + case -NFS4ERR_DEADSESSION: |
---|
| 1902 | + case -NFS4ERR_SEQ_FALSE_RETRY: |
---|
| 1903 | + case -NFS4ERR_SEQ_MISORDERED: |
---|
| 1904 | + set_bit(NFS4CLNT_SESSION_RESET, &clp->cl_state); |
---|
| 1905 | + /* Zero session reset errors */ |
---|
| 1906 | + break; |
---|
| 1907 | + case -NFS4ERR_CONN_NOT_BOUND_TO_SESSION: |
---|
| 1908 | + set_bit(NFS4CLNT_BIND_CONN_TO_SESSION, &clp->cl_state); |
---|
| 1909 | + break; |
---|
| 1910 | + default: |
---|
| 1911 | + dprintk("%s: failed to handle error %d for server %s\n", |
---|
| 1912 | + __func__, error, clp->cl_hostname); |
---|
| 1913 | + return error; |
---|
1850 | 1914 | } |
---|
1851 | 1915 | dprintk("%s: handled error %d for server %s\n", __func__, error, |
---|
1852 | 1916 | clp->cl_hostname); |
---|
.. | .. |
---|
1899 | 1963 | |
---|
1900 | 1964 | static int nfs4_check_lease(struct nfs_client *clp) |
---|
1901 | 1965 | { |
---|
1902 | | - struct rpc_cred *cred; |
---|
| 1966 | + const struct cred *cred; |
---|
1903 | 1967 | const struct nfs4_state_maintenance_ops *ops = |
---|
1904 | 1968 | clp->cl_mvops->state_renewal_ops; |
---|
1905 | 1969 | int status; |
---|
.. | .. |
---|
1907 | 1971 | /* Is the client already known to have an expired lease? */ |
---|
1908 | 1972 | if (test_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state)) |
---|
1909 | 1973 | return 0; |
---|
1910 | | - spin_lock(&clp->cl_lock); |
---|
1911 | | - cred = ops->get_state_renewal_cred_locked(clp); |
---|
1912 | | - spin_unlock(&clp->cl_lock); |
---|
| 1974 | + cred = ops->get_state_renewal_cred(clp); |
---|
1913 | 1975 | if (cred == NULL) { |
---|
1914 | 1976 | cred = nfs4_get_clid_cred(clp); |
---|
1915 | 1977 | status = -ENOKEY; |
---|
.. | .. |
---|
1917 | 1979 | goto out; |
---|
1918 | 1980 | } |
---|
1919 | 1981 | status = ops->renew_lease(clp, cred); |
---|
1920 | | - put_rpccred(cred); |
---|
| 1982 | + put_cred(cred); |
---|
1921 | 1983 | if (status == -ETIMEDOUT) { |
---|
1922 | 1984 | set_bit(NFS4CLNT_CHECK_LEASE, &clp->cl_state); |
---|
1923 | 1985 | return 0; |
---|
.. | .. |
---|
1951 | 2013 | return -EPERM; |
---|
1952 | 2014 | case -EACCES: |
---|
1953 | 2015 | case -NFS4ERR_DELAY: |
---|
1954 | | - case -ETIMEDOUT: |
---|
1955 | 2016 | case -EAGAIN: |
---|
1956 | 2017 | ssleep(1); |
---|
1957 | 2018 | break; |
---|
.. | .. |
---|
1977 | 2038 | |
---|
1978 | 2039 | static int nfs4_establish_lease(struct nfs_client *clp) |
---|
1979 | 2040 | { |
---|
1980 | | - struct rpc_cred *cred; |
---|
| 2041 | + const struct cred *cred; |
---|
1981 | 2042 | const struct nfs4_state_recovery_ops *ops = |
---|
1982 | 2043 | clp->cl_mvops->reboot_recovery_ops; |
---|
1983 | 2044 | int status; |
---|
.. | .. |
---|
1989 | 2050 | if (cred == NULL) |
---|
1990 | 2051 | return -ENOENT; |
---|
1991 | 2052 | status = ops->establish_clid(clp, cred); |
---|
1992 | | - put_rpccred(cred); |
---|
| 2053 | + put_cred(cred); |
---|
1993 | 2054 | if (status != 0) |
---|
1994 | 2055 | return status; |
---|
1995 | 2056 | pnfs_destroy_all_layouts(clp); |
---|
.. | .. |
---|
2036 | 2097 | * |
---|
2037 | 2098 | * Returns zero or a negative NFS4ERR status code. |
---|
2038 | 2099 | */ |
---|
2039 | | -static int nfs4_try_migration(struct nfs_server *server, struct rpc_cred *cred) |
---|
| 2100 | +static int nfs4_try_migration(struct nfs_server *server, const struct cred *cred) |
---|
2040 | 2101 | { |
---|
2041 | 2102 | struct nfs_client *clp = server->nfs_client; |
---|
2042 | 2103 | struct nfs4_fs_locations *locations = NULL; |
---|
.. | .. |
---|
2076 | 2137 | } |
---|
2077 | 2138 | |
---|
2078 | 2139 | status = nfs4_begin_drain_session(clp); |
---|
2079 | | - if (status != 0) |
---|
2080 | | - return status; |
---|
| 2140 | + if (status != 0) { |
---|
| 2141 | + result = status; |
---|
| 2142 | + goto out; |
---|
| 2143 | + } |
---|
2081 | 2144 | |
---|
2082 | 2145 | status = nfs4_replace_transport(server, locations); |
---|
2083 | 2146 | if (status != 0) { |
---|
.. | .. |
---|
2109 | 2172 | const struct nfs4_state_maintenance_ops *ops = |
---|
2110 | 2173 | clp->cl_mvops->state_renewal_ops; |
---|
2111 | 2174 | struct nfs_server *server; |
---|
2112 | | - struct rpc_cred *cred; |
---|
| 2175 | + const struct cred *cred; |
---|
2113 | 2176 | |
---|
2114 | 2177 | dprintk("%s: migration reported on \"%s\"\n", __func__, |
---|
2115 | 2178 | clp->cl_hostname); |
---|
2116 | 2179 | |
---|
2117 | | - spin_lock(&clp->cl_lock); |
---|
2118 | | - cred = ops->get_state_renewal_cred_locked(clp); |
---|
2119 | | - spin_unlock(&clp->cl_lock); |
---|
| 2180 | + cred = ops->get_state_renewal_cred(clp); |
---|
2120 | 2181 | if (cred == NULL) |
---|
2121 | 2182 | return -NFS4ERR_NOENT; |
---|
2122 | 2183 | |
---|
.. | .. |
---|
2137 | 2198 | rcu_read_unlock(); |
---|
2138 | 2199 | status = nfs4_try_migration(server, cred); |
---|
2139 | 2200 | if (status < 0) { |
---|
2140 | | - put_rpccred(cred); |
---|
| 2201 | + put_cred(cred); |
---|
2141 | 2202 | return status; |
---|
2142 | 2203 | } |
---|
2143 | 2204 | goto restart; |
---|
2144 | 2205 | } |
---|
2145 | 2206 | rcu_read_unlock(); |
---|
2146 | | - put_rpccred(cred); |
---|
| 2207 | + put_cred(cred); |
---|
2147 | 2208 | return 0; |
---|
2148 | 2209 | } |
---|
2149 | 2210 | |
---|
.. | .. |
---|
2157 | 2218 | const struct nfs4_state_maintenance_ops *ops = |
---|
2158 | 2219 | clp->cl_mvops->state_renewal_ops; |
---|
2159 | 2220 | struct nfs_server *server; |
---|
2160 | | - struct rpc_cred *cred; |
---|
| 2221 | + const struct cred *cred; |
---|
2161 | 2222 | |
---|
2162 | 2223 | dprintk("%s: lease moved reported on \"%s\"\n", __func__, |
---|
2163 | 2224 | clp->cl_hostname); |
---|
2164 | 2225 | |
---|
2165 | | - spin_lock(&clp->cl_lock); |
---|
2166 | | - cred = ops->get_state_renewal_cred_locked(clp); |
---|
2167 | | - spin_unlock(&clp->cl_lock); |
---|
| 2226 | + cred = ops->get_state_renewal_cred(clp); |
---|
2168 | 2227 | if (cred == NULL) |
---|
2169 | 2228 | return -NFS4ERR_NOENT; |
---|
2170 | 2229 | |
---|
.. | .. |
---|
2192 | 2251 | rcu_read_unlock(); |
---|
2193 | 2252 | |
---|
2194 | 2253 | out: |
---|
2195 | | - put_rpccred(cred); |
---|
| 2254 | + put_cred(cred); |
---|
2196 | 2255 | return 0; |
---|
2197 | 2256 | } |
---|
2198 | 2257 | |
---|
.. | .. |
---|
2215 | 2274 | const struct nfs4_state_recovery_ops *ops = |
---|
2216 | 2275 | clp->cl_mvops->reboot_recovery_ops; |
---|
2217 | 2276 | struct rpc_clnt *clnt; |
---|
2218 | | - struct rpc_cred *cred; |
---|
| 2277 | + const struct cred *cred; |
---|
2219 | 2278 | int i, status; |
---|
2220 | 2279 | |
---|
2221 | 2280 | dprintk("NFS: %s: testing '%s'\n", __func__, clp->cl_hostname); |
---|
.. | .. |
---|
2231 | 2290 | goto out_unlock; |
---|
2232 | 2291 | |
---|
2233 | 2292 | status = ops->detect_trunking(clp, result, cred); |
---|
2234 | | - put_rpccred(cred); |
---|
| 2293 | + put_cred(cred); |
---|
2235 | 2294 | switch (status) { |
---|
2236 | 2295 | case 0: |
---|
2237 | 2296 | case -EINTR: |
---|
.. | .. |
---|
2240 | 2299 | case -ETIMEDOUT: |
---|
2241 | 2300 | if (clnt->cl_softrtry) |
---|
2242 | 2301 | break; |
---|
2243 | | - /* Fall through */ |
---|
| 2302 | + fallthrough; |
---|
2244 | 2303 | case -NFS4ERR_DELAY: |
---|
2245 | 2304 | case -EAGAIN: |
---|
2246 | 2305 | ssleep(1); |
---|
2247 | | - /* Fall through */ |
---|
| 2306 | + fallthrough; |
---|
2248 | 2307 | case -NFS4ERR_STALE_CLIENTID: |
---|
2249 | 2308 | dprintk("NFS: %s after status %d, retrying\n", |
---|
2250 | 2309 | __func__, status); |
---|
.. | .. |
---|
2256 | 2315 | } |
---|
2257 | 2316 | if (clnt->cl_auth->au_flavor == RPC_AUTH_UNIX) |
---|
2258 | 2317 | break; |
---|
2259 | | - /* Fall through */ |
---|
| 2318 | + fallthrough; |
---|
2260 | 2319 | case -NFS4ERR_CLID_INUSE: |
---|
2261 | 2320 | case -NFS4ERR_WRONGSEC: |
---|
2262 | 2321 | /* No point in retrying if we already used RPC_AUTH_UNIX */ |
---|
.. | .. |
---|
2362 | 2421 | { |
---|
2363 | 2422 | /* FIXME: For now, we destroy all layouts. */ |
---|
2364 | 2423 | pnfs_destroy_all_layouts(clp); |
---|
2365 | | - /* FIXME: For now, we test all delegations+open state+locks. */ |
---|
2366 | | - nfs41_handle_some_state_revoked(clp); |
---|
| 2424 | + nfs_test_expired_all_delegations(clp); |
---|
2367 | 2425 | dprintk("%s: Recallable state revoked on server %s!\n", __func__, |
---|
2368 | 2426 | clp->cl_hostname); |
---|
2369 | 2427 | } |
---|
.. | .. |
---|
2422 | 2480 | |
---|
2423 | 2481 | static int nfs4_reset_session(struct nfs_client *clp) |
---|
2424 | 2482 | { |
---|
2425 | | - struct rpc_cred *cred; |
---|
| 2483 | + const struct cred *cred; |
---|
2426 | 2484 | int status; |
---|
2427 | 2485 | |
---|
2428 | 2486 | if (!nfs4_has_session(clp)) |
---|
.. | .. |
---|
2460 | 2518 | dprintk("%s: session reset was successful for server %s!\n", |
---|
2461 | 2519 | __func__, clp->cl_hostname); |
---|
2462 | 2520 | out: |
---|
2463 | | - if (cred) |
---|
2464 | | - put_rpccred(cred); |
---|
| 2521 | + put_cred(cred); |
---|
2465 | 2522 | return status; |
---|
2466 | 2523 | } |
---|
2467 | 2524 | |
---|
2468 | 2525 | static int nfs4_bind_conn_to_session(struct nfs_client *clp) |
---|
2469 | 2526 | { |
---|
2470 | | - struct rpc_cred *cred; |
---|
| 2527 | + const struct cred *cred; |
---|
2471 | 2528 | int ret; |
---|
2472 | 2529 | |
---|
2473 | 2530 | if (!nfs4_has_session(clp)) |
---|
.. | .. |
---|
2477 | 2534 | return ret; |
---|
2478 | 2535 | cred = nfs4_get_clid_cred(clp); |
---|
2479 | 2536 | ret = nfs4_proc_bind_conn_to_session(clp, cred); |
---|
2480 | | - if (cred) |
---|
2481 | | - put_rpccred(cred); |
---|
| 2537 | + put_cred(cred); |
---|
2482 | 2538 | clear_bit(NFS4CLNT_BIND_CONN_TO_SESSION, &clp->cl_state); |
---|
2483 | 2539 | switch (ret) { |
---|
2484 | 2540 | case 0: |
---|
.. | .. |
---|
2494 | 2550 | } |
---|
2495 | 2551 | return 0; |
---|
2496 | 2552 | } |
---|
| 2553 | + |
---|
| 2554 | +static void nfs4_layoutreturn_any_run(struct nfs_client *clp) |
---|
| 2555 | +{ |
---|
| 2556 | + int iomode = 0; |
---|
| 2557 | + |
---|
| 2558 | + if (test_and_clear_bit(NFS4CLNT_RECALL_ANY_LAYOUT_READ, &clp->cl_state)) |
---|
| 2559 | + iomode += IOMODE_READ; |
---|
| 2560 | + if (test_and_clear_bit(NFS4CLNT_RECALL_ANY_LAYOUT_RW, &clp->cl_state)) |
---|
| 2561 | + iomode += IOMODE_RW; |
---|
| 2562 | + /* Note: IOMODE_READ + IOMODE_RW == IOMODE_ANY */ |
---|
| 2563 | + if (iomode) { |
---|
| 2564 | + pnfs_layout_return_unused_byclid(clp, iomode); |
---|
| 2565 | + set_bit(NFS4CLNT_RUN_MANAGER, &clp->cl_state); |
---|
| 2566 | + } |
---|
| 2567 | +} |
---|
2497 | 2568 | #else /* CONFIG_NFS_V4_1 */ |
---|
2498 | 2569 | static int nfs4_reset_session(struct nfs_client *clp) { return 0; } |
---|
2499 | 2570 | |
---|
.. | .. |
---|
2501 | 2572 | { |
---|
2502 | 2573 | return 0; |
---|
2503 | 2574 | } |
---|
| 2575 | + |
---|
| 2576 | +static void nfs4_layoutreturn_any_run(struct nfs_client *clp) |
---|
| 2577 | +{ |
---|
| 2578 | +} |
---|
2504 | 2579 | #endif /* CONFIG_NFS_V4_1 */ |
---|
2505 | 2580 | |
---|
2506 | 2581 | static void nfs4_state_manager(struct nfs_client *clp) |
---|
2507 | 2582 | { |
---|
| 2583 | + unsigned int memflags; |
---|
2508 | 2584 | int status = 0; |
---|
2509 | 2585 | const char *section = "", *section_sep = ""; |
---|
2510 | 2586 | |
---|
| 2587 | + /* |
---|
| 2588 | + * State recovery can deadlock if the direct reclaim code tries |
---|
| 2589 | + * start NFS writeback. So ensure memory allocations are all |
---|
| 2590 | + * GFP_NOFS. |
---|
| 2591 | + */ |
---|
| 2592 | + memflags = memalloc_nofs_save(); |
---|
| 2593 | + |
---|
2511 | 2594 | /* Ensure exclusive access to NFSv4 state */ |
---|
2512 | 2595 | do { |
---|
| 2596 | + trace_nfs4_state_mgr(clp); |
---|
2513 | 2597 | clear_bit(NFS4CLNT_RUN_MANAGER, &clp->cl_state); |
---|
2514 | 2598 | if (test_bit(NFS4CLNT_PURGE_STATE, &clp->cl_state)) { |
---|
2515 | 2599 | section = "purge state"; |
---|
.. | .. |
---|
2580 | 2664 | if (status < 0) |
---|
2581 | 2665 | goto out_error; |
---|
2582 | 2666 | nfs4_state_end_reclaim_reboot(clp); |
---|
| 2667 | + continue; |
---|
2583 | 2668 | } |
---|
2584 | 2669 | |
---|
2585 | 2670 | /* Detect expired delegations... */ |
---|
.. | .. |
---|
2590 | 2675 | } |
---|
2591 | 2676 | |
---|
2592 | 2677 | /* Now recover expired state... */ |
---|
2593 | | - if (test_and_clear_bit(NFS4CLNT_RECLAIM_NOGRACE, &clp->cl_state)) { |
---|
| 2678 | + if (test_bit(NFS4CLNT_RECLAIM_NOGRACE, &clp->cl_state)) { |
---|
2594 | 2679 | section = "reclaim nograce"; |
---|
2595 | 2680 | status = nfs4_do_reclaim(clp, |
---|
2596 | 2681 | clp->cl_mvops->nograce_recovery_ops); |
---|
.. | .. |
---|
2598 | 2683 | continue; |
---|
2599 | 2684 | if (status < 0) |
---|
2600 | 2685 | goto out_error; |
---|
| 2686 | + clear_bit(NFS4CLNT_RECLAIM_NOGRACE, &clp->cl_state); |
---|
2601 | 2687 | } |
---|
2602 | 2688 | |
---|
| 2689 | + memalloc_nofs_restore(memflags); |
---|
2603 | 2690 | nfs4_end_drain_session(clp); |
---|
2604 | 2691 | nfs4_clear_state_manager_bit(clp); |
---|
2605 | 2692 | |
---|
2606 | | - if (!test_and_set_bit(NFS4CLNT_DELEGRETURN_RUNNING, &clp->cl_state)) { |
---|
| 2693 | + if (test_bit(NFS4CLNT_RUN_MANAGER, &clp->cl_state) && |
---|
| 2694 | + !test_and_set_bit(NFS4CLNT_MANAGER_RUNNING, |
---|
| 2695 | + &clp->cl_state)) { |
---|
| 2696 | + memflags = memalloc_nofs_save(); |
---|
| 2697 | + continue; |
---|
| 2698 | + } |
---|
| 2699 | + |
---|
| 2700 | + if (!test_and_set_bit(NFS4CLNT_RECALL_RUNNING, &clp->cl_state)) { |
---|
2607 | 2701 | if (test_and_clear_bit(NFS4CLNT_DELEGRETURN, &clp->cl_state)) { |
---|
2608 | 2702 | nfs_client_return_marked_delegations(clp); |
---|
2609 | 2703 | set_bit(NFS4CLNT_RUN_MANAGER, &clp->cl_state); |
---|
2610 | 2704 | } |
---|
2611 | | - clear_bit(NFS4CLNT_DELEGRETURN_RUNNING, &clp->cl_state); |
---|
| 2705 | + nfs4_layoutreturn_any_run(clp); |
---|
| 2706 | + clear_bit(NFS4CLNT_RECALL_RUNNING, &clp->cl_state); |
---|
2612 | 2707 | } |
---|
2613 | 2708 | |
---|
2614 | | - /* Did we race with an attempt to give us more work? */ |
---|
2615 | | - if (!test_bit(NFS4CLNT_RUN_MANAGER, &clp->cl_state)) |
---|
2616 | | - return; |
---|
2617 | | - if (test_and_set_bit(NFS4CLNT_MANAGER_RUNNING, &clp->cl_state) != 0) |
---|
2618 | | - return; |
---|
| 2709 | + return; |
---|
| 2710 | + |
---|
2619 | 2711 | } while (refcount_read(&clp->cl_count) > 1 && !signalled()); |
---|
2620 | 2712 | goto out_drain; |
---|
2621 | 2713 | |
---|
2622 | 2714 | out_error: |
---|
2623 | 2715 | if (strlen(section)) |
---|
2624 | 2716 | section_sep = ": "; |
---|
| 2717 | + trace_nfs4_state_mgr_failed(clp, section, status); |
---|
2625 | 2718 | pr_warn_ratelimited("NFS: state manager%s%s failed on NFSv4 server %s" |
---|
2626 | 2719 | " with error %d\n", section_sep, section, |
---|
2627 | 2720 | clp->cl_hostname, -status); |
---|
2628 | 2721 | ssleep(1); |
---|
2629 | 2722 | out_drain: |
---|
| 2723 | + memalloc_nofs_restore(memflags); |
---|
2630 | 2724 | nfs4_end_drain_session(clp); |
---|
2631 | 2725 | nfs4_clear_state_manager_bit(clp); |
---|
2632 | 2726 | } |
---|
.. | .. |
---|
2634 | 2728 | static int nfs4_run_state_manager(void *ptr) |
---|
2635 | 2729 | { |
---|
2636 | 2730 | struct nfs_client *clp = ptr; |
---|
| 2731 | + struct rpc_clnt *cl = clp->cl_rpcclient; |
---|
| 2732 | + |
---|
| 2733 | + while (cl != cl->cl_parent) |
---|
| 2734 | + cl = cl->cl_parent; |
---|
2637 | 2735 | |
---|
2638 | 2736 | allow_signal(SIGKILL); |
---|
| 2737 | +again: |
---|
2639 | 2738 | nfs4_state_manager(clp); |
---|
| 2739 | + |
---|
| 2740 | + if (test_bit(NFS4CLNT_MANAGER_AVAILABLE, &clp->cl_state) && |
---|
| 2741 | + !test_bit(NFS4CLNT_MANAGER_RUNNING, &clp->cl_state)) { |
---|
| 2742 | + wait_var_event_interruptible(&clp->cl_state, |
---|
| 2743 | + test_bit(NFS4CLNT_RUN_MANAGER, |
---|
| 2744 | + &clp->cl_state)); |
---|
| 2745 | + if (!atomic_read(&cl->cl_swapper)) |
---|
| 2746 | + clear_bit(NFS4CLNT_MANAGER_AVAILABLE, &clp->cl_state); |
---|
| 2747 | + if (refcount_read(&clp->cl_count) > 1 && !signalled() && |
---|
| 2748 | + !test_and_set_bit(NFS4CLNT_MANAGER_RUNNING, &clp->cl_state)) |
---|
| 2749 | + goto again; |
---|
| 2750 | + /* Either no longer a swapper, or were signalled */ |
---|
| 2751 | + clear_bit(NFS4CLNT_MANAGER_AVAILABLE, &clp->cl_state); |
---|
| 2752 | + } |
---|
| 2753 | + |
---|
| 2754 | + if (refcount_read(&clp->cl_count) > 1 && !signalled() && |
---|
| 2755 | + test_bit(NFS4CLNT_RUN_MANAGER, &clp->cl_state) && |
---|
| 2756 | + !test_and_set_bit(NFS4CLNT_MANAGER_RUNNING, &clp->cl_state)) |
---|
| 2757 | + goto again; |
---|
| 2758 | + |
---|
2640 | 2759 | nfs_put_client(clp); |
---|
2641 | 2760 | module_put_and_exit(0); |
---|
2642 | 2761 | return 0; |
---|