History

NFSv4/4.1: Fix nfs4_schedule_state_recovery abuses

nfs4_schedule_state_recovery() should only be used when we need to force the state manager to check the lease. If we just want to start the state manager in order to handle a state recovery situation, we should be using nfs4_schedule_state_manager(). This patch fixes the abuses of nfs4_schedule_state_recovery() by replacing its use with a set of helper functions that do the right thing.

Trond Myklebust committed 15 years ago

Commit 0400a6b1 parent c34c32e4 files · +52 −34Browse files

Unified · Split

4 files
  1. fs/nfs/nfs4_fs.h +7 −1
  2. fs/nfs/nfs4proc.c +23 −22
  3. fs/nfs/nfs4state.c +19 −6
  4. include/linux/nfs_fs_sb.h +3 −5
fs/nfs/nfs4_fs.h+7−1
@@ -298,6 +298,11 @@ struct rpc_cred *nfs4_get_renew_cred_locked(struct nfs_client *clp); · 297 unmodified lines
298298 #if defined(CONFIG_NFS_V4_1)
299299 struct rpc_cred *nfs4_get_machine_cred_locked(struct nfs_client *clp);
300300 struct rpc_cred *nfs4_get_exchange_id_cred(struct nfs_client *clp);
301+extern void nfs4_schedule_session_recovery(struct nfs4_session *);
302+#else
303+static inline void nfs4_schedule_session_recovery(struct nfs4_session *session)
304+{
305+}
301306 #endif /* CONFIG_NFS_V4_1 */
302307
303308 extern struct nfs4_state_owner * nfs4_get_state_owner(struct nfs_server *, struct rpc_cred *);
@@ -307,8 +312,9 @@ extern void nfs4_put_open_state(struct nfs4_state *); · 3 unmodified lines
307312 extern void nfs4_close_state(struct path *, struct nfs4_state *, fmode_t);
308313 extern void nfs4_close_sync(struct path *, struct nfs4_state *, fmode_t);
309314 extern void nfs4_state_set_mode_locked(struct nfs4_state *, fmode_t);
310−extern void nfs4_schedule_state_recovery(struct nfs_client *);
315+extern void nfs4_schedule_lease_recovery(struct nfs_client *);
311316 extern void nfs4_schedule_state_manager(struct nfs_client *);
317+extern void nfs4_schedule_stateid_recovery(const struct nfs_server *, struct nfs4_state *);
312318 extern int nfs4_state_mark_reclaim_nograce(struct nfs_client *clp, struct nfs4_state *state);
313319 extern int nfs4_state_mark_reclaim_reboot(struct nfs_client *clp, struct nfs4_state *state);
314320 extern void nfs41_handle_sequence_flag_errors(struct nfs_client *clp, u32 flags);
fs/nfs/nfs4proc.c+23−22
@@ -257,12 +257,13 @@ static int nfs4_handle_exception(const struct nfs_server *server, int errorcode, · 256 unmodified lines
257257 case -NFS4ERR_OPENMODE:
258258 if (state == NULL)
259259 break;
260− nfs4_state_mark_reclaim_nograce(clp, state);
261− goto do_state_recovery;
260+ nfs4_schedule_stateid_recovery(server, state);
261+ goto wait_on_recovery;
262262 case -NFS4ERR_STALE_STATEID:
263263 case -NFS4ERR_STALE_CLIENTID:
264264 case -NFS4ERR_EXPIRED:
265− goto do_state_recovery;
265+ nfs4_schedule_lease_recovery(clp);
266+ goto wait_on_recovery;
266267 #if defined(CONFIG_NFS_V4_1)
267268 case -NFS4ERR_BADSESSION:
268269 case -NFS4ERR_BADSLOT:
@@ -273,7 +274,7 @@ static int nfs4_handle_exception(const struct nfs_server *server, int errorcode, · 4 unmodified lines
273274 case -NFS4ERR_SEQ_MISORDERED:
274275 dprintk("%s ERROR: %d Reset session\n", __func__,
275276 errorcode);
276− nfs4_schedule_state_recovery(clp);
277+ nfs4_schedule_session_recovery(clp->cl_session);
277278 exception->retry = 1;
278279 break;
279280 #endif /* defined(CONFIG_NFS_V4_1) */
@@ -296,8 +297,7 @@ static int nfs4_handle_exception(const struct nfs_server *server, int errorcode, · 16 unmodified lines
296297 }
297298 /* We failed to handle the error */
298299 return nfs4_map_errors(ret);
299−do_state_recovery:
300− nfs4_schedule_state_recovery(clp);
300+wait_on_recovery:
301301 ret = nfs4_wait_clnt_recover(clp);
302302 if (ret == 0)
303303 exception->retry = 1;
@@ -1256,14 +1256,13 @@ int nfs4_open_delegation_recall(struct nfs_open_context *ctx, struct nfs4_state · 952 unmodified lines
12561256 case -NFS4ERR_BAD_HIGH_SLOT:
12571257 case -NFS4ERR_CONN_NOT_BOUND_TO_SESSION:
12581258 case -NFS4ERR_DEADSESSION:
1259− nfs4_schedule_state_recovery(
1260− server->nfs_client);
1259+ nfs4_schedule_session_recovery(server->nfs_client->cl_session);
12611260 goto out;
12621261 case -NFS4ERR_STALE_CLIENTID:
12631262 case -NFS4ERR_STALE_STATEID:
12641263 case -NFS4ERR_EXPIRED:
12651264 /* Don't recall a delegation if it was lost */
1266− nfs4_schedule_state_recovery(server->nfs_client);
1265+ nfs4_schedule_lease_recovery(server->nfs_client);
12671266 goto out;
12681267 case -ERESTARTSYS:
12691268 /*
@@ -1272,7 +1271,7 @@ int nfs4_open_delegation_recall(struct nfs_open_context *ctx, struct nfs4_state · 2 unmodified lines
12721271 */
12731272 case -NFS4ERR_ADMIN_REVOKED:
12741273 case -NFS4ERR_BAD_STATEID:
1275− nfs4_state_mark_reclaim_nograce(server->nfs_client, state);
1274+ nfs4_schedule_stateid_recovery(server, state);
12761275 case -EKEYEXPIRED:
12771276 /*
12781277 * User RPCSEC_GSS context has expired.
@@ -1588,7 +1587,7 @@ static int nfs4_recover_expired_lease(struct nfs_server *server) · 309 unmodified lines
15881587 if (!test_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state) &&
15891588 !test_bit(NFS4CLNT_CHECK_LEASE,&clp->cl_state))
15901589 break;
1591− nfs4_schedule_state_recovery(clp);
1590+ nfs4_schedule_state_manager(clp);
15921591 ret = -EIO;
15931592 }
15941593 return ret;
@@ -3179,7 +3178,7 @@ static void nfs4_renew_done(struct rpc_task *task, void *calldata) · 1584 unmodified lines
31793178 if (task->tk_status < 0) {
31803179 /* Unless we're shutting down, schedule state recovery! */
31813180 if (test_bit(NFS_CS_RENEWD, &clp->cl_res_state) != 0)
3182− nfs4_schedule_state_recovery(clp);
3181+ nfs4_schedule_lease_recovery(clp);
31833182 return;
31843183 }
31853184 do_renew_lease(clp, timestamp);
@@ -3504,12 +3503,13 @@ nfs4_async_handle_error(struct rpc_task *task, const struct nfs_server *server, · 318 unmodified lines
35043503 case -NFS4ERR_OPENMODE:
35053504 if (state == NULL)
35063505 break;
3507− nfs4_state_mark_reclaim_nograce(clp, state);
3508− goto do_state_recovery;
3506+ nfs4_schedule_stateid_recovery(server, state);
3507+ goto wait_on_recovery;
35093508 case -NFS4ERR_STALE_STATEID:
35103509 case -NFS4ERR_STALE_CLIENTID:
35113510 case -NFS4ERR_EXPIRED:
3512− goto do_state_recovery;
3511+ nfs4_schedule_lease_recovery(clp);
3512+ goto wait_on_recovery;
35133513 #if defined(CONFIG_NFS_V4_1)
35143514 case -NFS4ERR_BADSESSION:
35153515 case -NFS4ERR_BADSLOT:
@@ -3520,7 +3520,7 @@ nfs4_async_handle_error(struct rpc_task *task, const struct nfs_server *server, · 4 unmodified lines
35203520 case -NFS4ERR_SEQ_MISORDERED:
35213521 dprintk("%s ERROR %d, Reset session\n", __func__,
35223522 task->tk_status);
3523− nfs4_schedule_state_recovery(clp);
3523+ nfs4_schedule_session_recovery(clp->cl_session);
35243524 task->tk_status = 0;
35253525 return -EAGAIN;
35263526 #endif /* CONFIG_NFS_V4_1 */
@@ -3537,9 +3537,8 @@ nfs4_async_handle_error(struct rpc_task *task, const struct nfs_server *server, · 10 unmodified lines
35373537 }
35383538 task->tk_status = nfs4_map_errors(task->tk_status);
35393539 return 0;
3540−do_state_recovery:
3540+wait_on_recovery:
35413541 rpc_sleep_on(&clp->cl_rpcwaitq, task, NULL);
3542− nfs4_schedule_state_recovery(clp);
35433542 if (test_bit(NFS4CLNT_MANAGER_RUNNING, &clp->cl_state) == 0)
35443543 rpc_wake_up_queued_task(&clp->cl_rpcwaitq, task);
35453544 task->tk_status = 0;
@@ -4406,12 +4405,14 @@ int nfs4_lock_delegation_recall(struct nfs4_state *state, struct file_lock *fl) · 860 unmodified lines
44064405 case -NFS4ERR_EXPIRED:
44074406 case -NFS4ERR_STALE_CLIENTID:
44084407 case -NFS4ERR_STALE_STATEID:
4408+ nfs4_schedule_lease_recovery(server->nfs_client);
4409+ goto out;
44094410 case -NFS4ERR_BADSESSION:
44104411 case -NFS4ERR_BADSLOT:
44114412 case -NFS4ERR_BAD_HIGH_SLOT:
44124413 case -NFS4ERR_CONN_NOT_BOUND_TO_SESSION:
44134414 case -NFS4ERR_DEADSESSION:
4414− nfs4_schedule_state_recovery(server->nfs_client);
4415+ nfs4_schedule_session_recovery(server->nfs_client->cl_session);
44154416 goto out;
44164417 case -ERESTARTSYS:
44174418 /*
@@ -4421,7 +4422,7 @@ int nfs4_lock_delegation_recall(struct nfs4_state *state, struct file_lock *fl) · 3 unmodified lines
44214422 case -NFS4ERR_ADMIN_REVOKED:
44224423 case -NFS4ERR_BAD_STATEID:
44234424 case -NFS4ERR_OPENMODE:
4424− nfs4_state_mark_reclaim_nograce(server->nfs_client, state);
4425+ nfs4_schedule_stateid_recovery(server, state);
44254426 err = 0;
44264427 goto out;
44274428 case -EKEYEXPIRED:
@@ -5150,7 +5151,7 @@ static int nfs41_sequence_handle_errors(struct rpc_task *task, struct nfs_client · 722 unmodified lines
51505151 rpc_delay(task, NFS4_POLL_RETRY_MAX);
51515152 return -EAGAIN;
51525153 default:
5153− nfs4_schedule_state_recovery(clp);
5154+ nfs4_schedule_lease_recovery(clp);
51545155 }
51555156 return 0;
51565157 }
@@ -5291,7 +5292,7 @@ static int nfs41_reclaim_complete_handle_errors(struct rpc_task *task, struct nf · 134 unmodified lines
52915292 rpc_delay(task, NFS4_POLL_RETRY_MAX);
52925293 return -EAGAIN;
52935294 default:
5294− nfs4_schedule_state_recovery(clp);
5295+ nfs4_schedule_lease_recovery(clp);
52955296 }
52965297 return 0;
52975298 }
fs/nfs/nfs4state.c+19−6
@@ -1007,9 +1007,9 @@ void nfs4_schedule_state_manager(struct nfs_client *clp) · 1006 unmodified lines
10071007 }
10081008
10091009 /*
1010− * Schedule a state recovery attempt
1010+ * Schedule a lease recovery attempt
10111011 */
1012−void nfs4_schedule_state_recovery(struct nfs_client *clp)
1012+void nfs4_schedule_lease_recovery(struct nfs_client *clp)
10131013 {
10141014 if (!clp)
10151015 return;
@@ -1041,6 +1041,14 @@ int nfs4_state_mark_reclaim_nograce(struct nfs_client *clp, struct nfs4_state *s · 25 unmodified lines
10411041 return 1;
10421042 }
10431043
1044+void nfs4_schedule_stateid_recovery(const struct nfs_server *server, struct nfs4_state *state)
1045+{
1046+ struct nfs_client *clp = server->nfs_client;
1047+
1048+ nfs4_state_mark_reclaim_nograce(clp, state);
1049+ nfs4_schedule_state_manager(clp);
1050+}
1051+
10441052 static int nfs4_reclaim_locks(struct nfs4_state *state, const struct nfs4_state_recovery_ops *ops)
10451053 {
10461054 struct inode *inode = state->inode;
@@ -1436,10 +1444,15 @@ static int nfs4_reclaim_lease(struct nfs_client *clp) · 389 unmodified lines
14361444 }
14371445
14381446 #ifdef CONFIG_NFS_V4_1
1447+void nfs4_schedule_session_recovery(struct nfs4_session *session)
1448+{
1449+ nfs4_schedule_lease_recovery(session->clp);
1450+}
1451+
14391452 void nfs41_handle_recall_slot(struct nfs_client *clp)
14401453 {
14411454 set_bit(NFS4CLNT_RECALL_SLOT, &clp->cl_state);
1442− nfs4_schedule_state_recovery(clp);
1455+ nfs4_schedule_state_manager(clp);
14431456 }
14441457
14451458 static void nfs4_reset_all_state(struct nfs_client *clp)
@@ -1447,7 +1460,7 @@ static void nfs4_reset_all_state(struct nfs_client *clp) · 1 unmodified line
14471460 if (test_and_set_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state) == 0) {
14481461 clp->cl_boot_time = CURRENT_TIME;
14491462 nfs4_state_start_reclaim_nograce(clp);
1450− nfs4_schedule_state_recovery(clp);
1463+ nfs4_schedule_state_manager(clp);
14511464 }
14521465 }
14531466
@@ -1455,7 +1468,7 @@ static void nfs41_handle_server_reboot(struct nfs_client *clp) · 1 unmodified line
14551468 {
14561469 if (test_and_set_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state) == 0) {
14571470 nfs4_state_start_reclaim_reboot(clp);
1458− nfs4_schedule_state_recovery(clp);
1471+ nfs4_schedule_state_manager(clp);
14591472 }
14601473 }
14611474
@@ -1475,7 +1488,7 @@ static void nfs41_handle_cb_path_down(struct nfs_client *clp) · 13 unmodified lines
14751488 {
14761489 nfs_expire_all_delegations(clp);
14771490 if (test_and_set_bit(NFS4CLNT_SESSION_RESET, &clp->cl_state) == 0)
1478− nfs4_schedule_state_recovery(clp);
1491+ nfs4_schedule_state_manager(clp);
14791492 }
14801493
14811494 void nfs41_handle_sequence_flag_errors(struct nfs_client *clp, u32 flags)
include/linux/nfs_fs_sb.h+3−5
@@ -68,9 +68,7 @@ struct nfs_client { · 67 unmodified lines
6868 unsigned char cl_id_uniquifier;
6969 u32 cl_cb_ident; /* v4.0 callback identifier */
7070 const struct nfs4_minor_version_ops *cl_mvops;
71−#endif /* CONFIG_NFS_V4 */
7271
73−#ifdef CONFIG_NFS_V4_1
7472 /* The sequence id to use for the next CREATE_SESSION */
7573 u32 cl_seqid;
7674 /* The flags used for obtaining the clientid during EXCHANGE_ID */
@@ -78,7 +76,7 @@ struct nfs_client { · 1 unmodified line
7876 struct nfs4_session *cl_session; /* sharred session */
7977 struct list_head cl_layouts;
8078 struct pnfs_deviceid_cache *cl_devid_cache; /* pNFS deviceid cache */
81−#endif /* CONFIG_NFS_V4_1 */
79+#endif /* CONFIG_NFS_V4 */
8280
8381 #ifdef CONFIG_NFS_FSCACHE
8482 struct fscache_cookie *fscache; /* client index cache cookie */
@@ -183,7 +181,7 @@ struct nfs_server { · 98 unmodified lines
183181 /* maximum number of slots to use */
184182 #define NFS4_MAX_SLOT_TABLE RPC_MAX_SLOT_TABLE
185183
186−#if defined(CONFIG_NFS_V4_1)
184+#if defined(CONFIG_NFS_V4)
187185
188186 /* Sessions */
189187 #define SLOT_TABLE_SZ (NFS4_MAX_SLOT_TABLE/(8*sizeof(long)))
@@ -223,5 +221,5 @@ struct nfs4_session { · 33 unmodified lines
223221 struct nfs_client *clp;
224222 };
225223
226−#endif /* CONFIG_NFS_V4_1 */
224+#endif /* CONFIG_NFS_V4 */
227225 #endif