2 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
4 * Copyright (c) 2011, 2012, Intel Corporation.
6 * This file is part of Portals
7 * http://sourceforge.net/projects/sandiaportals/
9 * Portals is free software; you can redistribute it and/or
10 * modify it under the terms of version 2 of the GNU General Public
11 * License as published by the Free Software Foundation.
13 * Portals is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with Portals; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 #define DEBUG_SUBSYSTEM S_LNET
25 #include <lnet/lib-lnet.h>
27 #if defined(__KERNEL__) && defined(LNET_ROUTER)
29 #define LNET_NRB_TINY_MIN 512 /* min value for each CPT */
30 #define LNET_NRB_TINY (LNET_NRB_TINY_MIN * 4)
31 #define LNET_NRB_SMALL_MIN 4096 /* min value for each CPT */
32 #define LNET_NRB_SMALL (LNET_NRB_SMALL_MIN * 4)
33 #define LNET_NRB_LARGE_MIN 256 /* min value for each CPT */
34 #define LNET_NRB_LARGE (LNET_NRB_LARGE_MIN * 4)
36 static char *forwarding = "";
37 CFS_MODULE_PARM(forwarding, "s", charp, 0444,
38 "Explicitly enable/disable forwarding between networks");
40 static int tiny_router_buffers;
41 CFS_MODULE_PARM(tiny_router_buffers, "i", int, 0444,
42 "# of 0 payload messages to buffer in the router");
43 static int small_router_buffers;
44 CFS_MODULE_PARM(small_router_buffers, "i", int, 0444,
45 "# of small (1 page) messages to buffer in the router");
46 static int large_router_buffers;
47 CFS_MODULE_PARM(large_router_buffers, "i", int, 0444,
48 "# of large messages to buffer in the router");
49 static int peer_buffer_credits = 0;
50 CFS_MODULE_PARM(peer_buffer_credits, "i", int, 0444,
51 "# router buffer credits per peer");
53 static int auto_down = 1;
54 CFS_MODULE_PARM(auto_down, "i", int, 0444,
55 "Automatically mark peers down on comms error");
58 lnet_peer_buffer_credits(lnet_ni_t *ni)
60 /* NI option overrides LNet default */
61 if (ni->ni_peerrtrcredits > 0)
62 return ni->ni_peerrtrcredits;
63 if (peer_buffer_credits > 0)
64 return peer_buffer_credits;
66 /* As an approximation, allow this peer the same number of router
67 * buffers as it is allowed outstanding sends */
68 return ni->ni_peertxcredits;
72 static int lnet_router_checker(void *);
76 lnet_peer_buffer_credits(lnet_ni_t *ni)
83 static int check_routers_before_use = 0;
84 CFS_MODULE_PARM(check_routers_before_use, "i", int, 0444,
85 "Assume routers are down and ping them before use");
87 static int avoid_asym_router_failure = 1;
88 CFS_MODULE_PARM(avoid_asym_router_failure, "i", int, 0644,
89 "Avoid asymmetrical router failures (0 to disable)");
91 static int dead_router_check_interval = 60;
92 CFS_MODULE_PARM(dead_router_check_interval, "i", int, 0644,
93 "Seconds between dead router health checks (<= 0 to disable)");
95 static int live_router_check_interval = 60;
96 CFS_MODULE_PARM(live_router_check_interval, "i", int, 0644,
97 "Seconds between live router health checks (<= 0 to disable)");
99 static int router_ping_timeout = 50;
100 CFS_MODULE_PARM(router_ping_timeout, "i", int, 0644,
101 "Seconds to wait for the reply to a router health query");
104 lnet_peers_start_down(void)
106 return check_routers_before_use;
110 lnet_notify_locked(lnet_peer_t *lp, int notifylnd, int alive, cfs_time_t when)
112 if (cfs_time_before(when, lp->lp_timestamp)) { /* out of date information */
113 CDEBUG(D_NET, "Out of date\n");
117 lp->lp_timestamp = when; /* update timestamp */
118 lp->lp_ping_deadline = 0; /* disable ping timeout */
120 if (lp->lp_alive_count != 0 && /* got old news */
121 (!lp->lp_alive) == (!alive)) { /* new date for old news */
122 CDEBUG(D_NET, "Old news\n");
126 /* Flag that notification is outstanding */
128 lp->lp_alive_count++;
129 lp->lp_alive = !(!alive); /* 1 bit! */
131 lp->lp_notifylnd |= notifylnd;
133 lp->lp_ping_feats = LNET_PING_FEAT_INVAL; /* reset */
135 CDEBUG(D_NET, "set %s %d\n", libcfs_nid2str(lp->lp_nid), alive);
139 lnet_ni_notify_locked(lnet_ni_t *ni, lnet_peer_t *lp)
144 /* Notify only in 1 thread at any time to ensure ordered notification.
145 * NB individual events can be missed; the only guarantee is that you
146 * always get the most recent news */
148 if (lp->lp_notifying)
151 lp->lp_notifying = 1;
153 while (lp->lp_notify) {
154 alive = lp->lp_alive;
155 notifylnd = lp->lp_notifylnd;
157 lp->lp_notifylnd = 0;
160 if (notifylnd && ni->ni_lnd->lnd_notify != NULL) {
161 lnet_net_unlock(lp->lp_cpt);
163 /* A new notification could happen now; I'll handle it
164 * when control returns to me */
166 (ni->ni_lnd->lnd_notify)(ni, lp->lp_nid, alive);
168 lnet_net_lock(lp->lp_cpt);
172 lp->lp_notifying = 0;
177 lnet_rtr_addref_locked(lnet_peer_t *lp)
179 LASSERT(lp->lp_refcount > 0);
180 LASSERT(lp->lp_rtr_refcount >= 0);
182 /* lnet_net_lock must be exclusively locked */
183 lp->lp_rtr_refcount++;
184 if (lp->lp_rtr_refcount == 1) {
187 /* a simple insertion sort */
188 cfs_list_for_each_prev(pos, &the_lnet.ln_routers) {
189 lnet_peer_t *rtr = cfs_list_entry(pos, lnet_peer_t,
192 if (rtr->lp_nid < lp->lp_nid)
196 cfs_list_add(&lp->lp_rtr_list, pos);
197 /* addref for the_lnet.ln_routers */
198 lnet_peer_addref_locked(lp);
199 the_lnet.ln_routers_version++;
204 lnet_rtr_decref_locked(lnet_peer_t *lp)
206 LASSERT(lp->lp_refcount > 0);
207 LASSERT(lp->lp_rtr_refcount > 0);
209 /* lnet_net_lock must be exclusively locked */
210 lp->lp_rtr_refcount--;
211 if (lp->lp_rtr_refcount == 0) {
212 LASSERT(cfs_list_empty(&lp->lp_routes));
214 if (lp->lp_rcd != NULL) {
215 cfs_list_add(&lp->lp_rcd->rcd_list,
216 &the_lnet.ln_rcd_deathrow);
220 cfs_list_del(&lp->lp_rtr_list);
221 /* decref for the_lnet.ln_routers */
222 lnet_peer_decref_locked(lp);
223 the_lnet.ln_routers_version++;
228 lnet_find_net_locked (__u32 net)
230 lnet_remotenet_t *rnet;
234 LASSERT(!the_lnet.ln_shutdown);
236 rn_list = lnet_net2rnethash(net);
237 cfs_list_for_each(tmp, rn_list) {
238 rnet = cfs_list_entry(tmp, lnet_remotenet_t, lrn_list);
240 if (rnet->lrn_net == net)
246 static void lnet_shuffle_seed(void)
248 static int seeded = 0;
249 int lnd_type, seed[2];
257 cfs_get_random_bytes(seed, sizeof(seed));
259 /* Nodes with small feet have little entropy
260 * the NID for this node gives the most entropy in the low bits */
261 cfs_list_for_each(tmp, &the_lnet.ln_nis) {
262 ni = cfs_list_entry(tmp, lnet_ni_t, ni_list);
263 lnd_type = LNET_NETTYP(LNET_NIDNET(ni->ni_nid));
265 if (lnd_type != LOLND)
266 seed[0] ^= (LNET_NIDADDR(ni->ni_nid) | lnd_type);
269 cfs_gettimeofday(&tv);
270 cfs_srand(tv.tv_sec ^ seed[0], tv.tv_usec ^ seed[1]);
275 /* NB expects LNET_LOCK held */
277 lnet_add_route_to_rnet (lnet_remotenet_t *rnet, lnet_route_t *route)
279 unsigned int len = 0;
280 unsigned int offset = 0;
285 cfs_list_for_each (e, &rnet->lrn_routes) {
289 /* len+1 positions to add a new entry, also prevents division by 0 */
290 offset = cfs_rand() % (len + 1);
291 cfs_list_for_each (e, &rnet->lrn_routes) {
296 cfs_list_add(&route->lr_list, e);
297 cfs_list_add(&route->lr_gwlist, &route->lr_gateway->lp_routes);
299 the_lnet.ln_remote_nets_version++;
300 lnet_rtr_addref_locked(route->lr_gateway);
304 lnet_add_route (__u32 net, unsigned int hops, lnet_nid_t gateway)
307 lnet_remotenet_t *rnet;
308 lnet_remotenet_t *rnet2;
314 CDEBUG(D_NET, "Add route: net %s hops %u gw %s\n",
315 libcfs_net2str(net), hops, libcfs_nid2str(gateway));
317 if (gateway == LNET_NID_ANY ||
318 LNET_NETTYP(LNET_NIDNET(gateway)) == LOLND ||
319 net == LNET_NIDNET(LNET_NID_ANY) ||
320 LNET_NETTYP(net) == LOLND ||
321 LNET_NIDNET(gateway) == net ||
322 hops < 1 || hops > 255)
325 if (lnet_islocalnet(net)) /* it's a local network */
326 return 0; /* ignore the route entry */
328 /* Assume net, route, all new */
329 LIBCFS_ALLOC(route, sizeof(*route));
330 LIBCFS_ALLOC(rnet, sizeof(*rnet));
331 if (route == NULL || rnet == NULL) {
332 CERROR("Out of memory creating route %s %d %s\n",
333 libcfs_net2str(net), hops, libcfs_nid2str(gateway));
335 LIBCFS_FREE(route, sizeof(*route));
337 LIBCFS_FREE(rnet, sizeof(*rnet));
341 CFS_INIT_LIST_HEAD(&rnet->lrn_routes);
343 route->lr_hops = hops;
346 lnet_net_lock(LNET_LOCK_EX);
348 rc = lnet_nid2peer_locked(&route->lr_gateway, gateway, LNET_LOCK_EX);
350 lnet_net_unlock(LNET_LOCK_EX);
352 LIBCFS_FREE(route, sizeof(*route));
353 LIBCFS_FREE(rnet, sizeof(*rnet));
355 if (rc == -EHOSTUNREACH) { /* gateway is not on a local net */
356 return 0; /* ignore the route entry */
358 CERROR("Error %d creating route %s %d %s\n", rc,
359 libcfs_net2str(net), hops,
360 libcfs_nid2str(gateway));
365 LASSERT (!the_lnet.ln_shutdown);
367 rnet2 = lnet_find_net_locked(net);
370 cfs_list_add_tail(&rnet->lrn_list, lnet_net2rnethash(net));
374 /* Search for a duplicate route (it's a NOOP if it is) */
376 cfs_list_for_each (e, &rnet2->lrn_routes) {
377 lnet_route_t *route2 = cfs_list_entry(e, lnet_route_t, lr_list);
379 if (route2->lr_gateway == route->lr_gateway) {
384 /* our lookups must be true */
385 LASSERT (route2->lr_gateway->lp_nid != gateway);
389 lnet_peer_addref_locked(route->lr_gateway); /* +1 for notify */
390 lnet_add_route_to_rnet(rnet2, route);
392 ni = route->lr_gateway->lp_ni;
393 lnet_net_unlock(LNET_LOCK_EX);
395 /* XXX Assume alive */
396 if (ni->ni_lnd->lnd_notify != NULL)
397 (ni->ni_lnd->lnd_notify)(ni, gateway, 1);
399 lnet_net_lock(LNET_LOCK_EX);
402 /* -1 for notify or !add_route */
403 lnet_peer_decref_locked(route->lr_gateway);
404 lnet_net_unlock(LNET_LOCK_EX);
407 LIBCFS_FREE(route, sizeof(*route));
410 LIBCFS_FREE(rnet, sizeof(*rnet));
416 lnet_check_routes(void)
418 lnet_remotenet_t *rnet;
420 lnet_route_t *route2;
427 cpt = lnet_net_lock_current();
429 for (i = 0; i < LNET_REMOTE_NETS_HASH_SIZE; i++) {
430 rn_list = &the_lnet.ln_remote_nets_hash[i];
431 cfs_list_for_each(e1, rn_list) {
432 rnet = cfs_list_entry(e1, lnet_remotenet_t, lrn_list);
435 cfs_list_for_each(e2, &rnet->lrn_routes) {
440 route = cfs_list_entry(e2, lnet_route_t,
443 if (route2 == NULL) {
448 if (route->lr_gateway->lp_ni ==
449 route2->lr_gateway->lp_ni)
452 nid1 = route->lr_gateway->lp_nid;
453 nid2 = route2->lr_gateway->lp_nid;
456 lnet_net_unlock(cpt);
458 CERROR("Routes to %s via %s and %s not "
461 libcfs_nid2str(nid1),
462 libcfs_nid2str(nid2));
468 lnet_net_unlock(cpt);
473 lnet_del_route(__u32 net, lnet_nid_t gw_nid)
475 struct lnet_peer *gateway;
476 lnet_remotenet_t *rnet;
484 CDEBUG(D_NET, "Del route: net %s : gw %s\n",
485 libcfs_net2str(net), libcfs_nid2str(gw_nid));
487 /* NB Caller may specify either all routes via the given gateway
488 * or a specific route entry actual NIDs) */
490 lnet_net_lock(LNET_LOCK_EX);
491 if (net == LNET_NIDNET(LNET_NID_ANY))
492 rn_list = &the_lnet.ln_remote_nets_hash[0];
494 rn_list = lnet_net2rnethash(net);
497 cfs_list_for_each(e1, rn_list) {
498 rnet = cfs_list_entry(e1, lnet_remotenet_t, lrn_list);
500 if (!(net == LNET_NIDNET(LNET_NID_ANY) ||
501 net == rnet->lrn_net))
504 cfs_list_for_each(e2, &rnet->lrn_routes) {
505 route = cfs_list_entry(e2, lnet_route_t, lr_list);
507 gateway = route->lr_gateway;
508 if (!(gw_nid == LNET_NID_ANY ||
509 gw_nid == gateway->lp_nid))
512 cfs_list_del(&route->lr_list);
513 cfs_list_del(&route->lr_gwlist);
514 the_lnet.ln_remote_nets_version++;
516 if (cfs_list_empty(&rnet->lrn_routes))
517 cfs_list_del(&rnet->lrn_list);
521 lnet_rtr_decref_locked(gateway);
522 lnet_peer_decref_locked(gateway);
524 lnet_net_unlock(LNET_LOCK_EX);
526 LIBCFS_FREE(route, sizeof(*route));
529 LIBCFS_FREE(rnet, sizeof(*rnet));
532 lnet_net_lock(LNET_LOCK_EX);
537 if (net == LNET_NIDNET(LNET_NID_ANY) &&
538 ++idx < LNET_REMOTE_NETS_HASH_SIZE) {
539 rn_list = &the_lnet.ln_remote_nets_hash[idx];
542 lnet_net_unlock(LNET_LOCK_EX);
548 lnet_destroy_routes (void)
550 lnet_del_route(LNET_NIDNET(LNET_NID_ANY), LNET_NID_ANY);
554 lnet_get_route(int idx, __u32 *net, __u32 *hops,
555 lnet_nid_t *gateway, __u32 *alive)
559 lnet_remotenet_t *rnet;
565 cpt = lnet_net_lock_current();
567 for (i = 0; i < LNET_REMOTE_NETS_HASH_SIZE; i++) {
568 rn_list = &the_lnet.ln_remote_nets_hash[i];
569 cfs_list_for_each(e1, rn_list) {
570 rnet = cfs_list_entry(e1, lnet_remotenet_t, lrn_list);
572 cfs_list_for_each(e2, &rnet->lrn_routes) {
573 route = cfs_list_entry(e2, lnet_route_t,
577 *net = rnet->lrn_net;
578 *hops = route->lr_hops;
579 *gateway = route->lr_gateway->lp_nid;
580 *alive = route->lr_gateway->lp_alive;
581 lnet_net_unlock(cpt);
588 lnet_net_unlock(cpt);
593 lnet_swap_pinginfo(lnet_ping_info_t *info)
596 lnet_ni_status_t *stat;
598 __swab32s(&info->pi_magic);
599 __swab32s(&info->pi_features);
600 __swab32s(&info->pi_pid);
601 __swab32s(&info->pi_nnis);
602 for (i = 0; i < info->pi_nnis && i < LNET_MAX_RTR_NIS; i++) {
603 stat = &info->pi_ni[i];
604 __swab64s(&stat->ns_nid);
605 __swab32s(&stat->ns_status);
611 * parse router-checker pinginfo, record number of down NIs for remote
612 * networks on that router.
615 lnet_parse_rc_info(lnet_rc_data_t *rcd)
617 lnet_ping_info_t *info = rcd->rcd_pinginfo;
618 struct lnet_peer *gw = rcd->rcd_gateway;
624 if (info->pi_magic == __swab32(LNET_PROTO_PING_MAGIC))
625 lnet_swap_pinginfo(info);
627 /* NB always racing with network! */
628 if (info->pi_magic != LNET_PROTO_PING_MAGIC) {
629 CDEBUG(D_NET, "%s: Unexpected magic %08x\n",
630 libcfs_nid2str(gw->lp_nid), info->pi_magic);
631 gw->lp_ping_feats = LNET_PING_FEAT_INVAL;
635 gw->lp_ping_feats = info->pi_features;
636 if ((gw->lp_ping_feats & LNET_PING_FEAT_MASK) == 0) {
637 CDEBUG(D_NET, "%s: Unexpected features 0x%x\n",
638 libcfs_nid2str(gw->lp_nid), gw->lp_ping_feats);
639 return; /* nothing I can understand */
642 if ((gw->lp_ping_feats & LNET_PING_FEAT_NI_STATUS) == 0)
643 return; /* can't carry NI status info */
645 cfs_list_for_each_entry(rtr, &gw->lp_routes, lr_gwlist) {
646 int ptl_status = LNET_NI_STATUS_INVALID;
651 for (i = 0; i < info->pi_nnis && i < LNET_MAX_RTR_NIS; i++) {
652 lnet_ni_status_t *stat = &info->pi_ni[i];
653 lnet_nid_t nid = stat->ns_nid;
655 if (nid == LNET_NID_ANY) {
656 CDEBUG(D_NET, "%s: unexpected LNET_NID_ANY\n",
657 libcfs_nid2str(gw->lp_nid));
658 gw->lp_ping_feats = LNET_PING_FEAT_INVAL;
662 if (LNET_NETTYP(LNET_NIDNET(nid)) == LOLND)
665 if (stat->ns_status == LNET_NI_STATUS_DOWN) {
666 if (LNET_NETTYP(LNET_NIDNET(nid)) != PTLLND)
668 else if (ptl_status != LNET_NI_STATUS_UP)
669 ptl_status = LNET_NI_STATUS_DOWN;
673 if (stat->ns_status == LNET_NI_STATUS_UP) {
674 if (LNET_NIDNET(nid) == rtr->lr_net) {
678 /* ptl NIs are considered down only when
679 * they're all down */
680 if (LNET_NETTYP(LNET_NIDNET(nid)) == PTLLND)
681 ptl_status = LNET_NI_STATUS_UP;
685 CDEBUG(D_NET, "%s: Unexpected status 0x%x\n",
686 libcfs_nid2str(gw->lp_nid), stat->ns_status);
687 gw->lp_ping_feats = LNET_PING_FEAT_INVAL;
691 if (up) { /* ignore downed NIs if NI for dest network is up */
695 rtr->lr_downis = down + (ptl_status == LNET_NI_STATUS_DOWN);
700 lnet_router_checker_event(lnet_event_t *event)
702 lnet_rc_data_t *rcd = event->md.user_ptr;
703 struct lnet_peer *lp;
705 LASSERT(rcd != NULL);
707 if (event->unlinked) {
708 LNetInvalidateHandle(&rcd->rcd_mdh);
712 LASSERT(event->type == LNET_EVENT_SEND ||
713 event->type == LNET_EVENT_REPLY);
715 lp = rcd->rcd_gateway;
718 /* NB: it's called with holding lnet_res_lock, we have a few
719 * places need to hold both locks at the same time, please take
720 * care of lock ordering */
721 lnet_net_lock(lp->lp_cpt);
722 if (!lnet_isrouter(lp) || lp->lp_rcd != rcd) {
723 /* ignore if no longer a router or rcd is replaced */
727 if (event->type == LNET_EVENT_SEND) {
728 lp->lp_ping_notsent = 0;
729 if (event->status == 0)
733 /* LNET_EVENT_REPLY */
734 /* A successful REPLY means the router is up. If _any_ comms
735 * to the router fail I assume it's down (this will happen if
736 * we ping alive routers to try to detect router death before
737 * apps get burned). */
739 lnet_notify_locked(lp, 1, (event->status == 0), cfs_time_current());
740 /* The router checker will wake up very shortly and do the
741 * actual notification.
742 * XXX If 'lp' stops being a router before then, it will still
743 * have the notification pending!!! */
745 if (avoid_asym_router_failure && event->status == 0)
746 lnet_parse_rc_info(rcd);
749 lnet_net_unlock(lp->lp_cpt);
753 lnet_wait_known_routerstate(void)
759 LASSERT (the_lnet.ln_rc_state == LNET_RC_STATE_RUNNING);
762 int cpt = lnet_net_lock_current();
765 cfs_list_for_each (entry, &the_lnet.ln_routers) {
766 rtr = cfs_list_entry(entry, lnet_peer_t, lp_rtr_list);
768 if (rtr->lp_alive_count == 0) {
774 lnet_net_unlock(cpt);
780 lnet_router_checker();
782 cfs_pause(cfs_time_seconds(1));
787 lnet_update_ni_status_locked(void)
793 LASSERT(the_lnet.ln_routing);
795 timeout = router_ping_timeout +
796 MAX(live_router_check_interval, dead_router_check_interval);
798 now = cfs_time_current_sec();
799 cfs_list_for_each_entry(ni, &the_lnet.ln_nis, ni_list) {
800 if (ni->ni_lnd->lnd_type == LOLND)
803 if (now < ni->ni_last_alive + timeout)
807 /* re-check with lock */
808 if (now < ni->ni_last_alive + timeout) {
813 LASSERT(ni->ni_status != NULL);
815 if (ni->ni_status->ns_status != LNET_NI_STATUS_DOWN) {
816 CDEBUG(D_NET, "NI(%s:%d) status changed to down\n",
817 libcfs_nid2str(ni->ni_nid), timeout);
818 /* NB: so far, this is the only place to set
819 * NI status to "down" */
820 ni->ni_status->ns_status = LNET_NI_STATUS_DOWN;
827 lnet_destroy_rc_data(lnet_rc_data_t *rcd)
829 LASSERT(cfs_list_empty(&rcd->rcd_list));
830 /* detached from network */
831 LASSERT(LNetHandleIsInvalid(rcd->rcd_mdh));
833 if (rcd->rcd_gateway != NULL) {
834 int cpt = rcd->rcd_gateway->lp_cpt;
837 lnet_peer_decref_locked(rcd->rcd_gateway);
838 lnet_net_unlock(cpt);
841 if (rcd->rcd_pinginfo != NULL)
842 LIBCFS_FREE(rcd->rcd_pinginfo, LNET_PINGINFO_SIZE);
844 LIBCFS_FREE(rcd, sizeof(*rcd));
848 lnet_create_rc_data_locked(lnet_peer_t *gateway)
850 lnet_rc_data_t *rcd = NULL;
851 lnet_ping_info_t *pi;
855 lnet_net_unlock(gateway->lp_cpt);
857 LIBCFS_ALLOC(rcd, sizeof(*rcd));
861 LNetInvalidateHandle(&rcd->rcd_mdh);
862 CFS_INIT_LIST_HEAD(&rcd->rcd_list);
864 LIBCFS_ALLOC(pi, LNET_PINGINFO_SIZE);
868 memset(pi, 0, LNET_PINGINFO_SIZE);
869 for (i = 0; i < LNET_MAX_RTR_NIS; i++) {
870 pi->pi_ni[i].ns_nid = LNET_NID_ANY;
871 pi->pi_ni[i].ns_status = LNET_NI_STATUS_INVALID;
873 rcd->rcd_pinginfo = pi;
875 LASSERT (!LNetHandleIsInvalid(the_lnet.ln_rc_eqh));
876 rc = LNetMDBind((lnet_md_t){.start = pi,
878 .length = LNET_PINGINFO_SIZE,
879 .threshold = LNET_MD_THRESH_INF,
880 .options = LNET_MD_TRUNCATE,
881 .eq_handle = the_lnet.ln_rc_eqh},
885 CERROR("Can't bind MD: %d\n", rc);
890 lnet_net_lock(gateway->lp_cpt);
891 /* router table changed or someone has created rcd for this gateway */
892 if (!lnet_isrouter(gateway) || gateway->lp_rcd != NULL) {
893 lnet_net_unlock(gateway->lp_cpt);
897 lnet_peer_addref_locked(gateway);
898 rcd->rcd_gateway = gateway;
899 gateway->lp_rcd = rcd;
900 gateway->lp_ping_notsent = 0;
906 if (!LNetHandleIsInvalid(rcd->rcd_mdh)) {
907 rc = LNetMDUnlink(rcd->rcd_mdh);
910 lnet_destroy_rc_data(rcd);
913 lnet_net_lock(gateway->lp_cpt);
914 return gateway->lp_rcd;
918 lnet_router_check_interval (lnet_peer_t *rtr)
922 secs = rtr->lp_alive ? live_router_check_interval :
923 dead_router_check_interval;
931 lnet_ping_router_locked (lnet_peer_t *rtr)
933 lnet_rc_data_t *rcd = NULL;
934 cfs_time_t now = cfs_time_current();
937 lnet_peer_addref_locked(rtr);
939 if (rtr->lp_ping_deadline != 0 && /* ping timed out? */
940 cfs_time_after(now, rtr->lp_ping_deadline))
941 lnet_notify_locked(rtr, 1, 0, now);
943 /* Run any outstanding notifications */
944 lnet_ni_notify_locked(rtr->lp_ni, rtr);
946 if (!lnet_isrouter(rtr) ||
947 the_lnet.ln_rc_state != LNET_RC_STATE_RUNNING) {
948 /* router table changed or router checker is shutting down */
949 lnet_peer_decref_locked(rtr);
953 rcd = rtr->lp_rcd != NULL ?
954 rtr->lp_rcd : lnet_create_rc_data_locked(rtr);
959 secs = lnet_router_check_interval(rtr);
962 "rtr %s %d: deadline %lu ping_notsent %d alive %d "
963 "alive_count %d lp_ping_timestamp %lu\n",
964 libcfs_nid2str(rtr->lp_nid), secs,
965 rtr->lp_ping_deadline, rtr->lp_ping_notsent,
966 rtr->lp_alive, rtr->lp_alive_count, rtr->lp_ping_timestamp);
968 if (secs != 0 && !rtr->lp_ping_notsent &&
969 cfs_time_after(now, cfs_time_add(rtr->lp_ping_timestamp,
970 cfs_time_seconds(secs)))) {
972 lnet_process_id_t id;
973 lnet_handle_md_t mdh;
975 id.nid = rtr->lp_nid;
976 id.pid = LUSTRE_SRV_LNET_PID;
977 CDEBUG(D_NET, "Check: %s\n", libcfs_id2str(id));
979 rtr->lp_ping_notsent = 1;
980 rtr->lp_ping_timestamp = now;
984 if (rtr->lp_ping_deadline == 0) {
985 rtr->lp_ping_deadline =
986 cfs_time_shift(router_ping_timeout);
989 lnet_net_unlock(rtr->lp_cpt);
991 rc = LNetGet(LNET_NID_ANY, mdh, id, LNET_RESERVED_PORTAL,
992 LNET_PROTO_PING_MATCHBITS, 0);
994 lnet_net_lock(rtr->lp_cpt);
996 rtr->lp_ping_notsent = 0; /* no event pending */
999 lnet_peer_decref_locked(rtr);
1004 lnet_router_checker_start(void)
1012 int router_checker_max_eqsize = 10240;
1014 LASSERT (check_routers_before_use);
1015 LASSERT (dead_router_check_interval > 0);
1019 /* As an approximation, allow each router the same number of
1020 * outstanding events as it is allowed outstanding sends */
1022 version = the_lnet.ln_routers_version;
1023 cfs_list_for_each_entry(rtr, &the_lnet.ln_routers, lp_rtr_list) {
1024 lnet_ni_t *ni = rtr->lp_ni;
1025 lnet_process_id_t id;
1028 eqsz += ni->ni_peertxcredits;
1030 /* one async ping reply per router */
1031 id.nid = rtr->lp_nid;
1032 id.pid = LUSTRE_SRV_LNET_PID;
1036 rc = LNetSetAsync(id, 1);
1038 CWARN("LNetSetAsync %s failed: %d\n",
1039 libcfs_id2str(id), rc);
1044 /* NB router list doesn't change in userspace */
1045 LASSERT(version == the_lnet.ln_routers_version);
1052 "No router found, not starting router checker\n");
1056 /* at least allow a SENT and a REPLY per router */
1057 if (router_checker_max_eqsize < 2 * nrtr)
1058 router_checker_max_eqsize = 2 * nrtr;
1061 if (eqsz > router_checker_max_eqsize)
1062 eqsz = router_checker_max_eqsize;
1065 LASSERT (the_lnet.ln_rc_state == LNET_RC_STATE_SHUTDOWN);
1067 if (check_routers_before_use &&
1068 dead_router_check_interval <= 0) {
1069 LCONSOLE_ERROR_MSG(0x10a, "'dead_router_check_interval' must be"
1070 " set if 'check_routers_before_use' is set"
1075 if (!the_lnet.ln_routing &&
1076 live_router_check_interval <= 0 &&
1077 dead_router_check_interval <= 0)
1081 sema_init(&the_lnet.ln_rc_signal, 0);
1082 /* EQ size doesn't matter; the callback is guaranteed to get every
1085 rc = LNetEQAlloc(eqsz, lnet_router_checker_event,
1086 &the_lnet.ln_rc_eqh);
1088 rc = LNetEQAlloc(eqsz, LNET_EQ_HANDLER_NONE,
1089 &the_lnet.ln_rc_eqh);
1092 CERROR("Can't allocate EQ(%d): %d\n", eqsz, rc);
1096 the_lnet.ln_rc_state = LNET_RC_STATE_RUNNING;
1098 rc = cfs_create_thread(lnet_router_checker, NULL, 0);
1100 CERROR("Can't start router checker thread: %d\n", rc);
1101 /* block until event callback signals exit */
1102 down(&the_lnet.ln_rc_signal);
1103 rc = LNetEQFree(the_lnet.ln_rc_eqh);
1105 the_lnet.ln_rc_state = LNET_RC_STATE_SHUTDOWN;
1110 if (check_routers_before_use) {
1111 /* Note that a helpful side-effect of pinging all known routers
1112 * at startup is that it makes them drop stale connections they
1113 * may have to a previous instance of me. */
1114 lnet_wait_known_routerstate();
1121 lnet_router_checker_stop (void)
1125 if (the_lnet.ln_rc_state == LNET_RC_STATE_SHUTDOWN)
1128 LASSERT (the_lnet.ln_rc_state == LNET_RC_STATE_RUNNING);
1129 the_lnet.ln_rc_state = LNET_RC_STATE_STOPPING;
1132 /* block until event callback signals exit */
1133 down(&the_lnet.ln_rc_signal);
1135 lnet_router_checker();
1137 LASSERT(the_lnet.ln_rc_state == LNET_RC_STATE_SHUTDOWN);
1139 rc = LNetEQFree(the_lnet.ln_rc_eqh);
1145 lnet_prune_rc_data(int wait_unlink)
1147 lnet_rc_data_t *rcd;
1148 lnet_rc_data_t *tmp;
1153 if (likely(the_lnet.ln_rc_state == LNET_RC_STATE_RUNNING &&
1154 cfs_list_empty(&the_lnet.ln_rcd_deathrow) &&
1155 cfs_list_empty(&the_lnet.ln_rcd_zombie)))
1158 CFS_INIT_LIST_HEAD(&head);
1160 lnet_net_lock(LNET_LOCK_EX);
1162 if (the_lnet.ln_rc_state != LNET_RC_STATE_RUNNING) {
1163 /* router checker is stopping, prune all */
1164 cfs_list_for_each_entry(lp, &the_lnet.ln_routers,
1166 if (lp->lp_rcd == NULL)
1169 LASSERT(cfs_list_empty(&lp->lp_rcd->rcd_list));
1170 cfs_list_add(&lp->lp_rcd->rcd_list,
1171 &the_lnet.ln_rcd_deathrow);
1176 /* unlink all RCDs on deathrow list */
1177 cfs_list_splice_init(&the_lnet.ln_rcd_deathrow, &head);
1179 if (!cfs_list_empty(&head)) {
1180 lnet_net_unlock(LNET_LOCK_EX);
1182 cfs_list_for_each_entry(rcd, &head, rcd_list)
1183 LNetMDUnlink(rcd->rcd_mdh);
1185 lnet_net_lock(LNET_LOCK_EX);
1188 cfs_list_splice_init(&head, &the_lnet.ln_rcd_zombie);
1190 /* release all zombie RCDs */
1191 while (!cfs_list_empty(&the_lnet.ln_rcd_zombie)) {
1192 cfs_list_for_each_entry_safe(rcd, tmp, &the_lnet.ln_rcd_zombie,
1194 if (LNetHandleIsInvalid(rcd->rcd_mdh))
1195 cfs_list_move(&rcd->rcd_list, &head);
1198 wait_unlink = wait_unlink &&
1199 !cfs_list_empty(&the_lnet.ln_rcd_zombie);
1201 lnet_net_unlock(LNET_LOCK_EX);
1203 while (!cfs_list_empty(&head)) {
1204 rcd = cfs_list_entry(head.next,
1205 lnet_rc_data_t, rcd_list);
1206 cfs_list_del_init(&rcd->rcd_list);
1207 lnet_destroy_rc_data(rcd);
1214 CDEBUG(((i & (-i)) == i) ? D_WARNING : D_NET,
1215 "Waiting for rc buffers to unlink\n");
1216 cfs_pause(cfs_time_seconds(1) / 4);
1218 lnet_net_lock(LNET_LOCK_EX);
1221 lnet_net_unlock(LNET_LOCK_EX);
1225 #if defined(__KERNEL__) && defined(LNET_ROUTER)
1228 lnet_router_checker(void *arg)
1233 cfs_daemonize("router_checker");
1234 cfs_block_allsigs();
1236 LASSERT (the_lnet.ln_rc_state == LNET_RC_STATE_RUNNING);
1238 while (the_lnet.ln_rc_state == LNET_RC_STATE_RUNNING) {
1243 cpt = lnet_net_lock_current();
1245 version = the_lnet.ln_routers_version;
1247 cfs_list_for_each(entry, &the_lnet.ln_routers) {
1248 rtr = cfs_list_entry(entry, lnet_peer_t, lp_rtr_list);
1250 cpt2 = lnet_cpt_of_nid_locked(rtr->lp_nid);
1252 lnet_net_unlock(cpt);
1255 /* the routers list has changed */
1256 if (version != the_lnet.ln_routers_version)
1260 lnet_ping_router_locked(rtr);
1262 /* NB dropped lock */
1263 if (version != the_lnet.ln_routers_version) {
1264 /* the routers list has changed */
1269 if (the_lnet.ln_routing)
1270 lnet_update_ni_status_locked();
1272 lnet_net_unlock(cpt);
1274 lnet_prune_rc_data(0); /* don't wait for UNLINK */
1276 /* Call cfs_pause() here always adds 1 to load average
1277 * because kernel counts # active tasks as nr_running
1278 * + nr_uninterruptible. */
1279 cfs_schedule_timeout_and_set_state(CFS_TASK_INTERRUPTIBLE,
1280 cfs_time_seconds(1));
1283 LASSERT(the_lnet.ln_rc_state == LNET_RC_STATE_STOPPING);
1285 lnet_prune_rc_data(1); /* wait for UNLINK */
1287 the_lnet.ln_rc_state = LNET_RC_STATE_SHUTDOWN;
1288 up(&the_lnet.ln_rc_signal);
1289 /* The unlink event callback will signal final completion */
1294 lnet_destroy_rtrbuf(lnet_rtrbuf_t *rb, int npages)
1296 int sz = offsetof(lnet_rtrbuf_t, rb_kiov[npages]);
1298 while (--npages >= 0)
1299 cfs_free_page(rb->rb_kiov[npages].kiov_page);
1301 LIBCFS_FREE(rb, sz);
1305 lnet_new_rtrbuf(lnet_rtrbufpool_t *rbp, int cpt)
1307 int npages = rbp->rbp_npages;
1308 int sz = offsetof(lnet_rtrbuf_t, rb_kiov[npages]);
1313 LIBCFS_CPT_ALLOC(rb, lnet_cpt_table(), cpt, sz);
1319 for (i = 0; i < npages; i++) {
1320 page = cfs_page_cpt_alloc(lnet_cpt_table(), cpt,
1321 CFS_ALLOC_ZERO | CFS_ALLOC_STD);
1324 cfs_free_page(rb->rb_kiov[i].kiov_page);
1326 LIBCFS_FREE(rb, sz);
1330 rb->rb_kiov[i].kiov_len = CFS_PAGE_SIZE;
1331 rb->rb_kiov[i].kiov_offset = 0;
1332 rb->rb_kiov[i].kiov_page = page;
1339 lnet_rtrpool_free_bufs(lnet_rtrbufpool_t *rbp)
1341 int npages = rbp->rbp_npages;
1345 if (rbp->rbp_nbuffers == 0) /* not initialized or already freed */
1348 LASSERT (cfs_list_empty(&rbp->rbp_msgs));
1349 LASSERT (rbp->rbp_credits == rbp->rbp_nbuffers);
1351 while (!cfs_list_empty(&rbp->rbp_bufs)) {
1352 LASSERT (rbp->rbp_credits > 0);
1354 rb = cfs_list_entry(rbp->rbp_bufs.next,
1355 lnet_rtrbuf_t, rb_list);
1356 cfs_list_del(&rb->rb_list);
1357 lnet_destroy_rtrbuf(rb, npages);
1361 LASSERT (rbp->rbp_nbuffers == nbuffers);
1362 LASSERT (rbp->rbp_credits == nbuffers);
1364 rbp->rbp_nbuffers = rbp->rbp_credits = 0;
1368 lnet_rtrpool_alloc_bufs(lnet_rtrbufpool_t *rbp, int nbufs, int cpt)
1373 if (rbp->rbp_nbuffers != 0) {
1374 LASSERT (rbp->rbp_nbuffers == nbufs);
1378 for (i = 0; i < nbufs; i++) {
1379 rb = lnet_new_rtrbuf(rbp, cpt);
1382 CERROR("Failed to allocate %d router bufs of %d pages\n",
1383 nbufs, rbp->rbp_npages);
1387 rbp->rbp_nbuffers++;
1389 rbp->rbp_mincredits++;
1390 cfs_list_add(&rb->rb_list, &rbp->rbp_bufs);
1392 /* No allocation "under fire" */
1393 /* Otherwise we'd need code to schedule blocked msgs etc */
1394 LASSERT (!the_lnet.ln_routing);
1397 LASSERT (rbp->rbp_credits == nbufs);
1402 lnet_rtrpool_init(lnet_rtrbufpool_t *rbp, int npages)
1404 CFS_INIT_LIST_HEAD(&rbp->rbp_msgs);
1405 CFS_INIT_LIST_HEAD(&rbp->rbp_bufs);
1407 rbp->rbp_npages = npages;
1408 rbp->rbp_credits = 0;
1409 rbp->rbp_mincredits = 0;
1413 lnet_rtrpools_free(void)
1415 lnet_rtrbufpool_t *rtrp;
1418 if (the_lnet.ln_rtrpools == NULL) /* uninitialized or freed */
1421 cfs_percpt_for_each(rtrp, i, the_lnet.ln_rtrpools) {
1422 lnet_rtrpool_free_bufs(&rtrp[0]);
1423 lnet_rtrpool_free_bufs(&rtrp[1]);
1424 lnet_rtrpool_free_bufs(&rtrp[2]);
1427 cfs_percpt_free(the_lnet.ln_rtrpools);
1428 the_lnet.ln_rtrpools = NULL;
1432 lnet_nrb_tiny_calculate(int npages)
1434 int nrbs = LNET_NRB_TINY;
1436 if (tiny_router_buffers < 0) {
1437 LCONSOLE_ERROR_MSG(0x10c,
1438 "tiny_router_buffers=%d invalid when "
1439 "routing enabled\n", tiny_router_buffers);
1443 if (tiny_router_buffers > 0)
1444 nrbs = tiny_router_buffers;
1446 nrbs /= LNET_CPT_NUMBER;
1447 return max(nrbs, LNET_NRB_TINY_MIN);
1451 lnet_nrb_small_calculate(int npages)
1453 int nrbs = LNET_NRB_SMALL;
1455 if (small_router_buffers < 0) {
1456 LCONSOLE_ERROR_MSG(0x10c,
1457 "small_router_buffers=%d invalid when "
1458 "routing enabled\n", small_router_buffers);
1462 if (small_router_buffers > 0)
1463 nrbs = small_router_buffers;
1465 nrbs /= LNET_CPT_NUMBER;
1466 return max(nrbs, LNET_NRB_SMALL_MIN);
1470 lnet_nrb_large_calculate(int npages)
1472 int nrbs = LNET_NRB_LARGE;
1474 if (large_router_buffers < 0) {
1475 LCONSOLE_ERROR_MSG(0x10c,
1476 "large_router_buffers=%d invalid when "
1477 "routing enabled\n", large_router_buffers);
1481 if (large_router_buffers > 0)
1482 nrbs = large_router_buffers;
1484 nrbs /= LNET_CPT_NUMBER;
1485 return max(nrbs, LNET_NRB_LARGE_MIN);
1489 lnet_rtrpools_alloc(int im_a_router)
1491 lnet_rtrbufpool_t *rtrp;
1492 int large_pages = (LNET_MTU + CFS_PAGE_SIZE - 1) >> CFS_PAGE_SHIFT;
1493 int small_pages = 1;
1500 if (!strcmp(forwarding, "")) {
1501 /* not set either way */
1504 } else if (!strcmp(forwarding, "disabled")) {
1505 /* explicitly disabled */
1507 } else if (!strcmp(forwarding, "enabled")) {
1508 /* explicitly enabled */
1510 LCONSOLE_ERROR_MSG(0x10b, "'forwarding' not set to either "
1511 "'enabled' or 'disabled'\n");
1515 nrb_tiny = lnet_nrb_tiny_calculate(0);
1519 nrb_small = lnet_nrb_small_calculate(small_pages);
1523 nrb_large = lnet_nrb_large_calculate(large_pages);
1527 the_lnet.ln_rtrpools = cfs_percpt_alloc(lnet_cpt_table(),
1529 sizeof(lnet_rtrbufpool_t));
1530 if (the_lnet.ln_rtrpools == NULL) {
1531 LCONSOLE_ERROR_MSG(0x10c,
1532 "Failed to initialize router buffe pool\n");
1536 cfs_percpt_for_each(rtrp, i, the_lnet.ln_rtrpools) {
1537 lnet_rtrpool_init(&rtrp[0], 0);
1538 rc = lnet_rtrpool_alloc_bufs(&rtrp[0], nrb_tiny, i);
1542 lnet_rtrpool_init(&rtrp[1], small_pages);
1543 rc = lnet_rtrpool_alloc_bufs(&rtrp[1], nrb_small, i);
1547 lnet_rtrpool_init(&rtrp[2], large_pages);
1548 rc = lnet_rtrpool_alloc_bufs(&rtrp[2], nrb_large, i);
1553 lnet_net_lock(LNET_LOCK_EX);
1554 the_lnet.ln_routing = 1;
1555 lnet_net_unlock(LNET_LOCK_EX);
1560 lnet_rtrpools_free();
1565 lnet_notify(lnet_ni_t *ni, lnet_nid_t nid, int alive, cfs_time_t when)
1567 struct lnet_peer *lp = NULL;
1568 cfs_time_t now = cfs_time_current();
1569 int cpt = lnet_cpt_of_nid(nid);
1571 LASSERT (!cfs_in_interrupt ());
1573 CDEBUG (D_NET, "%s notifying %s: %s\n",
1574 (ni == NULL) ? "userspace" : libcfs_nid2str(ni->ni_nid),
1575 libcfs_nid2str(nid),
1576 alive ? "up" : "down");
1579 LNET_NIDNET(ni->ni_nid) != LNET_NIDNET(nid)) {
1580 CWARN ("Ignoring notification of %s %s by %s (different net)\n",
1581 libcfs_nid2str(nid), alive ? "birth" : "death",
1582 libcfs_nid2str(ni->ni_nid));
1586 /* can't do predictions... */
1587 if (cfs_time_after(when, now)) {
1588 CWARN ("Ignoring prediction from %s of %s %s "
1589 "%ld seconds in the future\n",
1590 (ni == NULL) ? "userspace" : libcfs_nid2str(ni->ni_nid),
1591 libcfs_nid2str(nid), alive ? "up" : "down",
1592 cfs_duration_sec(cfs_time_sub(when, now)));
1596 if (ni != NULL && !alive && /* LND telling me she's down */
1597 !auto_down) { /* auto-down disabled */
1598 CDEBUG(D_NET, "Auto-down disabled\n");
1604 if (the_lnet.ln_shutdown) {
1605 lnet_net_unlock(cpt);
1609 lp = lnet_find_peer_locked(the_lnet.ln_peer_tables[cpt], nid);
1612 lnet_net_unlock(cpt);
1613 CDEBUG(D_NET, "%s not found\n", libcfs_nid2str(nid));
1617 /* We can't fully trust LND on reporting exact peer last_alive
1618 * if he notifies us about dead peer. For example ksocklnd can
1619 * call us with when == _time_when_the_node_was_booted_ if
1620 * no connections were successfully established */
1621 if (ni != NULL && !alive && when < lp->lp_last_alive)
1622 when = lp->lp_last_alive;
1624 lnet_notify_locked(lp, ni == NULL, alive, when);
1626 lnet_ni_notify_locked(ni, lp);
1628 lnet_peer_decref_locked(lp);
1630 lnet_net_unlock(cpt);
1633 EXPORT_SYMBOL(lnet_notify);
1636 lnet_get_tunables (void)
1644 lnet_notify (lnet_ni_t *ni, lnet_nid_t nid, int alive, cfs_time_t when)
1650 lnet_router_checker (void)
1652 static time_t last = 0;
1653 static int running = 0;
1655 time_t now = cfs_time_current_sec();
1656 int interval = now - last;
1661 /* It's no use to call me again within a sec - all intervals and
1662 * timeouts are measured in seconds */
1663 if (last != 0 && interval < 2)
1667 interval > MAX(live_router_check_interval,
1668 dead_router_check_interval))
1669 CNETERR("Checker(%d/%d) not called for %d seconds\n",
1670 live_router_check_interval, dead_router_check_interval,
1673 LASSERT(LNET_CPT_NUMBER == 1);
1676 LASSERT(!running); /* recursion check */
1682 if (the_lnet.ln_rc_state == LNET_RC_STATE_STOPPING)
1683 lnet_prune_rc_data(0); /* unlink all rcd and nowait */
1685 /* consume all pending events */
1690 /* NB ln_rc_eqh must be the 1st in 'eventqs' otherwise the
1691 * recursion breaker in LNetEQPoll would fail */
1692 rc = LNetEQPoll(&the_lnet.ln_rc_eqh, 1, 0, &ev, &i);
1693 if (rc == 0) /* no event pending */
1696 /* NB a lost SENT prevents me from pinging a router again */
1697 if (rc == -EOVERFLOW) {
1698 CERROR("Dropped an event!!!\n");
1704 lnet_router_checker_event(&ev);
1707 if (the_lnet.ln_rc_state == LNET_RC_STATE_STOPPING) {
1708 lnet_prune_rc_data(1); /* release rcd */
1709 the_lnet.ln_rc_state = LNET_RC_STATE_SHUTDOWN;
1714 LASSERT (the_lnet.ln_rc_state == LNET_RC_STATE_RUNNING);
1718 version = the_lnet.ln_routers_version;
1719 cfs_list_for_each_entry (rtr, &the_lnet.ln_routers, lp_rtr_list) {
1720 lnet_ping_router_locked(rtr);
1721 LASSERT (version == the_lnet.ln_routers_version);
1726 running = 0; /* lock only needed for the recursion check */
1730 /* NB lnet_peers_start_down depends on me,
1731 * so must be called before any peer creation */
1733 lnet_get_tunables (void)
1737 s = getenv("LNET_ROUTER_PING_TIMEOUT");
1738 if (s != NULL) router_ping_timeout = atoi(s);
1740 s = getenv("LNET_LIVE_ROUTER_CHECK_INTERVAL");
1741 if (s != NULL) live_router_check_interval = atoi(s);
1743 s = getenv("LNET_DEAD_ROUTER_CHECK_INTERVAL");
1744 if (s != NULL) dead_router_check_interval = atoi(s);
1746 /* This replaces old lnd_notify mechanism */
1747 check_routers_before_use = 1;
1748 if (dead_router_check_interval <= 0)
1749 dead_router_check_interval = 30;
1753 lnet_rtrpools_free(void)
1758 lnet_rtrpools_alloc(int im_a_arouter)