diff options
Diffstat (limited to 'fs/nfs/nfs4state.c')
-rw-r--r-- | fs/nfs/nfs4state.c | 241 |
1 files changed, 170 insertions, 71 deletions
diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c index 2ef4fecf3984..6d263ed79e92 100644 --- a/fs/nfs/nfs4state.c +++ b/fs/nfs/nfs4state.c | |||
@@ -116,6 +116,79 @@ struct rpc_cred *nfs4_get_renew_cred_locked(struct nfs_client *clp) | |||
116 | 116 | ||
117 | #if defined(CONFIG_NFS_V4_1) | 117 | #if defined(CONFIG_NFS_V4_1) |
118 | 118 | ||
119 | static int nfs41_setup_state_renewal(struct nfs_client *clp) | ||
120 | { | ||
121 | int status; | ||
122 | struct nfs_fsinfo fsinfo; | ||
123 | |||
124 | status = nfs4_proc_get_lease_time(clp, &fsinfo); | ||
125 | if (status == 0) { | ||
126 | /* Update lease time and schedule renewal */ | ||
127 | spin_lock(&clp->cl_lock); | ||
128 | clp->cl_lease_time = fsinfo.lease_time * HZ; | ||
129 | clp->cl_last_renewal = jiffies; | ||
130 | spin_unlock(&clp->cl_lock); | ||
131 | |||
132 | nfs4_schedule_state_renewal(clp); | ||
133 | } | ||
134 | |||
135 | return status; | ||
136 | } | ||
137 | |||
138 | static void nfs4_end_drain_session(struct nfs_client *clp) | ||
139 | { | ||
140 | struct nfs4_session *ses = clp->cl_session; | ||
141 | int max_slots; | ||
142 | |||
143 | if (test_and_clear_bit(NFS4CLNT_SESSION_DRAINING, &clp->cl_state)) { | ||
144 | spin_lock(&ses->fc_slot_table.slot_tbl_lock); | ||
145 | max_slots = ses->fc_slot_table.max_slots; | ||
146 | while (max_slots--) { | ||
147 | struct rpc_task *task; | ||
148 | |||
149 | task = rpc_wake_up_next(&ses->fc_slot_table. | ||
150 | slot_tbl_waitq); | ||
151 | if (!task) | ||
152 | break; | ||
153 | rpc_task_set_priority(task, RPC_PRIORITY_PRIVILEGED); | ||
154 | } | ||
155 | spin_unlock(&ses->fc_slot_table.slot_tbl_lock); | ||
156 | } | ||
157 | } | ||
158 | |||
159 | static int nfs4_begin_drain_session(struct nfs_client *clp) | ||
160 | { | ||
161 | struct nfs4_session *ses = clp->cl_session; | ||
162 | struct nfs4_slot_table *tbl = &ses->fc_slot_table; | ||
163 | |||
164 | spin_lock(&tbl->slot_tbl_lock); | ||
165 | set_bit(NFS4CLNT_SESSION_DRAINING, &clp->cl_state); | ||
166 | if (tbl->highest_used_slotid != -1) { | ||
167 | INIT_COMPLETION(ses->complete); | ||
168 | spin_unlock(&tbl->slot_tbl_lock); | ||
169 | return wait_for_completion_interruptible(&ses->complete); | ||
170 | } | ||
171 | spin_unlock(&tbl->slot_tbl_lock); | ||
172 | return 0; | ||
173 | } | ||
174 | |||
175 | int nfs41_init_clientid(struct nfs_client *clp, struct rpc_cred *cred) | ||
176 | { | ||
177 | int status; | ||
178 | |||
179 | nfs4_begin_drain_session(clp); | ||
180 | status = nfs4_proc_exchange_id(clp, cred); | ||
181 | if (status != 0) | ||
182 | goto out; | ||
183 | status = nfs4_proc_create_session(clp); | ||
184 | if (status != 0) | ||
185 | goto out; | ||
186 | nfs41_setup_state_renewal(clp); | ||
187 | nfs_mark_client_ready(clp, NFS_CS_READY); | ||
188 | out: | ||
189 | return status; | ||
190 | } | ||
191 | |||
119 | struct rpc_cred *nfs4_get_exchange_id_cred(struct nfs_client *clp) | 192 | struct rpc_cred *nfs4_get_exchange_id_cred(struct nfs_client *clp) |
120 | { | 193 | { |
121 | struct rpc_cred *cred; | 194 | struct rpc_cred *cred; |
@@ -693,16 +766,21 @@ struct nfs_seqid *nfs_alloc_seqid(struct nfs_seqid_counter *counter) | |||
693 | return new; | 766 | return new; |
694 | } | 767 | } |
695 | 768 | ||
696 | void nfs_free_seqid(struct nfs_seqid *seqid) | 769 | void nfs_release_seqid(struct nfs_seqid *seqid) |
697 | { | 770 | { |
698 | if (!list_empty(&seqid->list)) { | 771 | if (!list_empty(&seqid->list)) { |
699 | struct rpc_sequence *sequence = seqid->sequence->sequence; | 772 | struct rpc_sequence *sequence = seqid->sequence->sequence; |
700 | 773 | ||
701 | spin_lock(&sequence->lock); | 774 | spin_lock(&sequence->lock); |
702 | list_del(&seqid->list); | 775 | list_del_init(&seqid->list); |
703 | spin_unlock(&sequence->lock); | 776 | spin_unlock(&sequence->lock); |
704 | rpc_wake_up(&sequence->wait); | 777 | rpc_wake_up(&sequence->wait); |
705 | } | 778 | } |
779 | } | ||
780 | |||
781 | void nfs_free_seqid(struct nfs_seqid *seqid) | ||
782 | { | ||
783 | nfs_release_seqid(seqid); | ||
706 | kfree(seqid); | 784 | kfree(seqid); |
707 | } | 785 | } |
708 | 786 | ||
@@ -877,6 +955,10 @@ static int nfs4_reclaim_locks(struct nfs4_state *state, const struct nfs4_state_ | |||
877 | case -NFS4ERR_EXPIRED: | 955 | case -NFS4ERR_EXPIRED: |
878 | case -NFS4ERR_NO_GRACE: | 956 | case -NFS4ERR_NO_GRACE: |
879 | case -NFS4ERR_STALE_CLIENTID: | 957 | case -NFS4ERR_STALE_CLIENTID: |
958 | case -NFS4ERR_BADSESSION: | ||
959 | case -NFS4ERR_BADSLOT: | ||
960 | case -NFS4ERR_BAD_HIGH_SLOT: | ||
961 | case -NFS4ERR_CONN_NOT_BOUND_TO_SESSION: | ||
880 | goto out; | 962 | goto out; |
881 | default: | 963 | default: |
882 | printk(KERN_ERR "%s: unhandled error %d. Zeroing state\n", | 964 | printk(KERN_ERR "%s: unhandled error %d. Zeroing state\n", |
@@ -959,6 +1041,10 @@ restart: | |||
959 | case -NFS4ERR_NO_GRACE: | 1041 | case -NFS4ERR_NO_GRACE: |
960 | nfs4_state_mark_reclaim_nograce(sp->so_client, state); | 1042 | nfs4_state_mark_reclaim_nograce(sp->so_client, state); |
961 | case -NFS4ERR_STALE_CLIENTID: | 1043 | case -NFS4ERR_STALE_CLIENTID: |
1044 | case -NFS4ERR_BADSESSION: | ||
1045 | case -NFS4ERR_BADSLOT: | ||
1046 | case -NFS4ERR_BAD_HIGH_SLOT: | ||
1047 | case -NFS4ERR_CONN_NOT_BOUND_TO_SESSION: | ||
962 | goto out_err; | 1048 | goto out_err; |
963 | } | 1049 | } |
964 | nfs4_put_open_state(state); | 1050 | nfs4_put_open_state(state); |
@@ -1011,6 +1097,14 @@ static void nfs4_state_start_reclaim_reboot(struct nfs_client *clp) | |||
1011 | nfs4_state_mark_reclaim_helper(clp, nfs4_state_mark_reclaim_reboot); | 1097 | nfs4_state_mark_reclaim_helper(clp, nfs4_state_mark_reclaim_reboot); |
1012 | } | 1098 | } |
1013 | 1099 | ||
1100 | static void nfs4_reclaim_complete(struct nfs_client *clp, | ||
1101 | const struct nfs4_state_recovery_ops *ops) | ||
1102 | { | ||
1103 | /* Notify the server we're done reclaiming our state */ | ||
1104 | if (ops->reclaim_complete) | ||
1105 | (void)ops->reclaim_complete(clp); | ||
1106 | } | ||
1107 | |||
1014 | static void nfs4_state_end_reclaim_reboot(struct nfs_client *clp) | 1108 | static void nfs4_state_end_reclaim_reboot(struct nfs_client *clp) |
1015 | { | 1109 | { |
1016 | struct nfs4_state_owner *sp; | 1110 | struct nfs4_state_owner *sp; |
@@ -1020,6 +1114,9 @@ static void nfs4_state_end_reclaim_reboot(struct nfs_client *clp) | |||
1020 | if (!test_and_clear_bit(NFS4CLNT_RECLAIM_REBOOT, &clp->cl_state)) | 1114 | if (!test_and_clear_bit(NFS4CLNT_RECLAIM_REBOOT, &clp->cl_state)) |
1021 | return; | 1115 | return; |
1022 | 1116 | ||
1117 | nfs4_reclaim_complete(clp, | ||
1118 | nfs4_reboot_recovery_ops[clp->cl_minorversion]); | ||
1119 | |||
1023 | for (pos = rb_first(&clp->cl_state_owners); pos != NULL; pos = rb_next(pos)) { | 1120 | for (pos = rb_first(&clp->cl_state_owners); pos != NULL; pos = rb_next(pos)) { |
1024 | sp = rb_entry(pos, struct nfs4_state_owner, so_client_node); | 1121 | sp = rb_entry(pos, struct nfs4_state_owner, so_client_node); |
1025 | spin_lock(&sp->so_lock); | 1122 | spin_lock(&sp->so_lock); |
@@ -1046,25 +1143,25 @@ static void nfs4_state_start_reclaim_nograce(struct nfs_client *clp) | |||
1046 | nfs4_state_mark_reclaim_helper(clp, nfs4_state_mark_reclaim_nograce); | 1143 | nfs4_state_mark_reclaim_helper(clp, nfs4_state_mark_reclaim_nograce); |
1047 | } | 1144 | } |
1048 | 1145 | ||
1049 | static void nfs4_state_end_reclaim_nograce(struct nfs_client *clp) | 1146 | static int nfs4_recovery_handle_error(struct nfs_client *clp, int error) |
1050 | { | ||
1051 | clear_bit(NFS4CLNT_RECLAIM_NOGRACE, &clp->cl_state); | ||
1052 | } | ||
1053 | |||
1054 | static void nfs4_recovery_handle_error(struct nfs_client *clp, int error) | ||
1055 | { | 1147 | { |
1056 | switch (error) { | 1148 | switch (error) { |
1057 | case -NFS4ERR_CB_PATH_DOWN: | 1149 | case -NFS4ERR_CB_PATH_DOWN: |
1058 | nfs_handle_cb_pathdown(clp); | 1150 | nfs_handle_cb_pathdown(clp); |
1059 | break; | 1151 | return 0; |
1152 | case -NFS4ERR_NO_GRACE: | ||
1153 | nfs4_state_end_reclaim_reboot(clp); | ||
1154 | return 0; | ||
1060 | case -NFS4ERR_STALE_CLIENTID: | 1155 | case -NFS4ERR_STALE_CLIENTID: |
1061 | case -NFS4ERR_LEASE_MOVED: | 1156 | case -NFS4ERR_LEASE_MOVED: |
1062 | set_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state); | 1157 | set_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state); |
1158 | nfs4_state_end_reclaim_reboot(clp); | ||
1063 | nfs4_state_start_reclaim_reboot(clp); | 1159 | nfs4_state_start_reclaim_reboot(clp); |
1064 | break; | 1160 | break; |
1065 | case -NFS4ERR_EXPIRED: | 1161 | case -NFS4ERR_EXPIRED: |
1066 | set_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state); | 1162 | set_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state); |
1067 | nfs4_state_start_reclaim_nograce(clp); | 1163 | nfs4_state_start_reclaim_nograce(clp); |
1164 | break; | ||
1068 | case -NFS4ERR_BADSESSION: | 1165 | case -NFS4ERR_BADSESSION: |
1069 | case -NFS4ERR_BADSLOT: | 1166 | case -NFS4ERR_BADSLOT: |
1070 | case -NFS4ERR_BAD_HIGH_SLOT: | 1167 | case -NFS4ERR_BAD_HIGH_SLOT: |
@@ -1072,8 +1169,11 @@ static void nfs4_recovery_handle_error(struct nfs_client *clp, int error) | |||
1072 | case -NFS4ERR_CONN_NOT_BOUND_TO_SESSION: | 1169 | case -NFS4ERR_CONN_NOT_BOUND_TO_SESSION: |
1073 | case -NFS4ERR_SEQ_FALSE_RETRY: | 1170 | case -NFS4ERR_SEQ_FALSE_RETRY: |
1074 | case -NFS4ERR_SEQ_MISORDERED: | 1171 | case -NFS4ERR_SEQ_MISORDERED: |
1075 | set_bit(NFS4CLNT_SESSION_SETUP, &clp->cl_state); | 1172 | set_bit(NFS4CLNT_SESSION_RESET, &clp->cl_state); |
1173 | /* Zero session reset errors */ | ||
1174 | return 0; | ||
1076 | } | 1175 | } |
1176 | return error; | ||
1077 | } | 1177 | } |
1078 | 1178 | ||
1079 | static int nfs4_do_reclaim(struct nfs_client *clp, const struct nfs4_state_recovery_ops *ops) | 1179 | static int nfs4_do_reclaim(struct nfs_client *clp, const struct nfs4_state_recovery_ops *ops) |
@@ -1093,8 +1193,7 @@ restart: | |||
1093 | if (status < 0) { | 1193 | if (status < 0) { |
1094 | set_bit(ops->owner_flag_bit, &sp->so_flags); | 1194 | set_bit(ops->owner_flag_bit, &sp->so_flags); |
1095 | nfs4_put_state_owner(sp); | 1195 | nfs4_put_state_owner(sp); |
1096 | nfs4_recovery_handle_error(clp, status); | 1196 | return nfs4_recovery_handle_error(clp, status); |
1097 | return status; | ||
1098 | } | 1197 | } |
1099 | nfs4_put_state_owner(sp); | 1198 | nfs4_put_state_owner(sp); |
1100 | goto restart; | 1199 | goto restart; |
@@ -1124,8 +1223,7 @@ static int nfs4_check_lease(struct nfs_client *clp) | |||
1124 | status = ops->renew_lease(clp, cred); | 1223 | status = ops->renew_lease(clp, cred); |
1125 | put_rpccred(cred); | 1224 | put_rpccred(cred); |
1126 | out: | 1225 | out: |
1127 | nfs4_recovery_handle_error(clp, status); | 1226 | return nfs4_recovery_handle_error(clp, status); |
1128 | return status; | ||
1129 | } | 1227 | } |
1130 | 1228 | ||
1131 | static int nfs4_reclaim_lease(struct nfs_client *clp) | 1229 | static int nfs4_reclaim_lease(struct nfs_client *clp) |
@@ -1151,55 +1249,59 @@ static int nfs4_reclaim_lease(struct nfs_client *clp) | |||
1151 | } | 1249 | } |
1152 | 1250 | ||
1153 | #ifdef CONFIG_NFS_V4_1 | 1251 | #ifdef CONFIG_NFS_V4_1 |
1154 | static void nfs4_session_recovery_handle_error(struct nfs_client *clp, int err) | 1252 | void nfs41_handle_sequence_flag_errors(struct nfs_client *clp, u32 flags) |
1155 | { | 1253 | { |
1156 | switch (err) { | 1254 | if (!flags) |
1157 | case -NFS4ERR_STALE_CLIENTID: | 1255 | return; |
1256 | else if (flags & SEQ4_STATUS_RESTART_RECLAIM_NEEDED) { | ||
1158 | set_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state); | 1257 | set_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state); |
1159 | set_bit(NFS4CLNT_SESSION_SETUP, &clp->cl_state); | 1258 | nfs4_state_start_reclaim_reboot(clp); |
1160 | } | 1259 | nfs4_schedule_state_recovery(clp); |
1260 | } else if (flags & (SEQ4_STATUS_EXPIRED_ALL_STATE_REVOKED | | ||
1261 | SEQ4_STATUS_EXPIRED_SOME_STATE_REVOKED | | ||
1262 | SEQ4_STATUS_ADMIN_STATE_REVOKED | | ||
1263 | SEQ4_STATUS_RECALLABLE_STATE_REVOKED | | ||
1264 | SEQ4_STATUS_LEASE_MOVED)) { | ||
1265 | set_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state); | ||
1266 | nfs4_state_start_reclaim_nograce(clp); | ||
1267 | nfs4_schedule_state_recovery(clp); | ||
1268 | } else if (flags & (SEQ4_STATUS_CB_PATH_DOWN | | ||
1269 | SEQ4_STATUS_BACKCHANNEL_FAULT | | ||
1270 | SEQ4_STATUS_CB_PATH_DOWN_SESSION)) | ||
1271 | nfs_expire_all_delegations(clp); | ||
1161 | } | 1272 | } |
1162 | 1273 | ||
1163 | static int nfs4_reset_session(struct nfs_client *clp) | 1274 | static int nfs4_reset_session(struct nfs_client *clp) |
1164 | { | 1275 | { |
1165 | int status; | 1276 | int status; |
1166 | 1277 | ||
1278 | nfs4_begin_drain_session(clp); | ||
1167 | status = nfs4_proc_destroy_session(clp->cl_session); | 1279 | status = nfs4_proc_destroy_session(clp->cl_session); |
1168 | if (status && status != -NFS4ERR_BADSESSION && | 1280 | if (status && status != -NFS4ERR_BADSESSION && |
1169 | status != -NFS4ERR_DEADSESSION) { | 1281 | status != -NFS4ERR_DEADSESSION) { |
1170 | nfs4_session_recovery_handle_error(clp, status); | 1282 | status = nfs4_recovery_handle_error(clp, status); |
1171 | goto out; | 1283 | goto out; |
1172 | } | 1284 | } |
1173 | 1285 | ||
1174 | memset(clp->cl_session->sess_id.data, 0, NFS4_MAX_SESSIONID_LEN); | 1286 | memset(clp->cl_session->sess_id.data, 0, NFS4_MAX_SESSIONID_LEN); |
1175 | status = nfs4_proc_create_session(clp, 1); | 1287 | status = nfs4_proc_create_session(clp); |
1176 | if (status) | 1288 | if (status) |
1177 | nfs4_session_recovery_handle_error(clp, status); | 1289 | status = nfs4_recovery_handle_error(clp, status); |
1178 | /* fall through*/ | ||
1179 | out: | ||
1180 | /* Wake up the next rpc task even on error */ | ||
1181 | rpc_wake_up_next(&clp->cl_session->fc_slot_table.slot_tbl_waitq); | ||
1182 | return status; | ||
1183 | } | ||
1184 | 1290 | ||
1185 | static int nfs4_initialize_session(struct nfs_client *clp) | 1291 | out: |
1186 | { | 1292 | /* |
1187 | int status; | 1293 | * Let the state manager reestablish state |
1294 | */ | ||
1295 | if (!test_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state) && | ||
1296 | status == 0) | ||
1297 | nfs41_setup_state_renewal(clp); | ||
1188 | 1298 | ||
1189 | status = nfs4_proc_create_session(clp, 0); | ||
1190 | if (!status) { | ||
1191 | nfs_mark_client_ready(clp, NFS_CS_READY); | ||
1192 | } else if (status == -NFS4ERR_STALE_CLIENTID) { | ||
1193 | set_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state); | ||
1194 | set_bit(NFS4CLNT_SESSION_SETUP, &clp->cl_state); | ||
1195 | } else { | ||
1196 | nfs_mark_client_ready(clp, status); | ||
1197 | } | ||
1198 | return status; | 1299 | return status; |
1199 | } | 1300 | } |
1301 | |||
1200 | #else /* CONFIG_NFS_V4_1 */ | 1302 | #else /* CONFIG_NFS_V4_1 */ |
1201 | static int nfs4_reset_session(struct nfs_client *clp) { return 0; } | 1303 | static int nfs4_reset_session(struct nfs_client *clp) { return 0; } |
1202 | static int nfs4_initialize_session(struct nfs_client *clp) { return 0; } | 1304 | static int nfs4_end_drain_session(struct nfs_client *clp) { return 0; } |
1203 | #endif /* CONFIG_NFS_V4_1 */ | 1305 | #endif /* CONFIG_NFS_V4_1 */ |
1204 | 1306 | ||
1205 | /* Set NFS4CLNT_LEASE_EXPIRED for all v4.0 errors and for recoverable errors | 1307 | /* Set NFS4CLNT_LEASE_EXPIRED for all v4.0 errors and for recoverable errors |
@@ -1234,7 +1336,8 @@ static void nfs4_state_manager(struct nfs_client *clp) | |||
1234 | status = nfs4_reclaim_lease(clp); | 1336 | status = nfs4_reclaim_lease(clp); |
1235 | if (status) { | 1337 | if (status) { |
1236 | nfs4_set_lease_expired(clp, status); | 1338 | nfs4_set_lease_expired(clp, status); |
1237 | if (status == -EAGAIN) | 1339 | if (test_bit(NFS4CLNT_LEASE_EXPIRED, |
1340 | &clp->cl_state)) | ||
1238 | continue; | 1341 | continue; |
1239 | if (clp->cl_cons_state == | 1342 | if (clp->cl_cons_state == |
1240 | NFS_CS_SESSION_INITING) | 1343 | NFS_CS_SESSION_INITING) |
@@ -1242,57 +1345,54 @@ static void nfs4_state_manager(struct nfs_client *clp) | |||
1242 | goto out_error; | 1345 | goto out_error; |
1243 | } | 1346 | } |
1244 | clear_bit(NFS4CLNT_CHECK_LEASE, &clp->cl_state); | 1347 | clear_bit(NFS4CLNT_CHECK_LEASE, &clp->cl_state); |
1348 | set_bit(NFS4CLNT_RECLAIM_REBOOT, &clp->cl_state); | ||
1245 | } | 1349 | } |
1246 | 1350 | ||
1247 | if (test_and_clear_bit(NFS4CLNT_CHECK_LEASE, &clp->cl_state)) { | 1351 | if (test_and_clear_bit(NFS4CLNT_CHECK_LEASE, &clp->cl_state)) { |
1248 | status = nfs4_check_lease(clp); | 1352 | status = nfs4_check_lease(clp); |
1249 | if (status != 0) | 1353 | if (test_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state)) |
1250 | continue; | 1354 | continue; |
1355 | if (status < 0 && status != -NFS4ERR_CB_PATH_DOWN) | ||
1356 | goto out_error; | ||
1251 | } | 1357 | } |
1358 | |||
1252 | /* Initialize or reset the session */ | 1359 | /* Initialize or reset the session */ |
1253 | if (test_and_clear_bit(NFS4CLNT_SESSION_SETUP, &clp->cl_state) | 1360 | if (test_and_clear_bit(NFS4CLNT_SESSION_RESET, &clp->cl_state) |
1254 | && nfs4_has_session(clp)) { | 1361 | && nfs4_has_session(clp)) { |
1255 | if (clp->cl_cons_state == NFS_CS_SESSION_INITING) | 1362 | status = nfs4_reset_session(clp); |
1256 | status = nfs4_initialize_session(clp); | 1363 | if (test_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state)) |
1257 | else | 1364 | continue; |
1258 | status = nfs4_reset_session(clp); | 1365 | if (status < 0) |
1259 | if (status) { | ||
1260 | if (status == -NFS4ERR_STALE_CLIENTID) | ||
1261 | continue; | ||
1262 | goto out_error; | 1366 | goto out_error; |
1263 | } | ||
1264 | } | 1367 | } |
1368 | |||
1265 | /* First recover reboot state... */ | 1369 | /* First recover reboot state... */ |
1266 | if (test_and_clear_bit(NFS4CLNT_RECLAIM_REBOOT, &clp->cl_state)) { | 1370 | if (test_bit(NFS4CLNT_RECLAIM_REBOOT, &clp->cl_state)) { |
1267 | status = nfs4_do_reclaim(clp, | 1371 | status = nfs4_do_reclaim(clp, |
1268 | nfs4_reboot_recovery_ops[clp->cl_minorversion]); | 1372 | nfs4_reboot_recovery_ops[clp->cl_minorversion]); |
1269 | if (status == -NFS4ERR_STALE_CLIENTID) | 1373 | if (test_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state) || |
1270 | continue; | 1374 | test_bit(NFS4CLNT_SESSION_RESET, &clp->cl_state)) |
1271 | if (test_bit(NFS4CLNT_SESSION_SETUP, &clp->cl_state)) | ||
1272 | continue; | 1375 | continue; |
1273 | nfs4_state_end_reclaim_reboot(clp); | 1376 | nfs4_state_end_reclaim_reboot(clp); |
1274 | continue; | 1377 | if (test_bit(NFS4CLNT_RECLAIM_NOGRACE, &clp->cl_state)) |
1378 | continue; | ||
1379 | if (status < 0) | ||
1380 | goto out_error; | ||
1275 | } | 1381 | } |
1276 | 1382 | ||
1277 | /* Now recover expired state... */ | 1383 | /* Now recover expired state... */ |
1278 | if (test_and_clear_bit(NFS4CLNT_RECLAIM_NOGRACE, &clp->cl_state)) { | 1384 | if (test_and_clear_bit(NFS4CLNT_RECLAIM_NOGRACE, &clp->cl_state)) { |
1279 | status = nfs4_do_reclaim(clp, | 1385 | status = nfs4_do_reclaim(clp, |
1280 | nfs4_nograce_recovery_ops[clp->cl_minorversion]); | 1386 | nfs4_nograce_recovery_ops[clp->cl_minorversion]); |
1281 | if (status < 0) { | 1387 | if (test_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state) || |
1282 | set_bit(NFS4CLNT_RECLAIM_NOGRACE, &clp->cl_state); | 1388 | test_bit(NFS4CLNT_SESSION_RESET, &clp->cl_state) || |
1283 | if (status == -NFS4ERR_STALE_CLIENTID) | 1389 | test_bit(NFS4CLNT_RECLAIM_REBOOT, &clp->cl_state)) |
1284 | continue; | 1390 | continue; |
1285 | if (status == -NFS4ERR_EXPIRED) | 1391 | if (status < 0) |
1286 | continue; | ||
1287 | if (test_bit(NFS4CLNT_SESSION_SETUP, | ||
1288 | &clp->cl_state)) | ||
1289 | continue; | ||
1290 | goto out_error; | 1392 | goto out_error; |
1291 | } else | ||
1292 | nfs4_state_end_reclaim_nograce(clp); | ||
1293 | continue; | ||
1294 | } | 1393 | } |
1295 | 1394 | ||
1395 | nfs4_end_drain_session(clp); | ||
1296 | if (test_and_clear_bit(NFS4CLNT_DELEGRETURN, &clp->cl_state)) { | 1396 | if (test_and_clear_bit(NFS4CLNT_DELEGRETURN, &clp->cl_state)) { |
1297 | nfs_client_return_marked_delegations(clp); | 1397 | nfs_client_return_marked_delegations(clp); |
1298 | continue; | 1398 | continue; |
@@ -1309,8 +1409,7 @@ static void nfs4_state_manager(struct nfs_client *clp) | |||
1309 | out_error: | 1409 | out_error: |
1310 | printk(KERN_WARNING "Error: state manager failed on NFSv4 server %s" | 1410 | printk(KERN_WARNING "Error: state manager failed on NFSv4 server %s" |
1311 | " with error %d\n", clp->cl_hostname, -status); | 1411 | " with error %d\n", clp->cl_hostname, -status); |
1312 | if (test_bit(NFS4CLNT_RECLAIM_REBOOT, &clp->cl_state)) | 1412 | nfs4_end_drain_session(clp); |
1313 | nfs4_state_end_reclaim_reboot(clp); | ||
1314 | nfs4_clear_state_manager_bit(clp); | 1413 | nfs4_clear_state_manager_bit(clp); |
1315 | } | 1414 | } |
1316 | 1415 | ||