#define LNET_RC_STATE_RUNNING 1 /* started up OK */
#define LNET_RC_STATE_STOPPING 2 /* telling thread to stop */
+/* LNet states */
+#define LNET_STATE_SHUTDOWN 0 /* not started */
+#define LNET_STATE_RUNNING 1 /* started up OK */
+#define LNET_STATE_STOPPING 2 /* telling thread to stop */
+
typedef struct
{
/* CPU partition table of LNet */
int ln_niinit_self;
/* LNetNIInit/LNetNIFini counter */
int ln_refcount;
- /* shutdown in progress */
- int ln_shutdown;
+ /* SHUTDOWN/RUNNING/STOPPING */
+ int ln_state;
int ln_routing; /* am I a router? */
lnet_pid_t ln_pid; /* requested pid */
/* NB called holding the global mutex */
/* All quiet on the API front */
- LASSERT(!the_lnet.ln_shutdown);
+ LASSERT(the_lnet.ln_state == LNET_STATE_RUNNING);
LASSERT(the_lnet.ln_refcount == 0);
lnet_net_lock(LNET_LOCK_EX);
- the_lnet.ln_shutdown = 1; /* flag shutdown */
+ the_lnet.ln_state = LNET_STATE_STOPPING;
while (!list_empty(&the_lnet.ln_nets)) {
/*
}
lnet_net_lock(LNET_LOCK_EX);
- the_lnet.ln_shutdown = 0;
+ the_lnet.ln_state = LNET_STATE_SHUTDOWN;
lnet_net_unlock(LNET_LOCK_EX);
}
int rc;
int ni_count = 0;
+ /*
+ * Change to running state before bringing up the LNDs. This
+ * allows lnet_shutdown_lndnets() to assert that we've passed
+ * through here.
+ */
+ lnet_net_lock(LNET_LOCK_EX);
+ the_lnet.ln_state = LNET_STATE_RUNNING;
+ lnet_net_unlock(LNET_LOCK_EX);
+
while (!list_empty(netlist)) {
net = list_entry(netlist->next, struct lnet_net, net_list);
list_del_init(&net->net_list);
seq = lnet_get_dlc_seq_locked();
- if (the_lnet.ln_shutdown) {
+ if (the_lnet.ln_state != LNET_STATE_RUNNING) {
lnet_net_unlock(cpt);
return -ESHUTDOWN;
}
mtable = lnet_mt_of_match(info, msg);
lnet_res_lock(mtable->mt_cpt);
- if (the_lnet.ln_shutdown) {
+ if (the_lnet.ln_state != LNET_STATE_RUNNING) {
rc = LNET_MATCHMD_DROP;
goto out1;
}
list_move(&msg->msg_list, &zombies);
}
} else {
- if (the_lnet.ln_shutdown)
+ if (the_lnet.ln_state != LNET_STATE_RUNNING)
CWARN("Active lazy portal %d on exit\n", portal);
else
CDEBUG(D_NET, "clearing portal %d lazy\n", portal);
int i;
struct lnet_peer_table *ptable;
- LASSERT(the_lnet.ln_shutdown || net != NULL);
+ LASSERT(the_lnet.ln_state != LNET_STATE_SHUTDOWN || net != NULL);
/* If just deleting the peers for a NI, get rid of any routes these
* peers are gateways for. */
cfs_percpt_for_each(ptable, i, the_lnet.ln_peer_tables) {
struct list_head *peers;
struct lnet_peer_ni *lp;
- LASSERT(!the_lnet.ln_shutdown);
+ LASSERT(the_lnet.ln_state == LNET_STATE_RUNNING);
peers = &ptable->pt_hash[lnet_nid2peerhash(nid)];
list_for_each_entry(lp, peers, lpni_hashlist) {
struct lnet_peer_ni *lpni = NULL;
int rc;
- if (the_lnet.ln_shutdown) /* it's shutting down */
+ if (the_lnet.ln_state != LNET_STATE_RUNNING)
return ERR_PTR(-ESHUTDOWN);
/*
struct lnet_peer_ni *lpni = NULL;
int rc;
- if (the_lnet.ln_shutdown) /* it's shutting down */
+ if (the_lnet.ln_state != LNET_STATE_RUNNING)
return ERR_PTR(-ESHUTDOWN);
/*
* Shutdown is only set under the ln_api_lock, so a single
* check here is sufficent.
*/
- if (the_lnet.ln_shutdown) {
+ if (the_lnet.ln_state != LNET_STATE_RUNNING) {
lpni = ERR_PTR(-ESHUTDOWN);
goto out_mutex_unlock;
}
struct list_head *tmp;
struct list_head *rn_list;
- LASSERT(!the_lnet.ln_shutdown);
+ LASSERT(the_lnet.ln_state == LNET_STATE_RUNNING);
rn_list = lnet_net2rnethash(net);
list_for_each(tmp, rn_list) {
return rc;
}
route->lr_gateway = lpni;
- LASSERT(!the_lnet.ln_shutdown);
+ LASSERT(the_lnet.ln_state == LNET_STATE_RUNNING);
rnet2 = lnet_find_rnet_locked(net);
if (rnet2 == NULL) {
lnet_net_lock(cpt);
- if (the_lnet.ln_shutdown) {
+ if (the_lnet.ln_state != LNET_STATE_RUNNING) {
lnet_net_unlock(cpt);
return -ESHUTDOWN;
}