forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-09 95099d4622f8cb224d94e314c7a8e0df60b13f87
kernel/fs/nfs/nfs4state.c
....@@ -49,6 +49,7 @@
4949 #include <linux/workqueue.h>
5050 #include <linux/bitops.h>
5151 #include <linux/jiffies.h>
52
+#include <linux/sched/mm.h>
5253
5354 #include <linux/sunrpc/clnt.h>
5455
....@@ -60,6 +61,7 @@
6061 #include "nfs4session.h"
6162 #include "pnfs.h"
6263 #include "netns.h"
64
+#include "nfs4trace.h"
6365
6466 #define NFSDBG_FACILITY NFSDBG_STATE
6567
....@@ -87,7 +89,26 @@
8789
8890 static DEFINE_MUTEX(nfs_clid_init_mutex);
8991
90
-int nfs4_init_clientid(struct nfs_client *clp, struct rpc_cred *cred)
92
+static int nfs4_setup_state_renewal(struct nfs_client *clp)
93
+{
94
+ int status;
95
+ struct nfs_fsinfo fsinfo;
96
+
97
+ if (!test_bit(NFS_CS_CHECK_LEASE_TIME, &clp->cl_res_state)) {
98
+ nfs4_schedule_state_renewal(clp);
99
+ return 0;
100
+ }
101
+
102
+ status = nfs4_proc_get_lease_time(clp, &fsinfo);
103
+ if (status == 0) {
104
+ nfs4_set_lease_period(clp, fsinfo.lease_time * HZ);
105
+ nfs4_schedule_state_renewal(clp);
106
+ }
107
+
108
+ return status;
109
+}
110
+
111
+int nfs4_init_clientid(struct nfs_client *clp, const struct cred *cred)
91112 {
92113 struct nfs4_setclientid_res clid = {
93114 .clientid = clp->cl_clientid,
....@@ -114,7 +135,7 @@
114135 if (status != 0)
115136 goto out;
116137 clear_bit(NFS4CLNT_LEASE_CONFIRM, &clp->cl_state);
117
- nfs4_schedule_state_renewal(clp);
138
+ nfs4_setup_state_renewal(clp);
118139 out:
119140 return status;
120141 }
....@@ -134,7 +155,7 @@
134155 */
135156 int nfs40_discover_server_trunking(struct nfs_client *clp,
136157 struct nfs_client **result,
137
- struct rpc_cred *cred)
158
+ const struct cred *cred)
138159 {
139160 struct nfs4_setclientid_res clid = {
140161 .clientid = clp->cl_clientid,
....@@ -168,32 +189,23 @@
168189 return status;
169190 }
170191
171
-struct rpc_cred *nfs4_get_machine_cred_locked(struct nfs_client *clp)
192
+const struct cred *nfs4_get_machine_cred(struct nfs_client *clp)
172193 {
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;
194
+ return get_cred(rpc_machine_cred());
178195 }
179196
180197 static void nfs4_root_machine_cred(struct nfs_client *clp)
181198 {
182
- struct rpc_cred *cred, *new;
183199
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);
200
+ /* Force root creds instead of machine */
201
+ clp->cl_principal = NULL;
202
+ clp->cl_rpcclient->cl_principal = NULL;
191203 }
192204
193
-static struct rpc_cred *
205
+static const struct cred *
194206 nfs4_get_renew_cred_server_locked(struct nfs_server *server)
195207 {
196
- struct rpc_cred *cred = NULL;
208
+ const struct cred *cred = NULL;
197209 struct nfs4_state_owner *sp;
198210 struct rb_node *pos;
199211
....@@ -203,29 +215,30 @@
203215 sp = rb_entry(pos, struct nfs4_state_owner, so_server_node);
204216 if (list_empty(&sp->so_states))
205217 continue;
206
- cred = get_rpccred(sp->so_cred);
218
+ cred = get_cred(sp->so_cred);
207219 break;
208220 }
209221 return cred;
210222 }
211223
212224 /**
213
- * nfs4_get_renew_cred_locked - Acquire credential for a renew operation
225
+ * nfs4_get_renew_cred - Acquire credential for a renew operation
214226 * @clp: client state handle
215227 *
216228 * Returns an rpc_cred with reference count bumped, or NULL.
217229 * Caller must hold clp->cl_lock.
218230 */
219
-struct rpc_cred *nfs4_get_renew_cred_locked(struct nfs_client *clp)
231
+const struct cred *nfs4_get_renew_cred(struct nfs_client *clp)
220232 {
221
- struct rpc_cred *cred = NULL;
233
+ const struct cred *cred = NULL;
222234 struct nfs_server *server;
223235
224236 /* Use machine credentials if available */
225
- cred = nfs4_get_machine_cred_locked(clp);
237
+ cred = nfs4_get_machine_cred(clp);
226238 if (cred != NULL)
227239 goto out;
228240
241
+ spin_lock(&clp->cl_lock);
229242 rcu_read_lock();
230243 list_for_each_entry_rcu(server, &clp->cl_superblocks, client_link) {
231244 cred = nfs4_get_renew_cred_server_locked(server);
....@@ -233,6 +246,7 @@
233246 break;
234247 }
235248 rcu_read_unlock();
249
+ spin_unlock(&clp->cl_lock);
236250
237251 out:
238252 return cred;
....@@ -293,37 +307,16 @@
293307
294308 #if defined(CONFIG_NFS_V4_1)
295309
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
-
317310 static void nfs41_finish_session_reset(struct nfs_client *clp)
318311 {
319312 clear_bit(NFS4CLNT_LEASE_CONFIRM, &clp->cl_state);
320313 clear_bit(NFS4CLNT_SESSION_RESET, &clp->cl_state);
321314 /* create_session negotiated new slot table */
322315 clear_bit(NFS4CLNT_BIND_CONN_TO_SESSION, &clp->cl_state);
323
- nfs41_setup_state_renewal(clp);
316
+ nfs4_setup_state_renewal(clp);
324317 }
325318
326
-int nfs41_init_clientid(struct nfs_client *clp, struct rpc_cred *cred)
319
+int nfs41_init_clientid(struct nfs_client *clp, const struct cred *cred)
327320 {
328321 int status;
329322
....@@ -358,7 +351,7 @@
358351 */
359352 int nfs41_discover_server_trunking(struct nfs_client *clp,
360353 struct nfs_client **result,
361
- struct rpc_cred *cred)
354
+ const struct cred *cred)
362355 {
363356 int status;
364357
....@@ -396,32 +389,32 @@
396389 * nfs4_get_clid_cred - Acquire credential for a setclientid operation
397390 * @clp: client state handle
398391 *
399
- * Returns an rpc_cred with reference count bumped, or NULL.
392
+ * Returns a cred with reference count bumped, or NULL.
400393 */
401
-struct rpc_cred *nfs4_get_clid_cred(struct nfs_client *clp)
394
+const struct cred *nfs4_get_clid_cred(struct nfs_client *clp)
402395 {
403
- struct rpc_cred *cred;
396
+ const struct cred *cred;
404397
405
- spin_lock(&clp->cl_lock);
406
- cred = nfs4_get_machine_cred_locked(clp);
407
- spin_unlock(&clp->cl_lock);
398
+ cred = nfs4_get_machine_cred(clp);
408399 return cred;
409400 }
410401
411402 static struct nfs4_state_owner *
412
-nfs4_find_state_owner_locked(struct nfs_server *server, struct rpc_cred *cred)
403
+nfs4_find_state_owner_locked(struct nfs_server *server, const struct cred *cred)
413404 {
414405 struct rb_node **p = &server->state_owners.rb_node,
415406 *parent = NULL;
416407 struct nfs4_state_owner *sp;
408
+ int cmp;
417409
418410 while (*p != NULL) {
419411 parent = *p;
420412 sp = rb_entry(parent, struct nfs4_state_owner, so_server_node);
413
+ cmp = cred_fscmp(cred, sp->so_cred);
421414
422
- if (cred < sp->so_cred)
415
+ if (cmp < 0)
423416 p = &parent->rb_left;
424
- else if (cred > sp->so_cred)
417
+ else if (cmp > 0)
425418 p = &parent->rb_right;
426419 else {
427420 if (!list_empty(&sp->so_lru))
....@@ -440,14 +433,16 @@
440433 struct rb_node **p = &server->state_owners.rb_node,
441434 *parent = NULL;
442435 struct nfs4_state_owner *sp;
436
+ int cmp;
443437
444438 while (*p != NULL) {
445439 parent = *p;
446440 sp = rb_entry(parent, struct nfs4_state_owner, so_server_node);
441
+ cmp = cred_fscmp(new->so_cred, sp->so_cred);
447442
448
- if (new->so_cred < sp->so_cred)
443
+ if (cmp < 0)
449444 p = &parent->rb_left;
450
- else if (new->so_cred > sp->so_cred)
445
+ else if (cmp > 0)
451446 p = &parent->rb_right;
452447 else {
453448 if (!list_empty(&sp->so_lru))
....@@ -494,7 +489,7 @@
494489 */
495490 static struct nfs4_state_owner *
496491 nfs4_alloc_state_owner(struct nfs_server *server,
497
- struct rpc_cred *cred,
492
+ const struct cred *cred,
498493 gfp_t gfp_flags)
499494 {
500495 struct nfs4_state_owner *sp;
....@@ -509,13 +504,13 @@
509504 return NULL;
510505 }
511506 sp->so_server = server;
512
- sp->so_cred = get_rpccred(cred);
507
+ sp->so_cred = get_cred(cred);
513508 spin_lock_init(&sp->so_lock);
514509 INIT_LIST_HEAD(&sp->so_states);
515510 nfs4_init_seqid_counter(&sp->so_seqid);
516511 atomic_set(&sp->so_count, 1);
517512 INIT_LIST_HEAD(&sp->so_lru);
518
- seqcount_init(&sp->so_reclaim_seqcount);
513
+ seqcount_spinlock_init(&sp->so_reclaim_seqcount, &sp->so_lock);
519514 mutex_init(&sp->so_delegreturn_mutex);
520515 return sp;
521516 }
....@@ -538,7 +533,7 @@
538533 static void nfs4_free_state_owner(struct nfs4_state_owner *sp)
539534 {
540535 nfs4_destroy_seqid_counter(&sp->so_seqid);
541
- put_rpccred(sp->so_cred);
536
+ put_cred(sp->so_cred);
542537 ida_simple_remove(&sp->so_server->openowner_id, sp->so_seqid.owner_id);
543538 kfree(sp);
544539 }
....@@ -572,11 +567,12 @@
572567 * nfs4_get_state_owner - Look up a state owner given a credential
573568 * @server: nfs_server to search
574569 * @cred: RPC credential to match
570
+ * @gfp_flags: allocation mode
575571 *
576572 * Returns a pointer to an instantiated nfs4_state_owner struct, or NULL.
577573 */
578574 struct nfs4_state_owner *nfs4_get_state_owner(struct nfs_server *server,
579
- struct rpc_cred *cred,
575
+ const struct cred *cred,
580576 gfp_t gfp_flags)
581577 {
582578 struct nfs_client *clp = server->nfs_client;
....@@ -674,7 +670,7 @@
674670 state = kzalloc(sizeof(*state), GFP_NOFS);
675671 if (!state)
676672 return NULL;
677
- atomic_set(&state->count, 1);
673
+ refcount_set(&state->count, 1);
678674 INIT_LIST_HEAD(&state->lock_states);
679675 spin_lock_init(&state->state_lock);
680676 seqlock_init(&state->seqlock);
....@@ -703,12 +699,12 @@
703699 struct nfs_inode *nfsi = NFS_I(inode);
704700 struct nfs4_state *state;
705701
706
- list_for_each_entry(state, &nfsi->open_states, inode_states) {
702
+ list_for_each_entry_rcu(state, &nfsi->open_states, inode_states) {
707703 if (state->owner != owner)
708704 continue;
709705 if (!nfs4_valid_open_stateid(state))
710706 continue;
711
- if (atomic_inc_not_zero(&state->count))
707
+ if (refcount_inc_not_zero(&state->count))
712708 return state;
713709 }
714710 return NULL;
....@@ -717,7 +713,7 @@
717713 static void
718714 nfs4_free_open_state(struct nfs4_state *state)
719715 {
720
- kfree(state);
716
+ kfree_rcu(state, rcu_head);
721717 }
722718
723719 struct nfs4_state *
....@@ -726,9 +722,9 @@
726722 struct nfs4_state *state, *new;
727723 struct nfs_inode *nfsi = NFS_I(inode);
728724
729
- spin_lock(&inode->i_lock);
725
+ rcu_read_lock();
730726 state = __nfs4_find_state_byowner(inode, owner);
731
- spin_unlock(&inode->i_lock);
727
+ rcu_read_unlock();
732728 if (state)
733729 goto out;
734730 new = nfs4_alloc_open_state();
....@@ -739,9 +735,9 @@
739735 state = new;
740736 state->owner = owner;
741737 atomic_inc(&owner->so_count);
742
- list_add(&state->inode_states, &nfsi->open_states);
743738 ihold(inode);
744739 state->inode = inode;
740
+ list_add_rcu(&state->inode_states, &nfsi->open_states);
745741 spin_unlock(&inode->i_lock);
746742 /* Note: The reclaim code dictates that we add stateless
747743 * and read-only stateids to the end of the list */
....@@ -762,13 +758,14 @@
762758 struct inode *inode = state->inode;
763759 struct nfs4_state_owner *owner = state->owner;
764760
765
- if (!atomic_dec_and_lock(&state->count, &owner->so_lock))
761
+ if (!refcount_dec_and_lock(&state->count, &owner->so_lock))
766762 return;
767763 spin_lock(&inode->i_lock);
768
- list_del(&state->inode_states);
764
+ list_del_rcu(&state->inode_states);
769765 list_del(&state->open_states);
770766 spin_unlock(&inode->i_lock);
771767 spin_unlock(&owner->so_lock);
768
+ nfs4_inode_return_delegation_on_close(inode);
772769 iput(inode);
773770 nfs4_free_open_state(state);
774771 nfs4_put_state_owner(owner);
....@@ -1019,22 +1016,6 @@
10191016 return ret;
10201017 }
10211018
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
-
10381019 bool nfs4_copy_open_stateid(nfs4_stateid *dst, struct nfs4_state *state)
10391020 {
10401021 bool ret;
....@@ -1060,7 +1041,7 @@
10601041 */
10611042 int nfs4_select_rw_stateid(struct nfs4_state *state,
10621043 fmode_t fmode, const struct nfs_lock_context *l_ctx,
1063
- nfs4_stateid *dst, struct rpc_cred **cred)
1044
+ nfs4_stateid *dst, const struct cred **cred)
10641045 {
10651046 int ret;
10661047
....@@ -1083,8 +1064,7 @@
10831064 * choose to use.
10841065 */
10851066 goto out;
1086
- nfs4_copy_open_stateid(dst, state);
1087
- ret = 0;
1067
+ ret = nfs4_copy_open_stateid(dst, state) ? 0 : -EAGAIN;
10881068 out:
10891069 if (nfs_server_capable(state->inode, NFS_CAP_STATEID_NFSV41))
10901070 dst->seqid = 0;
....@@ -1155,7 +1135,7 @@
11551135 case -NFS4ERR_MOVED:
11561136 /* Non-seqid mutating errors */
11571137 return;
1158
- };
1138
+ }
11591139 /*
11601140 * Note: no locking needed as we are guaranteed to be first
11611141 * on the sequence list
....@@ -1428,7 +1408,7 @@
14281408 list_for_each_entry(pos, &state->lock_states, ls_locks) {
14291409 if (!test_bit(NFS_LOCK_INITIALIZED, &pos->ls_flags))
14301410 continue;
1431
- if (nfs4_stateid_match_other(&pos->ls_stateid, stateid))
1411
+ if (nfs4_stateid_match_or_older(&pos->ls_stateid, stateid))
14321412 return pos;
14331413 }
14341414 return NULL;
....@@ -1457,17 +1437,18 @@
14571437 struct nfs4_state *state;
14581438 bool found = false;
14591439
1460
- spin_lock(&inode->i_lock);
1461
- list_for_each_entry(ctx, &nfsi->open_files, list) {
1440
+ rcu_read_lock();
1441
+ list_for_each_entry_rcu(ctx, &nfsi->open_files, list) {
14621442 state = ctx->state;
14631443 if (state == NULL)
14641444 continue;
1465
- if (nfs4_stateid_match_other(&state->stateid, stateid) &&
1445
+ if (nfs4_stateid_match_or_older(&state->stateid, stateid) &&
14661446 nfs4_state_mark_reclaim_nograce(clp, state)) {
14671447 found = true;
14681448 continue;
14691449 }
1470
- if (nfs4_stateid_match_other(&state->open_stateid, stateid) &&
1450
+ if (test_bit(NFS_OPEN_STATE, &state->flags) &&
1451
+ nfs4_stateid_match_or_older(&state->open_stateid, stateid) &&
14711452 nfs4_state_mark_reclaim_nograce(clp, state)) {
14721453 found = true;
14731454 continue;
....@@ -1476,32 +1457,34 @@
14761457 nfs4_state_mark_reclaim_nograce(clp, state))
14771458 found = true;
14781459 }
1479
- spin_unlock(&inode->i_lock);
1460
+ rcu_read_unlock();
14801461
14811462 nfs_inode_find_delegation_state_and_recover(inode, stateid);
14821463 if (found)
14831464 nfs4_schedule_state_manager(clp);
14841465 }
14851466
1486
-static void nfs4_state_mark_open_context_bad(struct nfs4_state *state)
1467
+static void nfs4_state_mark_open_context_bad(struct nfs4_state *state, int err)
14871468 {
14881469 struct inode *inode = state->inode;
14891470 struct nfs_inode *nfsi = NFS_I(inode);
14901471 struct nfs_open_context *ctx;
14911472
1492
- spin_lock(&inode->i_lock);
1493
- list_for_each_entry(ctx, &nfsi->open_files, list) {
1473
+ rcu_read_lock();
1474
+ list_for_each_entry_rcu(ctx, &nfsi->open_files, list) {
14941475 if (ctx->state != state)
14951476 continue;
14961477 set_bit(NFS_CONTEXT_BAD, &ctx->flags);
1478
+ pr_warn("NFSv4: state recovery failed for open file %pd2, "
1479
+ "error = %d\n", ctx->dentry, err);
14971480 }
1498
- spin_unlock(&inode->i_lock);
1481
+ rcu_read_unlock();
14991482 }
15001483
15011484 static void nfs4_state_mark_recovery_failed(struct nfs4_state *state, int error)
15021485 {
15031486 set_bit(NFS_STATE_RECOVERY_FAILED, &state->flags);
1504
- nfs4_state_mark_open_context_bad(state);
1487
+ nfs4_state_mark_open_context_bad(state, error);
15051488 }
15061489
15071490
....@@ -1532,6 +1515,7 @@
15321515 switch (status) {
15331516 case 0:
15341517 break;
1518
+ case -ETIMEDOUT:
15351519 case -ESTALE:
15361520 case -NFS4ERR_ADMIN_REVOKED:
15371521 case -NFS4ERR_STALE_STATEID:
....@@ -1547,7 +1531,7 @@
15471531 default:
15481532 pr_err("NFS: %s: unhandled error %d\n",
15491533 __func__, status);
1550
- /* Fall through */
1534
+ fallthrough;
15511535 case -ENOMEM:
15521536 case -NFS4ERR_DENIED:
15531537 case -NFS4ERR_RECLAIM_BAD:
....@@ -1569,11 +1553,84 @@
15691553 return status;
15701554 }
15711555
1556
+#ifdef CONFIG_NFS_V4_2
1557
+static void nfs42_complete_copies(struct nfs4_state_owner *sp, struct nfs4_state *state)
1558
+{
1559
+ struct nfs4_copy_state *copy;
1560
+
1561
+ if (!test_bit(NFS_CLNT_DST_SSC_COPY_STATE, &state->flags) &&
1562
+ !test_bit(NFS_CLNT_SRC_SSC_COPY_STATE, &state->flags))
1563
+ return;
1564
+
1565
+ spin_lock(&sp->so_server->nfs_client->cl_lock);
1566
+ list_for_each_entry(copy, &sp->so_server->ss_copies, copies) {
1567
+ if ((test_bit(NFS_CLNT_DST_SSC_COPY_STATE, &state->flags) &&
1568
+ !nfs4_stateid_match_other(&state->stateid,
1569
+ &copy->parent_dst_state->stateid)))
1570
+ continue;
1571
+ copy->flags = 1;
1572
+ if (test_and_clear_bit(NFS_CLNT_DST_SSC_COPY_STATE,
1573
+ &state->flags)) {
1574
+ clear_bit(NFS_CLNT_SRC_SSC_COPY_STATE, &state->flags);
1575
+ complete(&copy->completion);
1576
+ }
1577
+ }
1578
+ list_for_each_entry(copy, &sp->so_server->ss_copies, src_copies) {
1579
+ if ((test_bit(NFS_CLNT_SRC_SSC_COPY_STATE, &state->flags) &&
1580
+ !nfs4_stateid_match_other(&state->stateid,
1581
+ &copy->parent_src_state->stateid)))
1582
+ continue;
1583
+ copy->flags = 1;
1584
+ if (test_and_clear_bit(NFS_CLNT_DST_SSC_COPY_STATE,
1585
+ &state->flags))
1586
+ complete(&copy->completion);
1587
+ }
1588
+ spin_unlock(&sp->so_server->nfs_client->cl_lock);
1589
+}
1590
+#else /* !CONFIG_NFS_V4_2 */
1591
+static inline void nfs42_complete_copies(struct nfs4_state_owner *sp,
1592
+ struct nfs4_state *state)
1593
+{
1594
+}
1595
+#endif /* CONFIG_NFS_V4_2 */
1596
+
1597
+static int __nfs4_reclaim_open_state(struct nfs4_state_owner *sp, struct nfs4_state *state,
1598
+ const struct nfs4_state_recovery_ops *ops)
1599
+{
1600
+ struct nfs4_lock_state *lock;
1601
+ int status;
1602
+
1603
+ status = ops->recover_open(sp, state);
1604
+ if (status < 0)
1605
+ return status;
1606
+
1607
+ status = nfs4_reclaim_locks(state, ops);
1608
+ if (status < 0)
1609
+ return status;
1610
+
1611
+ if (!test_bit(NFS_DELEGATED_STATE, &state->flags)) {
1612
+ spin_lock(&state->state_lock);
1613
+ list_for_each_entry(lock, &state->lock_states, ls_locks) {
1614
+ trace_nfs4_state_lock_reclaim(state, lock);
1615
+ if (!test_bit(NFS_LOCK_INITIALIZED, &lock->ls_flags))
1616
+ pr_warn_ratelimited("NFS: %s: Lock reclaim failed!\n", __func__);
1617
+ }
1618
+ spin_unlock(&state->state_lock);
1619
+ }
1620
+
1621
+ nfs42_complete_copies(sp, state);
1622
+ clear_bit(NFS_STATE_RECLAIM_NOGRACE, &state->flags);
1623
+ return status;
1624
+}
1625
+
15721626 static int nfs4_reclaim_open_state(struct nfs4_state_owner *sp, const struct nfs4_state_recovery_ops *ops)
15731627 {
15741628 struct nfs4_state *state;
1575
- struct nfs4_lock_state *lock;
1629
+ unsigned int loop = 0;
15761630 int status = 0;
1631
+#ifdef CONFIG_NFS_V4_2
1632
+ bool found_ssc_copy_state = false;
1633
+#endif /* CONFIG_NFS_V4_2 */
15771634
15781635 /* Note: we rely on the sp->so_states list being ordered
15791636 * so that we always reclaim open(O_RDWR) and/or open(O_WRITE)
....@@ -1593,79 +1650,60 @@
15931650 continue;
15941651 if (state->state == 0)
15951652 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);
16141653 #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, &copy->parent_state->stateid.other, NFS4_STATEID_SIZE))
1621
- continue;
1622
- copy->flags = 1;
1623
- complete(&copy->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
- }
1654
+ if (test_bit(NFS_SRV_SSC_COPY_STATE, &state->flags)) {
1655
+ nfs4_state_mark_recovery_failed(state, -EIO);
1656
+ found_ssc_copy_state = true;
1657
+ continue;
16341658 }
1659
+#endif /* CONFIG_NFS_V4_2 */
1660
+ refcount_inc(&state->count);
1661
+ spin_unlock(&sp->so_lock);
1662
+ status = __nfs4_reclaim_open_state(sp, state, ops);
1663
+
16351664 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);
1665
+ default:
1666
+ if (status >= 0) {
1667
+ loop = 0;
16481668 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);
1669
+ }
1670
+ printk(KERN_ERR "NFS: %s: unhandled error %d\n", __func__, status);
1671
+ fallthrough;
1672
+ case -ENOENT:
1673
+ case -ENOMEM:
1674
+ case -EACCES:
1675
+ case -EROFS:
1676
+ case -EIO:
1677
+ case -ESTALE:
1678
+ /* Open state on this file cannot be recovered */
1679
+ nfs4_state_mark_recovery_failed(state, status);
1680
+ break;
1681
+ case -EAGAIN:
1682
+ ssleep(1);
1683
+ if (loop++ < 10) {
1684
+ set_bit(ops->state_flag_bit, &state->flags);
16591685 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;
1686
+ }
1687
+ fallthrough;
1688
+ case -NFS4ERR_ADMIN_REVOKED:
1689
+ case -NFS4ERR_STALE_STATEID:
1690
+ case -NFS4ERR_OLD_STATEID:
1691
+ case -NFS4ERR_BAD_STATEID:
1692
+ case -NFS4ERR_RECLAIM_BAD:
1693
+ case -NFS4ERR_RECLAIM_CONFLICT:
1694
+ nfs4_state_mark_reclaim_nograce(sp->so_server->nfs_client, state);
1695
+ break;
1696
+ case -NFS4ERR_EXPIRED:
1697
+ case -NFS4ERR_NO_GRACE:
1698
+ nfs4_state_mark_reclaim_nograce(sp->so_server->nfs_client, state);
1699
+ fallthrough;
1700
+ case -NFS4ERR_STALE_CLIENTID:
1701
+ case -NFS4ERR_BADSESSION:
1702
+ case -NFS4ERR_BADSLOT:
1703
+ case -NFS4ERR_BAD_HIGH_SLOT:
1704
+ case -NFS4ERR_CONN_NOT_BOUND_TO_SESSION:
1705
+ case -ETIMEDOUT:
1706
+ goto out_err;
16691707 }
16701708 nfs4_put_open_state(state);
16711709 spin_lock(&sp->so_lock);
....@@ -1673,6 +1711,10 @@
16731711 }
16741712 raw_write_seqcount_end(&sp->so_reclaim_seqcount);
16751713 spin_unlock(&sp->so_lock);
1714
+#ifdef CONFIG_NFS_V4_2
1715
+ if (found_ssc_copy_state)
1716
+ return -EIO;
1717
+#endif /* CONFIG_NFS_V4_2 */
16761718 return 0;
16771719 out_err:
16781720 nfs4_put_open_state(state);
....@@ -1735,6 +1777,7 @@
17351777
17361778 static void nfs4_state_start_reclaim_reboot(struct nfs_client *clp)
17371779 {
1780
+ set_bit(NFS4CLNT_RECLAIM_REBOOT, &clp->cl_state);
17381781 /* Mark all delegations for reclaim */
17391782 nfs_delegation_mark_reclaim(clp);
17401783 nfs4_state_mark_reclaim_helper(clp, nfs4_state_mark_reclaim_reboot);
....@@ -1742,7 +1785,7 @@
17421785
17431786 static int nfs4_reclaim_complete(struct nfs_client *clp,
17441787 const struct nfs4_state_recovery_ops *ops,
1745
- struct rpc_cred *cred)
1788
+ const struct cred *cred)
17461789 {
17471790 /* Notify the server we're done reclaiming our state */
17481791 if (ops->reclaim_complete)
....@@ -1793,7 +1836,7 @@
17931836 static void nfs4_state_end_reclaim_reboot(struct nfs_client *clp)
17941837 {
17951838 const struct nfs4_state_recovery_ops *ops;
1796
- struct rpc_cred *cred;
1839
+ const struct cred *cred;
17971840 int err;
17981841
17991842 if (!nfs4_state_clear_reclaim_reboot(clp))
....@@ -1801,7 +1844,7 @@
18011844 ops = clp->cl_mvops->reboot_recovery_ops;
18021845 cred = nfs4_get_clid_cred(clp);
18031846 err = nfs4_reclaim_complete(clp, ops, cred);
1804
- put_rpccred(cred);
1847
+ put_cred(cred);
18051848 if (err == -NFS4ERR_CONN_NOT_BOUND_TO_SESSION)
18061849 set_bit(NFS4CLNT_RECLAIM_REBOOT, &clp->cl_state);
18071850 }
....@@ -1815,38 +1858,38 @@
18151858 static int nfs4_recovery_handle_error(struct nfs_client *clp, int error)
18161859 {
18171860 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;
1861
+ case 0:
1862
+ break;
1863
+ case -NFS4ERR_CB_PATH_DOWN:
1864
+ nfs40_handle_cb_pathdown(clp);
1865
+ break;
1866
+ case -NFS4ERR_NO_GRACE:
1867
+ nfs4_state_end_reclaim_reboot(clp);
1868
+ break;
1869
+ case -NFS4ERR_STALE_CLIENTID:
1870
+ set_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state);
1871
+ nfs4_state_start_reclaim_reboot(clp);
1872
+ break;
1873
+ case -NFS4ERR_EXPIRED:
1874
+ set_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state);
1875
+ nfs4_state_start_reclaim_nograce(clp);
1876
+ break;
1877
+ case -NFS4ERR_BADSESSION:
1878
+ case -NFS4ERR_BADSLOT:
1879
+ case -NFS4ERR_BAD_HIGH_SLOT:
1880
+ case -NFS4ERR_DEADSESSION:
1881
+ case -NFS4ERR_SEQ_FALSE_RETRY:
1882
+ case -NFS4ERR_SEQ_MISORDERED:
1883
+ set_bit(NFS4CLNT_SESSION_RESET, &clp->cl_state);
1884
+ /* Zero session reset errors */
1885
+ break;
1886
+ case -NFS4ERR_CONN_NOT_BOUND_TO_SESSION:
1887
+ set_bit(NFS4CLNT_BIND_CONN_TO_SESSION, &clp->cl_state);
1888
+ break;
1889
+ default:
1890
+ dprintk("%s: failed to handle error %d for server %s\n",
1891
+ __func__, error, clp->cl_hostname);
1892
+ return error;
18501893 }
18511894 dprintk("%s: handled error %d for server %s\n", __func__, error,
18521895 clp->cl_hostname);
....@@ -1899,7 +1942,7 @@
18991942
19001943 static int nfs4_check_lease(struct nfs_client *clp)
19011944 {
1902
- struct rpc_cred *cred;
1945
+ const struct cred *cred;
19031946 const struct nfs4_state_maintenance_ops *ops =
19041947 clp->cl_mvops->state_renewal_ops;
19051948 int status;
....@@ -1907,9 +1950,7 @@
19071950 /* Is the client already known to have an expired lease? */
19081951 if (test_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state))
19091952 return 0;
1910
- spin_lock(&clp->cl_lock);
1911
- cred = ops->get_state_renewal_cred_locked(clp);
1912
- spin_unlock(&clp->cl_lock);
1953
+ cred = ops->get_state_renewal_cred(clp);
19131954 if (cred == NULL) {
19141955 cred = nfs4_get_clid_cred(clp);
19151956 status = -ENOKEY;
....@@ -1917,7 +1958,7 @@
19171958 goto out;
19181959 }
19191960 status = ops->renew_lease(clp, cred);
1920
- put_rpccred(cred);
1961
+ put_cred(cred);
19211962 if (status == -ETIMEDOUT) {
19221963 set_bit(NFS4CLNT_CHECK_LEASE, &clp->cl_state);
19231964 return 0;
....@@ -1951,7 +1992,6 @@
19511992 return -EPERM;
19521993 case -EACCES:
19531994 case -NFS4ERR_DELAY:
1954
- case -ETIMEDOUT:
19551995 case -EAGAIN:
19561996 ssleep(1);
19571997 break;
....@@ -1977,7 +2017,7 @@
19772017
19782018 static int nfs4_establish_lease(struct nfs_client *clp)
19792019 {
1980
- struct rpc_cred *cred;
2020
+ const struct cred *cred;
19812021 const struct nfs4_state_recovery_ops *ops =
19822022 clp->cl_mvops->reboot_recovery_ops;
19832023 int status;
....@@ -1989,7 +2029,7 @@
19892029 if (cred == NULL)
19902030 return -ENOENT;
19912031 status = ops->establish_clid(clp, cred);
1992
- put_rpccred(cred);
2032
+ put_cred(cred);
19932033 if (status != 0)
19942034 return status;
19952035 pnfs_destroy_all_layouts(clp);
....@@ -2036,7 +2076,7 @@
20362076 *
20372077 * Returns zero or a negative NFS4ERR status code.
20382078 */
2039
-static int nfs4_try_migration(struct nfs_server *server, struct rpc_cred *cred)
2079
+static int nfs4_try_migration(struct nfs_server *server, const struct cred *cred)
20402080 {
20412081 struct nfs_client *clp = server->nfs_client;
20422082 struct nfs4_fs_locations *locations = NULL;
....@@ -2076,8 +2116,10 @@
20762116 }
20772117
20782118 status = nfs4_begin_drain_session(clp);
2079
- if (status != 0)
2080
- return status;
2119
+ if (status != 0) {
2120
+ result = status;
2121
+ goto out;
2122
+ }
20812123
20822124 status = nfs4_replace_transport(server, locations);
20832125 if (status != 0) {
....@@ -2109,14 +2151,12 @@
21092151 const struct nfs4_state_maintenance_ops *ops =
21102152 clp->cl_mvops->state_renewal_ops;
21112153 struct nfs_server *server;
2112
- struct rpc_cred *cred;
2154
+ const struct cred *cred;
21132155
21142156 dprintk("%s: migration reported on \"%s\"\n", __func__,
21152157 clp->cl_hostname);
21162158
2117
- spin_lock(&clp->cl_lock);
2118
- cred = ops->get_state_renewal_cred_locked(clp);
2119
- spin_unlock(&clp->cl_lock);
2159
+ cred = ops->get_state_renewal_cred(clp);
21202160 if (cred == NULL)
21212161 return -NFS4ERR_NOENT;
21222162
....@@ -2137,13 +2177,13 @@
21372177 rcu_read_unlock();
21382178 status = nfs4_try_migration(server, cred);
21392179 if (status < 0) {
2140
- put_rpccred(cred);
2180
+ put_cred(cred);
21412181 return status;
21422182 }
21432183 goto restart;
21442184 }
21452185 rcu_read_unlock();
2146
- put_rpccred(cred);
2186
+ put_cred(cred);
21472187 return 0;
21482188 }
21492189
....@@ -2157,14 +2197,12 @@
21572197 const struct nfs4_state_maintenance_ops *ops =
21582198 clp->cl_mvops->state_renewal_ops;
21592199 struct nfs_server *server;
2160
- struct rpc_cred *cred;
2200
+ const struct cred *cred;
21612201
21622202 dprintk("%s: lease moved reported on \"%s\"\n", __func__,
21632203 clp->cl_hostname);
21642204
2165
- spin_lock(&clp->cl_lock);
2166
- cred = ops->get_state_renewal_cred_locked(clp);
2167
- spin_unlock(&clp->cl_lock);
2205
+ cred = ops->get_state_renewal_cred(clp);
21682206 if (cred == NULL)
21692207 return -NFS4ERR_NOENT;
21702208
....@@ -2192,7 +2230,7 @@
21922230 rcu_read_unlock();
21932231
21942232 out:
2195
- put_rpccred(cred);
2233
+ put_cred(cred);
21962234 return 0;
21972235 }
21982236
....@@ -2215,7 +2253,7 @@
22152253 const struct nfs4_state_recovery_ops *ops =
22162254 clp->cl_mvops->reboot_recovery_ops;
22172255 struct rpc_clnt *clnt;
2218
- struct rpc_cred *cred;
2256
+ const struct cred *cred;
22192257 int i, status;
22202258
22212259 dprintk("NFS: %s: testing '%s'\n", __func__, clp->cl_hostname);
....@@ -2231,7 +2269,7 @@
22312269 goto out_unlock;
22322270
22332271 status = ops->detect_trunking(clp, result, cred);
2234
- put_rpccred(cred);
2272
+ put_cred(cred);
22352273 switch (status) {
22362274 case 0:
22372275 case -EINTR:
....@@ -2240,11 +2278,11 @@
22402278 case -ETIMEDOUT:
22412279 if (clnt->cl_softrtry)
22422280 break;
2243
- /* Fall through */
2281
+ fallthrough;
22442282 case -NFS4ERR_DELAY:
22452283 case -EAGAIN:
22462284 ssleep(1);
2247
- /* Fall through */
2285
+ fallthrough;
22482286 case -NFS4ERR_STALE_CLIENTID:
22492287 dprintk("NFS: %s after status %d, retrying\n",
22502288 __func__, status);
....@@ -2256,7 +2294,7 @@
22562294 }
22572295 if (clnt->cl_auth->au_flavor == RPC_AUTH_UNIX)
22582296 break;
2259
- /* Fall through */
2297
+ fallthrough;
22602298 case -NFS4ERR_CLID_INUSE:
22612299 case -NFS4ERR_WRONGSEC:
22622300 /* No point in retrying if we already used RPC_AUTH_UNIX */
....@@ -2362,8 +2400,7 @@
23622400 {
23632401 /* FIXME: For now, we destroy all layouts. */
23642402 pnfs_destroy_all_layouts(clp);
2365
- /* FIXME: For now, we test all delegations+open state+locks. */
2366
- nfs41_handle_some_state_revoked(clp);
2403
+ nfs_test_expired_all_delegations(clp);
23672404 dprintk("%s: Recallable state revoked on server %s!\n", __func__,
23682405 clp->cl_hostname);
23692406 }
....@@ -2422,7 +2459,7 @@
24222459
24232460 static int nfs4_reset_session(struct nfs_client *clp)
24242461 {
2425
- struct rpc_cred *cred;
2462
+ const struct cred *cred;
24262463 int status;
24272464
24282465 if (!nfs4_has_session(clp))
....@@ -2460,14 +2497,13 @@
24602497 dprintk("%s: session reset was successful for server %s!\n",
24612498 __func__, clp->cl_hostname);
24622499 out:
2463
- if (cred)
2464
- put_rpccred(cred);
2500
+ put_cred(cred);
24652501 return status;
24662502 }
24672503
24682504 static int nfs4_bind_conn_to_session(struct nfs_client *clp)
24692505 {
2470
- struct rpc_cred *cred;
2506
+ const struct cred *cred;
24712507 int ret;
24722508
24732509 if (!nfs4_has_session(clp))
....@@ -2477,8 +2513,7 @@
24772513 return ret;
24782514 cred = nfs4_get_clid_cred(clp);
24792515 ret = nfs4_proc_bind_conn_to_session(clp, cred);
2480
- if (cred)
2481
- put_rpccred(cred);
2516
+ put_cred(cred);
24822517 clear_bit(NFS4CLNT_BIND_CONN_TO_SESSION, &clp->cl_state);
24832518 switch (ret) {
24842519 case 0:
....@@ -2494,6 +2529,21 @@
24942529 }
24952530 return 0;
24962531 }
2532
+
2533
+static void nfs4_layoutreturn_any_run(struct nfs_client *clp)
2534
+{
2535
+ int iomode = 0;
2536
+
2537
+ if (test_and_clear_bit(NFS4CLNT_RECALL_ANY_LAYOUT_READ, &clp->cl_state))
2538
+ iomode += IOMODE_READ;
2539
+ if (test_and_clear_bit(NFS4CLNT_RECALL_ANY_LAYOUT_RW, &clp->cl_state))
2540
+ iomode += IOMODE_RW;
2541
+ /* Note: IOMODE_READ + IOMODE_RW == IOMODE_ANY */
2542
+ if (iomode) {
2543
+ pnfs_layout_return_unused_byclid(clp, iomode);
2544
+ set_bit(NFS4CLNT_RUN_MANAGER, &clp->cl_state);
2545
+ }
2546
+}
24972547 #else /* CONFIG_NFS_V4_1 */
24982548 static int nfs4_reset_session(struct nfs_client *clp) { return 0; }
24992549
....@@ -2501,15 +2551,28 @@
25012551 {
25022552 return 0;
25032553 }
2554
+
2555
+static void nfs4_layoutreturn_any_run(struct nfs_client *clp)
2556
+{
2557
+}
25042558 #endif /* CONFIG_NFS_V4_1 */
25052559
25062560 static void nfs4_state_manager(struct nfs_client *clp)
25072561 {
2562
+ unsigned int memflags;
25082563 int status = 0;
25092564 const char *section = "", *section_sep = "";
25102565
2566
+ /*
2567
+ * State recovery can deadlock if the direct reclaim code tries
2568
+ * start NFS writeback. So ensure memory allocations are all
2569
+ * GFP_NOFS.
2570
+ */
2571
+ memflags = memalloc_nofs_save();
2572
+
25112573 /* Ensure exclusive access to NFSv4 state */
25122574 do {
2575
+ trace_nfs4_state_mgr(clp);
25132576 clear_bit(NFS4CLNT_RUN_MANAGER, &clp->cl_state);
25142577 if (test_bit(NFS4CLNT_PURGE_STATE, &clp->cl_state)) {
25152578 section = "purge state";
....@@ -2580,6 +2643,7 @@
25802643 if (status < 0)
25812644 goto out_error;
25822645 nfs4_state_end_reclaim_reboot(clp);
2646
+ continue;
25832647 }
25842648
25852649 /* Detect expired delegations... */
....@@ -2590,7 +2654,7 @@
25902654 }
25912655
25922656 /* Now recover expired state... */
2593
- if (test_and_clear_bit(NFS4CLNT_RECLAIM_NOGRACE, &clp->cl_state)) {
2657
+ if (test_bit(NFS4CLNT_RECLAIM_NOGRACE, &clp->cl_state)) {
25942658 section = "reclaim nograce";
25952659 status = nfs4_do_reclaim(clp,
25962660 clp->cl_mvops->nograce_recovery_ops);
....@@ -2598,17 +2662,20 @@
25982662 continue;
25992663 if (status < 0)
26002664 goto out_error;
2665
+ clear_bit(NFS4CLNT_RECLAIM_NOGRACE, &clp->cl_state);
26012666 }
26022667
2668
+ memalloc_nofs_restore(memflags);
26032669 nfs4_end_drain_session(clp);
26042670 nfs4_clear_state_manager_bit(clp);
26052671
2606
- if (!test_and_set_bit(NFS4CLNT_DELEGRETURN_RUNNING, &clp->cl_state)) {
2672
+ if (!test_and_set_bit(NFS4CLNT_RECALL_RUNNING, &clp->cl_state)) {
26072673 if (test_and_clear_bit(NFS4CLNT_DELEGRETURN, &clp->cl_state)) {
26082674 nfs_client_return_marked_delegations(clp);
26092675 set_bit(NFS4CLNT_RUN_MANAGER, &clp->cl_state);
26102676 }
2611
- clear_bit(NFS4CLNT_DELEGRETURN_RUNNING, &clp->cl_state);
2677
+ nfs4_layoutreturn_any_run(clp);
2678
+ clear_bit(NFS4CLNT_RECALL_RUNNING, &clp->cl_state);
26122679 }
26132680
26142681 /* Did we race with an attempt to give us more work? */
....@@ -2616,17 +2683,20 @@
26162683 return;
26172684 if (test_and_set_bit(NFS4CLNT_MANAGER_RUNNING, &clp->cl_state) != 0)
26182685 return;
2686
+ memflags = memalloc_nofs_save();
26192687 } while (refcount_read(&clp->cl_count) > 1 && !signalled());
26202688 goto out_drain;
26212689
26222690 out_error:
26232691 if (strlen(section))
26242692 section_sep = ": ";
2693
+ trace_nfs4_state_mgr_failed(clp, section, status);
26252694 pr_warn_ratelimited("NFS: state manager%s%s failed on NFSv4 server %s"
26262695 " with error %d\n", section_sep, section,
26272696 clp->cl_hostname, -status);
26282697 ssleep(1);
26292698 out_drain:
2699
+ memalloc_nofs_restore(memflags);
26302700 nfs4_end_drain_session(clp);
26312701 nfs4_clear_state_manager_bit(clp);
26322702 }