Whamcloud - gitweb
LU-6060 lnet: set downis to 1 if there's no NI for remote net
[fs/lustre-release.git] / lnet / lnet / router.c
index 290fe2d..ddd83aa 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
  *
- * Copyright (c) 2011, 2013, Intel Corporation.
+ * Copyright (c) 2011, 2014, Intel Corporation.
  *
  *   This file is part of Portals
  *   http://sourceforge.net/projects/sandiaportals/
@@ -87,7 +87,7 @@ static int check_routers_before_use = 0;
 CFS_MODULE_PARM(check_routers_before_use, "i", int, 0444,
                "Assume routers are down and ping them before use");
 
-static int avoid_asym_router_failure = 1;
+int avoid_asym_router_failure = 1;
 CFS_MODULE_PARM(avoid_asym_router_failure, "i", int, 0644,
                "Avoid asymmetrical router failures (0 to disable)");
 
@@ -138,7 +138,7 @@ lnet_notify_locked(lnet_peer_t *lp, int notifylnd, int alive, cfs_time_t when)
        CDEBUG(D_NET, "set %s %d\n", libcfs_nid2str(lp->lp_nid), alive);
 }
 
-void
+static void
 lnet_ni_notify_locked(lnet_ni_t *ni, lnet_peer_t *lp)
 {
         int        alive;
@@ -276,8 +276,8 @@ static void lnet_shuffle_seed(void)
 }
 
 /* NB expects LNET_LOCK held */
-void
-lnet_add_route_to_rnet (lnet_remotenet_t *rnet, lnet_route_t *route)
+static void
+lnet_add_route_to_rnet(lnet_remotenet_t *rnet, lnet_route_t *route)
 {
        unsigned int      len = 0;
        unsigned int      offset = 0;
@@ -327,7 +327,7 @@ lnet_add_route(__u32 net, unsigned int hops, lnet_nid_t gateway,
                return -EINVAL;
 
        if (lnet_islocalnet(net))       /* it's a local network */
-               return 0;               /* ignore the route entry */
+               return -EEXIST;
 
        /* Assume net, route, all new */
        LIBCFS_ALLOC(route, sizeof(*route));
@@ -358,7 +358,7 @@ lnet_add_route(__u32 net, unsigned int hops, lnet_nid_t gateway,
                LIBCFS_FREE(rnet, sizeof(*rnet));
 
                if (rc == -EHOSTUNREACH) /* gateway is not on a local net. */
-                       return 0;        /* ignore the route entry */
+                       return rc;       /* ignore the route entry */
                CERROR("Error %d creating route %s %d %s\n", rc,
                        libcfs_net2str(net), hops,
                        libcfs_nid2str(gateway));
@@ -406,13 +406,17 @@ lnet_add_route(__u32 net, unsigned int hops, lnet_nid_t gateway,
        lnet_peer_decref_locked(route->lr_gateway);
        lnet_net_unlock(LNET_LOCK_EX);
 
-       if (!add_route)
+       rc = 0;
+
+       if (!add_route) {
+               rc = -EEXIST;
                LIBCFS_FREE(route, sizeof(*route));
+       }
 
        if (rnet != rnet2)
                LIBCFS_FREE(rnet, sizeof(*rnet));
 
-       return 0;
+       return rc;
 }
 
 int
@@ -731,6 +735,11 @@ lnet_parse_rc_info(lnet_rc_data_t *rcd)
                        rte->lr_downis = 0;
                        continue;
                }
+               /* if @down is zero and this route is single-hop, it means
+                * we can't find NI for target network */
+               if (down == 0 && rte->lr_hops == 1)
+                       down = 1;
+
                rte->lr_downis = down;
        }
 }
@@ -788,7 +797,7 @@ lnet_router_checker_event(lnet_event_t *event)
        lnet_net_unlock(lp->lp_cpt);
 }
 
-void
+static void
 lnet_wait_known_routerstate(void)
 {
        lnet_peer_t      *rtr;
@@ -823,6 +832,21 @@ lnet_wait_known_routerstate(void)
 }
 
 void
+lnet_router_ni_update_locked(lnet_peer_t *gw, __u32 net)
+{
+       lnet_route_t *rte;
+
+       if ((gw->lp_ping_feats & LNET_PING_FEAT_NI_STATUS) != 0) {
+               list_for_each_entry(rte, &gw->lp_routes, lr_gwlist) {
+                       if (rte->lr_net == net) {
+                               rte->lr_downis = 0;
+                               break;
+                       }
+               }
+       }
+}
+
+static void
 lnet_update_ni_status_locked(void)
 {
        lnet_ni_t       *ni;
@@ -862,7 +886,7 @@ lnet_update_ni_status_locked(void)
        }
 }
 
-void
+static void
 lnet_destroy_rc_data(lnet_rc_data_t *rcd)
 {
        LASSERT(list_empty(&rcd->rcd_list));
@@ -883,7 +907,7 @@ lnet_destroy_rc_data(lnet_rc_data_t *rcd)
        LIBCFS_FREE(rcd, sizeof(*rcd));
 }
 
-lnet_rc_data_t *
+static lnet_rc_data_t *
 lnet_create_rc_data_locked(lnet_peer_t *gateway)
 {
        lnet_rc_data_t          *rcd = NULL;
@@ -1011,7 +1035,7 @@ lnet_ping_router_locked (lnet_peer_t *rtr)
                 lnet_handle_md_t  mdh;
 
                 id.nid = rtr->lp_nid;
-                id.pid = LUSTRE_SRV_LNET_PID;
+               id.pid = LNET_PID_LUSTRE;
                 CDEBUG(D_NET, "Check: %s\n", libcfs_id2str(id));
 
                 rtr->lp_ping_notsent   = 1;
@@ -1069,7 +1093,7 @@ lnet_router_checker_start(void)
 
                 /* one async ping reply per router */
                 id.nid = rtr->lp_nid;
-                id.pid = LUSTRE_SRV_LNET_PID;
+               id.pid = LNET_PID_LUSTRE;
 
                lnet_net_unlock(0);
 
@@ -1341,7 +1365,7 @@ lnet_destroy_rtrbuf(lnet_rtrbuf_t *rb, int npages)
         LIBCFS_FREE(rb, sz);
 }
 
-lnet_rtrbuf_t *
+static lnet_rtrbuf_t *
 lnet_new_rtrbuf(lnet_rtrbufpool_t *rbp, int cpt)
 {
        int            npages = rbp->rbp_npages;
@@ -1375,7 +1399,7 @@ lnet_new_rtrbuf(lnet_rtrbufpool_t *rbp, int cpt)
         return rb;
 }
 
-void
+static void
 lnet_rtrpool_free_bufs(lnet_rtrbufpool_t *rbp, int cpt)
 {
        int              npages = rbp->rbp_npages;
@@ -1468,7 +1492,7 @@ failed:
        return -ENOMEM;
 }
 
-void
+static void
 lnet_rtrpool_init(lnet_rtrbufpool_t *rbp, int npages)
 {
        INIT_LIST_HEAD(&rbp->rbp_msgs);