@@ -56,10 +56,10 @@ struct ptlrpc_connect_async_args {
56
56
57
57
/**
58
58
* Updates import \a imp current state to provided \a state value
59
- * Helper function. Must be called under imp_lock.
59
+ * Helper function.
60
60
*/
61
- static void __import_set_state (struct obd_import * imp ,
62
- enum lustre_imp_state state )
61
+ static void import_set_state_nolock (struct obd_import * imp ,
62
+ enum lustre_imp_state state )
63
63
{
64
64
switch (state ) {
65
65
case LUSTRE_IMP_CLOSED :
@@ -72,7 +72,20 @@ static void __import_set_state(struct obd_import *imp,
72
72
break ;
73
73
default :
74
74
imp -> imp_replay_state = LUSTRE_IMP_REPLAY ;
75
+ break ;
76
+ }
77
+
78
+ /* A CLOSED import should remain so. */
79
+ if (state == LUSTRE_IMP_CLOSED )
80
+ return ;
81
+
82
+ if (imp -> imp_state != LUSTRE_IMP_NEW ) {
83
+ CDEBUG (D_HA , "%p %s: changing import state from %s to %s\n" ,
84
+ imp , obd2cli_tgt (imp -> imp_obd ),
85
+ ptlrpc_import_state_name (imp -> imp_state ),
86
+ ptlrpc_import_state_name (state ));
75
87
}
88
+
76
89
imp -> imp_state = state ;
77
90
imp -> imp_state_hist [imp -> imp_state_hist_idx ].ish_state = state ;
78
91
imp -> imp_state_hist [imp -> imp_state_hist_idx ].ish_time =
@@ -81,28 +94,17 @@ static void __import_set_state(struct obd_import *imp,
81
94
IMP_STATE_HIST_LEN ;
82
95
}
83
96
84
- /* A CLOSED import should remain so. */
85
- #define IMPORT_SET_STATE_NOLOCK (imp , state ) \
86
- do { \
87
- if (imp->imp_state != LUSTRE_IMP_CLOSED) { \
88
- CDEBUG(D_HA, "%p %s: changing import state from %s to %s\n", \
89
- imp, obd2cli_tgt(imp->imp_obd), \
90
- ptlrpc_import_state_name(imp->imp_state), \
91
- ptlrpc_import_state_name(state)); \
92
- __import_set_state(imp, state); \
93
- } \
94
- } while(0)
95
-
96
- #define IMPORT_SET_STATE (imp , state ) \
97
- do { \
98
- spin_lock(&imp->imp_lock); \
99
- IMPORT_SET_STATE_NOLOCK(imp, state); \
100
- spin_unlock(&imp->imp_lock); \
101
- } while(0)
97
+ static void import_set_state (struct obd_import * imp ,
98
+ enum lustre_imp_state new_state )
99
+ {
100
+ spin_lock (& imp -> imp_lock );
101
+ import_set_state_nolock (imp , new_state );
102
+ spin_unlock (& imp -> imp_lock );
103
+ }
102
104
103
105
void ptlrpc_import_enter_resend (struct obd_import * imp )
104
106
{
105
- IMPORT_SET_STATE (imp , LUSTRE_IMP_RECOVER );
107
+ import_set_state (imp , LUSTRE_IMP_RECOVER );
106
108
}
107
109
EXPORT_SYMBOL (ptlrpc_import_enter_resend );
108
110
@@ -184,7 +186,7 @@ int ptlrpc_set_import_discon(struct obd_import *imp, __u32 conn_cnt)
184
186
imp -> imp_obd -> obd_name , target_len , target_start ,
185
187
obd_import_nid2str (imp ));
186
188
}
187
- IMPORT_SET_STATE_NOLOCK (imp , LUSTRE_IMP_DISCON );
189
+ import_set_state_nolock (imp , LUSTRE_IMP_DISCON );
188
190
spin_unlock (& imp -> imp_lock );
189
191
190
192
if (obd_dump_on_timeout )
@@ -682,7 +684,7 @@ int ptlrpc_connect_import(struct obd_import *imp)
682
684
RETURN (- EALREADY );
683
685
}
684
686
685
- IMPORT_SET_STATE_NOLOCK (imp , LUSTRE_IMP_CONNECTING );
687
+ import_set_state_nolock (imp , LUSTRE_IMP_CONNECTING );
686
688
687
689
imp -> imp_conn_cnt ++ ;
688
690
imp -> imp_resend_replay = 0 ;
@@ -789,7 +791,7 @@ int ptlrpc_connect_import(struct obd_import *imp)
789
791
rc = 0 ;
790
792
out :
791
793
if (rc != 0 )
792
- IMPORT_SET_STATE (imp , LUSTRE_IMP_DISCON );
794
+ import_set_state (imp , LUSTRE_IMP_DISCON );
793
795
794
796
RETURN (rc );
795
797
}
@@ -1154,9 +1156,9 @@ static int ptlrpc_connect_interpret(const struct lu_env *env,
1154
1156
if (msg_flags & MSG_CONNECT_RECOVERING ) {
1155
1157
CDEBUG (D_HA , "connect to %s during recovery\n" ,
1156
1158
obd2cli_tgt (imp -> imp_obd ));
1157
- IMPORT_SET_STATE (imp , LUSTRE_IMP_REPLAY_LOCKS );
1159
+ import_set_state (imp , LUSTRE_IMP_REPLAY_LOCKS );
1158
1160
} else {
1159
- IMPORT_SET_STATE (imp , LUSTRE_IMP_FULL );
1161
+ import_set_state (imp , LUSTRE_IMP_FULL );
1160
1162
ptlrpc_activate_import (imp );
1161
1163
}
1162
1164
@@ -1215,7 +1217,7 @@ static int ptlrpc_connect_interpret(const struct lu_env *env,
1215
1217
* lustre_msg_get_handle (request -> rq_repmsg );
1216
1218
1217
1219
if (!(MSG_CONNECT_RECOVERING & msg_flags )) {
1218
- IMPORT_SET_STATE (imp , LUSTRE_IMP_EVICTED );
1220
+ import_set_state (imp , LUSTRE_IMP_EVICTED );
1219
1221
GOTO (finish , rc = 0 );
1220
1222
}
1221
1223
@@ -1228,7 +1230,7 @@ static int ptlrpc_connect_interpret(const struct lu_env *env,
1228
1230
if (imp -> imp_invalid ) {
1229
1231
CDEBUG (D_HA , "%s: reconnected but import is invalid; "
1230
1232
"marking evicted\n" , imp -> imp_obd -> obd_name );
1231
- IMPORT_SET_STATE (imp , LUSTRE_IMP_EVICTED );
1233
+ import_set_state (imp , LUSTRE_IMP_EVICTED );
1232
1234
} else if (MSG_CONNECT_RECOVERING & msg_flags ) {
1233
1235
CDEBUG (D_HA , "%s: reconnected to %s during replay\n" ,
1234
1236
imp -> imp_obd -> obd_name ,
@@ -1238,17 +1240,17 @@ static int ptlrpc_connect_interpret(const struct lu_env *env,
1238
1240
imp -> imp_resend_replay = 1 ;
1239
1241
spin_unlock (& imp -> imp_lock );
1240
1242
1241
- IMPORT_SET_STATE (imp , imp -> imp_replay_state );
1243
+ import_set_state (imp , imp -> imp_replay_state );
1242
1244
} else {
1243
- IMPORT_SET_STATE (imp , LUSTRE_IMP_RECOVER );
1245
+ import_set_state (imp , LUSTRE_IMP_RECOVER );
1244
1246
}
1245
1247
} else if ((MSG_CONNECT_RECOVERING & msg_flags ) && !imp -> imp_invalid ) {
1246
1248
LASSERT (imp -> imp_replayable );
1247
1249
imp -> imp_remote_handle =
1248
1250
* lustre_msg_get_handle (request -> rq_repmsg );
1249
1251
imp -> imp_last_replay_transno = 0 ;
1250
1252
imp -> imp_replay_cursor = & imp -> imp_committed_list ;
1251
- IMPORT_SET_STATE (imp , LUSTRE_IMP_REPLAY );
1253
+ import_set_state (imp , LUSTRE_IMP_REPLAY );
1252
1254
} else if ((ocd -> ocd_connect_flags & OBD_CONNECT_LIGHTWEIGHT ) != 0 &&
1253
1255
!imp -> imp_invalid ) {
1254
1256
@@ -1257,13 +1259,13 @@ static int ptlrpc_connect_interpret(const struct lu_env *env,
1257
1259
imp -> imp_obd -> obd_name );
1258
1260
imp -> imp_remote_handle =
1259
1261
* lustre_msg_get_handle (request -> rq_repmsg );
1260
- IMPORT_SET_STATE (imp , LUSTRE_IMP_RECOVER );
1262
+ import_set_state (imp , LUSTRE_IMP_RECOVER );
1261
1263
} else {
1262
1264
DEBUG_REQ (D_HA , request , "%s: evicting (reconnect/recover flags"
1263
1265
" not set: %x)" , imp -> imp_obd -> obd_name , msg_flags );
1264
1266
imp -> imp_remote_handle =
1265
1267
* lustre_msg_get_handle (request -> rq_repmsg );
1266
- IMPORT_SET_STATE (imp , LUSTRE_IMP_EVICTED );
1268
+ import_set_state (imp , LUSTRE_IMP_EVICTED );
1267
1269
}
1268
1270
1269
1271
/* Sanity checks for a reconnected import. */
@@ -1309,7 +1311,7 @@ static int ptlrpc_connect_interpret(const struct lu_env *env,
1309
1311
class_export_put (exp );
1310
1312
1311
1313
if (rc != 0 ) {
1312
- IMPORT_SET_STATE (imp , LUSTRE_IMP_DISCON );
1314
+ import_set_state (imp , LUSTRE_IMP_DISCON );
1313
1315
if (rc == - EACCES ) {
1314
1316
/*
1315
1317
* Give up trying to reconnect
@@ -1347,7 +1349,7 @@ static int ptlrpc_connect_interpret(const struct lu_env *env,
1347
1349
OBD_OCD_VERSION_FIX (ocd -> ocd_version ),
1348
1350
LUSTRE_VERSION_STRING );
1349
1351
ptlrpc_deactivate_import (imp );
1350
- IMPORT_SET_STATE (imp , LUSTRE_IMP_CLOSED );
1352
+ import_set_state (imp , LUSTRE_IMP_CLOSED );
1351
1353
}
1352
1354
RETURN (- EPROTO );
1353
1355
}
@@ -1450,7 +1452,7 @@ static int ptlrpc_invalidate_import_thread(void *data)
1450
1452
libcfs_debug_dumplog ();
1451
1453
}
1452
1454
1453
- IMPORT_SET_STATE (imp , LUSTRE_IMP_RECOVER );
1455
+ import_set_state (imp , LUSTRE_IMP_RECOVER );
1454
1456
ptlrpc_import_recovery_state_machine (imp );
1455
1457
1456
1458
class_import_put (imp );
@@ -1532,7 +1534,7 @@ int ptlrpc_import_recovery_state_machine(struct obd_import *imp)
1532
1534
rc = ptlrpc_replay_next (imp , & inflight );
1533
1535
if (inflight == 0 &&
1534
1536
atomic_read (& imp -> imp_replay_inflight ) == 0 ) {
1535
- IMPORT_SET_STATE (imp , LUSTRE_IMP_REPLAY_LOCKS );
1537
+ import_set_state (imp , LUSTRE_IMP_REPLAY_LOCKS );
1536
1538
rc = ldlm_replay_locks (imp );
1537
1539
if (rc )
1538
1540
GOTO (out , rc );
@@ -1542,7 +1544,7 @@ int ptlrpc_import_recovery_state_machine(struct obd_import *imp)
1542
1544
1543
1545
if (imp -> imp_state == LUSTRE_IMP_REPLAY_LOCKS ) {
1544
1546
if (atomic_read (& imp -> imp_replay_inflight ) == 0 ) {
1545
- IMPORT_SET_STATE (imp , LUSTRE_IMP_REPLAY_WAIT );
1547
+ import_set_state (imp , LUSTRE_IMP_REPLAY_WAIT );
1546
1548
rc = signal_completed_replay (imp );
1547
1549
if (rc )
1548
1550
GOTO (out , rc );
@@ -1551,7 +1553,7 @@ int ptlrpc_import_recovery_state_machine(struct obd_import *imp)
1551
1553
1552
1554
if (imp -> imp_state == LUSTRE_IMP_REPLAY_WAIT ) {
1553
1555
if (atomic_read (& imp -> imp_replay_inflight ) == 0 ) {
1554
- IMPORT_SET_STATE (imp , LUSTRE_IMP_RECOVER );
1556
+ import_set_state (imp , LUSTRE_IMP_RECOVER );
1555
1557
}
1556
1558
}
1557
1559
@@ -1561,7 +1563,7 @@ int ptlrpc_import_recovery_state_machine(struct obd_import *imp)
1561
1563
rc = ptlrpc_resend (imp );
1562
1564
if (rc )
1563
1565
GOTO (out , rc );
1564
- IMPORT_SET_STATE (imp , LUSTRE_IMP_FULL );
1566
+ import_set_state (imp , LUSTRE_IMP_FULL );
1565
1567
ptlrpc_activate_import (imp );
1566
1568
1567
1569
LCONSOLE_INFO ("%s: Connection restored to %s (at %s)\n" ,
@@ -1619,7 +1621,7 @@ static struct ptlrpc_request *ptlrpc_disconnect_prep_req(struct obd_import *imp)
1619
1621
req -> rq_timeout = min_t (int , req -> rq_timeout ,
1620
1622
INITIAL_CONNECT_TIMEOUT );
1621
1623
1622
- IMPORT_SET_STATE (imp , LUSTRE_IMP_CONNECTING );
1624
+ import_set_state (imp , LUSTRE_IMP_CONNECTING );
1623
1625
req -> rq_send_state = LUSTRE_IMP_CONNECTING ;
1624
1626
ptlrpc_request_set_replen (req );
1625
1627
@@ -1683,9 +1685,9 @@ int ptlrpc_disconnect_import(struct obd_import *imp, int noclose)
1683
1685
spin_lock (& imp -> imp_lock );
1684
1686
out :
1685
1687
if (noclose )
1686
- IMPORT_SET_STATE_NOLOCK (imp , LUSTRE_IMP_DISCON );
1688
+ import_set_state_nolock (imp , LUSTRE_IMP_DISCON );
1687
1689
else
1688
- IMPORT_SET_STATE_NOLOCK (imp , LUSTRE_IMP_CLOSED );
1690
+ import_set_state_nolock (imp , LUSTRE_IMP_CLOSED );
1689
1691
memset (& imp -> imp_remote_handle , 0 , sizeof (imp -> imp_remote_handle ));
1690
1692
spin_unlock (& imp -> imp_lock );
1691
1693
@@ -1736,7 +1738,7 @@ static int ptlrpc_disconnect_idle_interpret(const struct lu_env *env,
1736
1738
if (atomic_read (& imp -> imp_inflight ) > 1 ) {
1737
1739
imp -> imp_generation ++ ;
1738
1740
imp -> imp_initiated_at = imp -> imp_generation ;
1739
- IMPORT_SET_STATE_NOLOCK (imp , LUSTRE_IMP_NEW );
1741
+ import_set_state_nolock (imp , LUSTRE_IMP_NEW );
1740
1742
ptlrpc_reset_reqs_generation (imp );
1741
1743
connect = 1 ;
1742
1744
}
@@ -1789,7 +1791,7 @@ void ptlrpc_cleanup_imp(struct obd_import *imp)
1789
1791
ENTRY ;
1790
1792
1791
1793
spin_lock (& imp -> imp_lock );
1792
- IMPORT_SET_STATE_NOLOCK (imp , LUSTRE_IMP_CLOSED );
1794
+ import_set_state_nolock (imp , LUSTRE_IMP_CLOSED );
1793
1795
imp -> imp_generation ++ ;
1794
1796
spin_unlock (& imp -> imp_lock );
1795
1797
ptlrpc_abort_inflight (imp );
0 commit comments