Whamcloud - gitweb
LU-4423 lustre: don't declare extern variables in C files.
[fs/lustre-release.git] / lnet / lnet / router.c
index 9fdfc2a..2cc502d 100644 (file)
@@ -35,8 +35,6 @@
 #define LNET_NRB_LARGE_PAGES   ((LNET_MTU + PAGE_SIZE - 1) >> \
                                  PAGE_SHIFT)
 
-extern unsigned int lnet_current_net_count;
-
 static char *forwarding = "";
 module_param(forwarding, charp, 0444);
 MODULE_PARM_DESC(forwarding, "Explicitly enable/disable forwarding between networks");
@@ -239,7 +237,7 @@ bool lnet_is_route_alive(struct lnet_route *route)
         * aliveness information can only be obtained when discovery is
         * enabled.
         */
-       if (lnet_peer_discovery_disabled)
+       if (lnet_is_discovery_disabled(gw))
                return route->lr_alive;
 
        /*
@@ -332,18 +330,23 @@ lnet_router_discovery_ping_reply(struct lnet_peer *lp)
 
        spin_lock(&lp->lp_lock);
        lp_state = lp->lp_state;
-       spin_unlock(&lp->lp_lock);
 
        /* only handle replies if discovery is disabled. */
-       if (!lnet_peer_discovery_disabled)
+       if (!lnet_is_discovery_disabled_locked(lp)) {
+               spin_unlock(&lp->lp_lock);
                return;
+       }
+
+       spin_unlock(&lp->lp_lock);
 
-       if (lp_state & LNET_PEER_PING_FAILED) {
-               CDEBUG(D_NET,
-                      "Ping failed with %d. Set routes down for gw %s\n",
-                      lp->lp_ping_error, libcfs_nid2str(lp->lp_primary_nid));
-               /* If the ping failed then mark the routes served by this
-                * peer down
+       if (lp_state & LNET_PEER_PING_FAILED ||
+           pbuf->pb_info.pi_features & LNET_PING_FEAT_RTE_DISABLED) {
+               CDEBUG(D_NET, "Set routes down for gw %s because %s %d\n",
+                      libcfs_nid2str(lp->lp_primary_nid),
+                      lp_state & LNET_PEER_PING_FAILED ? "ping failed" :
+                      "route feature is disabled", lp->lp_ping_error);
+               /* If the ping failed or the peer has routing disabled then
+                * mark the routes served by this peer down
                 */
                list_for_each_entry(route, &lp->lp_routes, lr_gwlist)
                        lnet_set_route_aliveness(route, false);
@@ -373,13 +376,6 @@ lnet_router_discovery_ping_reply(struct lnet_peer *lp)
                            route->lr_gateway->lp_primary_nid)
                                continue;
 
-                       /* gateway has the routing feature disabled */
-                       if (pbuf->pb_info.pi_features &
-                             LNET_PING_FEAT_RTE_DISABLED) {
-                               lnet_set_route_aliveness(route, false);
-                               continue;
-                       }
-
                        llpn = lnet_peer_get_net_locked(lp, route->lr_lnet);
                        if (!llpn) {
                                lnet_set_route_aliveness(route, false);
@@ -429,6 +425,7 @@ lnet_router_discovery_complete(struct lnet_peer *lp)
 
        spin_lock(&lp->lp_lock);
        lp->lp_state &= ~LNET_PEER_RTR_DISCOVERY;
+       lp->lp_state |= LNET_PEER_RTR_DISCOVERED;
        spin_unlock(&lp->lp_lock);
 
        /*
@@ -522,7 +519,6 @@ static void lnet_shuffle_seed(void)
                add_device_randomness(&ni->ni_nid, sizeof(ni->ni_nid));
 
        seeded = 1;
-       return;
 }
 
 /* NB expects LNET_LOCK held */
@@ -706,7 +702,7 @@ lnet_add_route(__u32 net, __u32 hops, lnet_nid_t gateway,
                LIBCFS_FREE(rnet, sizeof(*rnet));
 
        /* kick start the monitor thread to handle the added route */
-       wake_up(&the_lnet.ln_mt_waitq);
+       complete(&the_lnet.ln_mt_wait_complete);
 
        return rc;
 }
@@ -751,7 +747,7 @@ lnet_del_route(__u32 net, lnet_nid_t gw_nid)
        struct lnet_peer_ni *lpni;
        struct lnet_route *route;
        struct list_head zombies;
-       struct lnet_peer *lp;
+       struct lnet_peer *lp = NULL;
        int i = 0;
 
        INIT_LIST_HEAD(&rnet_zombies);
@@ -927,7 +923,7 @@ lnet_wait_known_routerstate(void)
 
                        spin_lock(&rtr->lp_lock);
 
-                       if ((rtr->lp_state & LNET_PEER_DISCOVERED) == 0) {
+                       if ((rtr->lp_state & LNET_PEER_RTR_DISCOVERED) == 0) {
                                all_known = 0;
                                spin_unlock(&rtr->lp_lock);
                                break;
@@ -1458,7 +1454,7 @@ lnet_rtrpools_alloc(int im_a_router)
        lnet_net_lock(LNET_LOCK_EX);
        the_lnet.ln_routing = 1;
        lnet_net_unlock(LNET_LOCK_EX);
-       wake_up(&the_lnet.ln_mt_waitq);
+       complete(&the_lnet.ln_mt_wait_complete);
        return 0;
 
  failed: