/* 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);
if (rc > 1) {
rc = -EINVAL; /* only add one network per call */
- goto failed;
+ goto out_unlock_clean;
}
net = list_entry(net_head.next, struct lnet_net, net_list);
conf->cfg_config_u.cfg_net.net_max_tx_credits;
rc = lnet_add_net_common(net, &tun);
- if (rc != 0)
- goto failed;
- return 0;
-
-failed:
+out_unlock_clean:
mutex_unlock(&the_lnet.ln_api_mutex);
while (!list_empty(&net_head)) {
+ /* net_head list is empty in success case */
net = list_entry(net_head.next, struct lnet_net, net_list);
list_del_init(&net->net_list);
lnet_net_free(net);
net = lnet_get_net_locked(net_id);
if (net == NULL) {
+ lnet_net_unlock(0);
rc = -EINVAL;
goto out;
}
EXPORT_SYMBOL(LNetDebugPeer);
/**
+ * Determine if the specified peer \a nid is on the local node.
+ *
+ * \param nid peer nid to check
+ *
+ * \retval true If peer NID is on the local node.
+ * \retval false If peer NID is not on the local node.
+ */
+bool LNetIsPeerLocal(lnet_nid_t nid)
+{
+ struct lnet_net *net;
+ struct lnet_ni *ni;
+ int cpt;
+
+ cpt = lnet_net_lock_current();
+ list_for_each_entry(net, &the_lnet.ln_nets, net_list) {
+ list_for_each_entry(ni, &net->net_ni_list, ni_netlist) {
+ if (ni->ni_nid == nid) {
+ lnet_net_unlock(cpt);
+ return true;
+ }
+ }
+ }
+ lnet_net_unlock(cpt);
+
+ return false;
+}
+EXPORT_SYMBOL(LNetIsPeerLocal);
+
+/**
* Retrieve the struct lnet_process_id ID of LNet interface at \a index.
* Note that all interfaces share a same PID, as requested by LNetNIInit().
*