Whamcloud - gitweb
LU-5485 lnet: peer aliveness status and NI status
[fs/lustre-release.git] / lnet / lnet / router.c
index f7bb49c..091cfd9 100644 (file)
@@ -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)");
 
@@ -553,6 +553,42 @@ lnet_destroy_routes (void)
         lnet_del_route(LNET_NIDNET(LNET_NID_ANY), LNET_NID_ANY);
 }
 
+int lnet_get_rtr_pool_cfg(int idx, struct lnet_ioctl_pool_cfg *pool_cfg)
+{
+       int i, rc = -ENOENT, lidx, j;
+
+       if (the_lnet.ln_rtrpools == NULL)
+               return rc;
+
+       for (i = 0; i < LNET_NRBPOOLS; i++) {
+               lnet_rtrbufpool_t *rbp;
+
+               lnet_net_lock(LNET_LOCK_EX);
+               lidx = idx;
+               cfs_percpt_for_each(rbp, j, the_lnet.ln_rtrpools) {
+                       if (lidx-- == 0) {
+                               rc = 0;
+                               pool_cfg->pl_pools[i].pl_npages =
+                                       rbp[i].rbp_npages;
+                               pool_cfg->pl_pools[i].pl_nbuffers =
+                                       rbp[i].rbp_nbuffers;
+                               pool_cfg->pl_pools[i].pl_credits =
+                                       rbp[i].rbp_credits;
+                               pool_cfg->pl_pools[i].pl_mincredits =
+                                       rbp[i].rbp_mincredits;
+                               break;
+                       }
+               }
+               lnet_net_unlock(LNET_LOCK_EX);
+       }
+
+       lnet_net_lock(LNET_LOCK_EX);
+       pool_cfg->pl_routing = the_lnet.ln_routing;
+       lnet_net_unlock(LNET_LOCK_EX);
+
+       return rc;
+}
+
 int
 lnet_get_route(int idx, __u32 *net, __u32 *hops,
               lnet_nid_t *gateway, __u32 *alive, __u32 *priority)
@@ -582,8 +618,8 @@ lnet_get_route(int idx, __u32 *net, __u32 *hops,
                                        *priority = route->lr_priority;
                                        *gateway  = route->lr_gateway->lp_nid;
                                        *alive    =
-                                         route->lr_gateway->lp_alive &&
-                                          !route->lr_downis;
+                                               route->lr_gateway->lp_alive &&
+                                                       !route->lr_downis;
                                        lnet_net_unlock(cpt);
                                        return 0;
                                }
@@ -787,6 +823,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;
+                       }
+               }
+       }
+}
+
+void
 lnet_update_ni_status_locked(void)
 {
        lnet_ni_t       *ni;
@@ -975,7 +1026,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;
@@ -1033,7 +1084,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);
 
@@ -1599,24 +1650,17 @@ lnet_rtrpools_alloc(int im_a_router)
        return rc;
 }
 
-int
-lnet_rtrpools_adjust(int tiny, int small, int large)
+static int
+lnet_rtrpools_adjust_helper(int tiny, int small, int large)
 {
        int nrb = 0;
        int rc = 0;
        int i;
        lnet_rtrbufpool_t *rtrp;
 
-       /* this function doesn't revert the changes if adding new buffers
-        * failed.  It's up to the user space caller to revert the
-        * changes. */
-
-       if (!the_lnet.ln_routing)
-               return 0;
-
        /* If the provided values for each buffer pool are different than the
         * configured values, we need to take action. */
-       if (tiny >= 0 && tiny != tiny_router_buffers) {
+       if (tiny >= 0) {
                tiny_router_buffers = tiny;
                nrb = lnet_nrb_tiny_calculate();
                cfs_percpt_for_each(rtrp, i, the_lnet.ln_rtrpools) {
@@ -1626,7 +1670,7 @@ lnet_rtrpools_adjust(int tiny, int small, int large)
                                return rc;
                }
        }
-       if (small >= 0 && small != small_router_buffers) {
+       if (small >= 0) {
                small_router_buffers = small;
                nrb = lnet_nrb_small_calculate();
                cfs_percpt_for_each(rtrp, i, the_lnet.ln_rtrpools) {
@@ -1636,7 +1680,7 @@ lnet_rtrpools_adjust(int tiny, int small, int large)
                                return rc;
                }
        }
-       if (large >= 0 && large != large_router_buffers) {
+       if (large >= 0) {
                large_router_buffers = large;
                nrb = lnet_nrb_large_calculate();
                cfs_percpt_for_each(rtrp, i, the_lnet.ln_rtrpools) {
@@ -1651,6 +1695,19 @@ lnet_rtrpools_adjust(int tiny, int small, int large)
 }
 
 int
+lnet_rtrpools_adjust(int tiny, int small, int large)
+{
+       /* this function doesn't revert the changes if adding new buffers
+        * failed.  It's up to the user space caller to revert the
+        * changes. */
+
+       if (!the_lnet.ln_routing)
+               return 0;
+
+       return lnet_rtrpools_adjust_helper(tiny, small, large);
+}
+
+int
 lnet_rtrpools_enable(void)
 {
        int rc;
@@ -1666,7 +1723,7 @@ lnet_rtrpools_enable(void)
                 * time. */
                return lnet_rtrpools_alloc(1);
 
-       rc = lnet_rtrpools_adjust(0, 0, 0);
+       rc = lnet_rtrpools_adjust_helper(0, 0, 0);
        if (rc != 0)
                return rc;