2 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
4 * Copyright (c) 2011, 2013, 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 do_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,
305 unsigned int priority)
308 lnet_remotenet_t *rnet;
309 lnet_remotenet_t *rnet2;
315 CDEBUG(D_NET, "Add route: net %s hops %u priority %u gw %s\n",
316 libcfs_net2str(net), hops, priority, libcfs_nid2str(gateway));
318 if (gateway == LNET_NID_ANY ||
319 LNET_NETTYP(LNET_NIDNET(gateway)) == LOLND ||
320 net == LNET_NIDNET(LNET_NID_ANY) ||
321 LNET_NETTYP(net) == LOLND ||
322 LNET_NIDNET(gateway) == net ||
323 hops < 1 || hops > 255)
326 if (lnet_islocalnet(net)) /* it's a local network */
327 return 0; /* ignore the route entry */
329 /* Assume net, route, all new */
330 LIBCFS_ALLOC(route, sizeof(*route));
331 LIBCFS_ALLOC(rnet, sizeof(*rnet));
332 if (route == NULL || rnet == NULL) {
333 CERROR("Out of memory creating route %s %d %s\n",
334 libcfs_net2str(net), hops, libcfs_nid2str(gateway));
336 LIBCFS_FREE(route, sizeof(*route));
338 LIBCFS_FREE(rnet, sizeof(*rnet));
342 CFS_INIT_LIST_HEAD(&rnet->lrn_routes);
344 route->lr_hops = hops;
346 route->lr_priority = priority;
348 lnet_net_lock(LNET_LOCK_EX);
350 rc = lnet_nid2peer_locked(&route->lr_gateway, gateway, LNET_LOCK_EX);
352 lnet_net_unlock(LNET_LOCK_EX);
354 LIBCFS_FREE(route, sizeof(*route));
355 LIBCFS_FREE(rnet, sizeof(*rnet));
357 if (rc == -EHOSTUNREACH) { /* gateway is not on a local net */
358 return 0; /* ignore the route entry */
360 CERROR("Error %d creating route %s %d %s\n", rc,
361 libcfs_net2str(net), hops,
362 libcfs_nid2str(gateway));
367 LASSERT (!the_lnet.ln_shutdown);
369 rnet2 = lnet_find_net_locked(net);
372 cfs_list_add_tail(&rnet->lrn_list, lnet_net2rnethash(net));
376 /* Search for a duplicate route (it's a NOOP if it is) */
378 cfs_list_for_each (e, &rnet2->lrn_routes) {
379 lnet_route_t *route2 = cfs_list_entry(e, lnet_route_t, lr_list);
381 if (route2->lr_gateway == route->lr_gateway) {
386 /* our lookups must be true */
387 LASSERT (route2->lr_gateway->lp_nid != gateway);
391 lnet_peer_addref_locked(route->lr_gateway); /* +1 for notify */
392 lnet_add_route_to_rnet(rnet2, route);
394 ni = route->lr_gateway->lp_ni;
395 lnet_net_unlock(LNET_LOCK_EX);
397 /* XXX Assume alive */
398 if (ni->ni_lnd->lnd_notify != NULL)
399 (ni->ni_lnd->lnd_notify)(ni, gateway, 1);
401 lnet_net_lock(LNET_LOCK_EX);
404 /* -1 for notify or !add_route */
405 lnet_peer_decref_locked(route->lr_gateway);
406 lnet_net_unlock(LNET_LOCK_EX);
409 LIBCFS_FREE(route, sizeof(*route));
412 LIBCFS_FREE(rnet, sizeof(*rnet));
418 lnet_check_routes(void)
420 lnet_remotenet_t *rnet;
422 lnet_route_t *route2;
429 cpt = lnet_net_lock_current();
431 for (i = 0; i < LNET_REMOTE_NETS_HASH_SIZE; i++) {
432 rn_list = &the_lnet.ln_remote_nets_hash[i];
433 cfs_list_for_each(e1, rn_list) {
434 rnet = cfs_list_entry(e1, lnet_remotenet_t, lrn_list);
437 cfs_list_for_each(e2, &rnet->lrn_routes) {
442 route = cfs_list_entry(e2, lnet_route_t,
445 if (route2 == NULL) {
450 if (route->lr_gateway->lp_ni ==
451 route2->lr_gateway->lp_ni)
454 nid1 = route->lr_gateway->lp_nid;
455 nid2 = route2->lr_gateway->lp_nid;
458 lnet_net_unlock(cpt);
460 CERROR("Routes to %s via %s and %s not "
463 libcfs_nid2str(nid1),
464 libcfs_nid2str(nid2));
470 lnet_net_unlock(cpt);
475 lnet_del_route(__u32 net, lnet_nid_t gw_nid)
477 struct lnet_peer *gateway;
478 lnet_remotenet_t *rnet;
486 CDEBUG(D_NET, "Del route: net %s : gw %s\n",
487 libcfs_net2str(net), libcfs_nid2str(gw_nid));
489 /* NB Caller may specify either all routes via the given gateway
490 * or a specific route entry actual NIDs) */
492 lnet_net_lock(LNET_LOCK_EX);
493 if (net == LNET_NIDNET(LNET_NID_ANY))
494 rn_list = &the_lnet.ln_remote_nets_hash[0];
496 rn_list = lnet_net2rnethash(net);
499 cfs_list_for_each(e1, rn_list) {
500 rnet = cfs_list_entry(e1, lnet_remotenet_t, lrn_list);
502 if (!(net == LNET_NIDNET(LNET_NID_ANY) ||
503 net == rnet->lrn_net))
506 cfs_list_for_each(e2, &rnet->lrn_routes) {
507 route = cfs_list_entry(e2, lnet_route_t, lr_list);
509 gateway = route->lr_gateway;
510 if (!(gw_nid == LNET_NID_ANY ||
511 gw_nid == gateway->lp_nid))
514 cfs_list_del(&route->lr_list);
515 cfs_list_del(&route->lr_gwlist);
516 the_lnet.ln_remote_nets_version++;
518 if (cfs_list_empty(&rnet->lrn_routes))
519 cfs_list_del(&rnet->lrn_list);
523 lnet_rtr_decref_locked(gateway);
524 lnet_peer_decref_locked(gateway);
526 lnet_net_unlock(LNET_LOCK_EX);
528 LIBCFS_FREE(route, sizeof(*route));
531 LIBCFS_FREE(rnet, sizeof(*rnet));
534 lnet_net_lock(LNET_LOCK_EX);
539 if (net == LNET_NIDNET(LNET_NID_ANY) &&
540 ++idx < LNET_REMOTE_NETS_HASH_SIZE) {
541 rn_list = &the_lnet.ln_remote_nets_hash[idx];
544 lnet_net_unlock(LNET_LOCK_EX);
550 lnet_destroy_routes (void)
552 lnet_del_route(LNET_NIDNET(LNET_NID_ANY), LNET_NID_ANY);
556 lnet_get_route(int idx, __u32 *net, __u32 *hops,
557 lnet_nid_t *gateway, __u32 *alive, __u32 *priority)
561 lnet_remotenet_t *rnet;
567 cpt = lnet_net_lock_current();
569 for (i = 0; i < LNET_REMOTE_NETS_HASH_SIZE; i++) {
570 rn_list = &the_lnet.ln_remote_nets_hash[i];
571 cfs_list_for_each(e1, rn_list) {
572 rnet = cfs_list_entry(e1, lnet_remotenet_t, lrn_list);
574 cfs_list_for_each(e2, &rnet->lrn_routes) {
575 route = cfs_list_entry(e2, lnet_route_t,
579 *net = rnet->lrn_net;
580 *hops = route->lr_hops;
581 *priority = route->lr_priority;
582 *gateway = route->lr_gateway->lp_nid;
583 *alive = route->lr_gateway->lp_alive;
584 lnet_net_unlock(cpt);
591 lnet_net_unlock(cpt);
596 lnet_swap_pinginfo(lnet_ping_info_t *info)
599 lnet_ni_status_t *stat;
601 __swab32s(&info->pi_magic);
602 __swab32s(&info->pi_features);
603 __swab32s(&info->pi_pid);
604 __swab32s(&info->pi_nnis);
605 for (i = 0; i < info->pi_nnis && i < LNET_MAX_RTR_NIS; i++) {
606 stat = &info->pi_ni[i];
607 __swab64s(&stat->ns_nid);
608 __swab32s(&stat->ns_status);
614 * parse router-checker pinginfo, record number of down NIs for remote
615 * networks on that router.
618 lnet_parse_rc_info(lnet_rc_data_t *rcd)
620 lnet_ping_info_t *info = rcd->rcd_pinginfo;
621 struct lnet_peer *gw = rcd->rcd_gateway;
627 if (info->pi_magic == __swab32(LNET_PROTO_PING_MAGIC))
628 lnet_swap_pinginfo(info);
630 /* NB always racing with network! */
631 if (info->pi_magic != LNET_PROTO_PING_MAGIC) {
632 CDEBUG(D_NET, "%s: Unexpected magic %08x\n",
633 libcfs_nid2str(gw->lp_nid), info->pi_magic);
634 gw->lp_ping_feats = LNET_PING_FEAT_INVAL;
638 gw->lp_ping_feats = info->pi_features;
639 if ((gw->lp_ping_feats & LNET_PING_FEAT_MASK) == 0) {
640 CDEBUG(D_NET, "%s: Unexpected features 0x%x\n",
641 libcfs_nid2str(gw->lp_nid), gw->lp_ping_feats);
642 return; /* nothing I can understand */
645 if ((gw->lp_ping_feats & LNET_PING_FEAT_NI_STATUS) == 0)
646 return; /* can't carry NI status info */
648 cfs_list_for_each_entry(rtr, &gw->lp_routes, lr_gwlist) {
649 int ptl_status = LNET_NI_STATUS_INVALID;
654 for (i = 0; i < info->pi_nnis && i < LNET_MAX_RTR_NIS; i++) {
655 lnet_ni_status_t *stat = &info->pi_ni[i];
656 lnet_nid_t nid = stat->ns_nid;
658 if (nid == LNET_NID_ANY) {
659 CDEBUG(D_NET, "%s: unexpected LNET_NID_ANY\n",
660 libcfs_nid2str(gw->lp_nid));
661 gw->lp_ping_feats = LNET_PING_FEAT_INVAL;
665 if (LNET_NETTYP(LNET_NIDNET(nid)) == LOLND)
668 if (stat->ns_status == LNET_NI_STATUS_DOWN) {
669 if (LNET_NETTYP(LNET_NIDNET(nid)) != PTLLND)
671 else if (ptl_status != LNET_NI_STATUS_UP)
672 ptl_status = LNET_NI_STATUS_DOWN;
676 if (stat->ns_status == LNET_NI_STATUS_UP) {
677 if (LNET_NIDNET(nid) == rtr->lr_net) {
681 /* ptl NIs are considered down only when
682 * they're all down */
683 if (LNET_NETTYP(LNET_NIDNET(nid)) == PTLLND)
684 ptl_status = LNET_NI_STATUS_UP;
688 CDEBUG(D_NET, "%s: Unexpected status 0x%x\n",
689 libcfs_nid2str(gw->lp_nid), stat->ns_status);
690 gw->lp_ping_feats = LNET_PING_FEAT_INVAL;
694 if (up) { /* ignore downed NIs if NI for dest network is up */
698 rtr->lr_downis = down + (ptl_status == LNET_NI_STATUS_DOWN);
703 lnet_router_checker_event(lnet_event_t *event)
705 lnet_rc_data_t *rcd = event->md.user_ptr;
706 struct lnet_peer *lp;
708 LASSERT(rcd != NULL);
710 if (event->unlinked) {
711 LNetInvalidateHandle(&rcd->rcd_mdh);
715 LASSERT(event->type == LNET_EVENT_SEND ||
716 event->type == LNET_EVENT_REPLY);
718 lp = rcd->rcd_gateway;
721 /* NB: it's called with holding lnet_res_lock, we have a few
722 * places need to hold both locks at the same time, please take
723 * care of lock ordering */
724 lnet_net_lock(lp->lp_cpt);
725 if (!lnet_isrouter(lp) || lp->lp_rcd != rcd) {
726 /* ignore if no longer a router or rcd is replaced */
730 if (event->type == LNET_EVENT_SEND) {
731 lp->lp_ping_notsent = 0;
732 if (event->status == 0)
736 /* LNET_EVENT_REPLY */
737 /* A successful REPLY means the router is up. If _any_ comms
738 * to the router fail I assume it's down (this will happen if
739 * we ping alive routers to try to detect router death before
740 * apps get burned). */
742 lnet_notify_locked(lp, 1, (event->status == 0), cfs_time_current());
743 /* The router checker will wake up very shortly and do the
744 * actual notification.
745 * XXX If 'lp' stops being a router before then, it will still
746 * have the notification pending!!! */
748 if (avoid_asym_router_failure && event->status == 0)
749 lnet_parse_rc_info(rcd);
752 lnet_net_unlock(lp->lp_cpt);
756 lnet_wait_known_routerstate(void)
762 LASSERT (the_lnet.ln_rc_state == LNET_RC_STATE_RUNNING);
765 int cpt = lnet_net_lock_current();
768 cfs_list_for_each (entry, &the_lnet.ln_routers) {
769 rtr = cfs_list_entry(entry, lnet_peer_t, lp_rtr_list);
771 if (rtr->lp_alive_count == 0) {
777 lnet_net_unlock(cpt);
783 lnet_router_checker();
785 cfs_pause(cfs_time_seconds(1));
790 lnet_update_ni_status_locked(void)
796 LASSERT(the_lnet.ln_routing);
798 timeout = router_ping_timeout +
799 MAX(live_router_check_interval, dead_router_check_interval);
801 now = cfs_time_current_sec();
802 cfs_list_for_each_entry(ni, &the_lnet.ln_nis, ni_list) {
803 if (ni->ni_lnd->lnd_type == LOLND)
806 if (now < ni->ni_last_alive + timeout)
810 /* re-check with lock */
811 if (now < ni->ni_last_alive + timeout) {
816 LASSERT(ni->ni_status != NULL);
818 if (ni->ni_status->ns_status != LNET_NI_STATUS_DOWN) {
819 CDEBUG(D_NET, "NI(%s:%d) status changed to down\n",
820 libcfs_nid2str(ni->ni_nid), timeout);
821 /* NB: so far, this is the only place to set
822 * NI status to "down" */
823 ni->ni_status->ns_status = LNET_NI_STATUS_DOWN;
830 lnet_destroy_rc_data(lnet_rc_data_t *rcd)
832 LASSERT(cfs_list_empty(&rcd->rcd_list));
833 /* detached from network */
834 LASSERT(LNetHandleIsInvalid(rcd->rcd_mdh));
836 if (rcd->rcd_gateway != NULL) {
837 int cpt = rcd->rcd_gateway->lp_cpt;
840 lnet_peer_decref_locked(rcd->rcd_gateway);
841 lnet_net_unlock(cpt);
844 if (rcd->rcd_pinginfo != NULL)
845 LIBCFS_FREE(rcd->rcd_pinginfo, LNET_PINGINFO_SIZE);
847 LIBCFS_FREE(rcd, sizeof(*rcd));
851 lnet_create_rc_data_locked(lnet_peer_t *gateway)
853 lnet_rc_data_t *rcd = NULL;
854 lnet_ping_info_t *pi;
858 lnet_net_unlock(gateway->lp_cpt);
860 LIBCFS_ALLOC(rcd, sizeof(*rcd));
864 LNetInvalidateHandle(&rcd->rcd_mdh);
865 CFS_INIT_LIST_HEAD(&rcd->rcd_list);
867 LIBCFS_ALLOC(pi, LNET_PINGINFO_SIZE);
871 memset(pi, 0, LNET_PINGINFO_SIZE);
872 for (i = 0; i < LNET_MAX_RTR_NIS; i++) {
873 pi->pi_ni[i].ns_nid = LNET_NID_ANY;
874 pi->pi_ni[i].ns_status = LNET_NI_STATUS_INVALID;
876 rcd->rcd_pinginfo = pi;
878 LASSERT (!LNetHandleIsInvalid(the_lnet.ln_rc_eqh));
879 rc = LNetMDBind((lnet_md_t){.start = pi,
881 .length = LNET_PINGINFO_SIZE,
882 .threshold = LNET_MD_THRESH_INF,
883 .options = LNET_MD_TRUNCATE,
884 .eq_handle = the_lnet.ln_rc_eqh},
888 CERROR("Can't bind MD: %d\n", rc);
893 lnet_net_lock(gateway->lp_cpt);
894 /* router table changed or someone has created rcd for this gateway */
895 if (!lnet_isrouter(gateway) || gateway->lp_rcd != NULL) {
896 lnet_net_unlock(gateway->lp_cpt);
900 lnet_peer_addref_locked(gateway);
901 rcd->rcd_gateway = gateway;
902 gateway->lp_rcd = rcd;
903 gateway->lp_ping_notsent = 0;
909 if (!LNetHandleIsInvalid(rcd->rcd_mdh)) {
910 rc = LNetMDUnlink(rcd->rcd_mdh);
913 lnet_destroy_rc_data(rcd);
916 lnet_net_lock(gateway->lp_cpt);
917 return gateway->lp_rcd;
921 lnet_router_check_interval (lnet_peer_t *rtr)
925 secs = rtr->lp_alive ? live_router_check_interval :
926 dead_router_check_interval;
934 lnet_ping_router_locked (lnet_peer_t *rtr)
936 lnet_rc_data_t *rcd = NULL;
937 cfs_time_t now = cfs_time_current();
940 lnet_peer_addref_locked(rtr);
942 if (rtr->lp_ping_deadline != 0 && /* ping timed out? */
943 cfs_time_after(now, rtr->lp_ping_deadline))
944 lnet_notify_locked(rtr, 1, 0, now);
946 /* Run any outstanding notifications */
947 lnet_ni_notify_locked(rtr->lp_ni, rtr);
949 if (!lnet_isrouter(rtr) ||
950 the_lnet.ln_rc_state != LNET_RC_STATE_RUNNING) {
951 /* router table changed or router checker is shutting down */
952 lnet_peer_decref_locked(rtr);
956 rcd = rtr->lp_rcd != NULL ?
957 rtr->lp_rcd : lnet_create_rc_data_locked(rtr);
962 secs = lnet_router_check_interval(rtr);
965 "rtr %s %d: deadline %lu ping_notsent %d alive %d "
966 "alive_count %d lp_ping_timestamp %lu\n",
967 libcfs_nid2str(rtr->lp_nid), secs,
968 rtr->lp_ping_deadline, rtr->lp_ping_notsent,
969 rtr->lp_alive, rtr->lp_alive_count, rtr->lp_ping_timestamp);
971 if (secs != 0 && !rtr->lp_ping_notsent &&
972 cfs_time_after(now, cfs_time_add(rtr->lp_ping_timestamp,
973 cfs_time_seconds(secs)))) {
975 lnet_process_id_t id;
976 lnet_handle_md_t mdh;
978 id.nid = rtr->lp_nid;
979 id.pid = LUSTRE_SRV_LNET_PID;
980 CDEBUG(D_NET, "Check: %s\n", libcfs_id2str(id));
982 rtr->lp_ping_notsent = 1;
983 rtr->lp_ping_timestamp = now;
987 if (rtr->lp_ping_deadline == 0) {
988 rtr->lp_ping_deadline =
989 cfs_time_shift(router_ping_timeout);
992 lnet_net_unlock(rtr->lp_cpt);
994 rc = LNetGet(LNET_NID_ANY, mdh, id, LNET_RESERVED_PORTAL,
995 LNET_PROTO_PING_MATCHBITS, 0);
997 lnet_net_lock(rtr->lp_cpt);
999 rtr->lp_ping_notsent = 0; /* no event pending */
1002 lnet_peer_decref_locked(rtr);
1007 lnet_router_checker_start(void)
1015 int router_checker_max_eqsize = 10240;
1017 LASSERT (check_routers_before_use);
1018 LASSERT (dead_router_check_interval > 0);
1022 /* As an approximation, allow each router the same number of
1023 * outstanding events as it is allowed outstanding sends */
1025 version = the_lnet.ln_routers_version;
1026 cfs_list_for_each_entry(rtr, &the_lnet.ln_routers, lp_rtr_list) {
1027 lnet_ni_t *ni = rtr->lp_ni;
1028 lnet_process_id_t id;
1031 eqsz += ni->ni_peertxcredits;
1033 /* one async ping reply per router */
1034 id.nid = rtr->lp_nid;
1035 id.pid = LUSTRE_SRV_LNET_PID;
1039 rc = LNetSetAsync(id, 1);
1041 CWARN("LNetSetAsync %s failed: %d\n",
1042 libcfs_id2str(id), rc);
1047 /* NB router list doesn't change in userspace */
1048 LASSERT(version == the_lnet.ln_routers_version);
1055 "No router found, not starting router checker\n");
1059 /* at least allow a SENT and a REPLY per router */
1060 if (router_checker_max_eqsize < 2 * nrtr)
1061 router_checker_max_eqsize = 2 * nrtr;
1064 if (eqsz > router_checker_max_eqsize)
1065 eqsz = router_checker_max_eqsize;
1068 LASSERT (the_lnet.ln_rc_state == LNET_RC_STATE_SHUTDOWN);
1070 if (check_routers_before_use &&
1071 dead_router_check_interval <= 0) {
1072 LCONSOLE_ERROR_MSG(0x10a, "'dead_router_check_interval' must be"
1073 " set if 'check_routers_before_use' is set"
1078 if (!the_lnet.ln_routing &&
1079 live_router_check_interval <= 0 &&
1080 dead_router_check_interval <= 0)
1084 sema_init(&the_lnet.ln_rc_signal, 0);
1085 /* EQ size doesn't matter; the callback is guaranteed to get every
1088 rc = LNetEQAlloc(eqsz, lnet_router_checker_event,
1089 &the_lnet.ln_rc_eqh);
1091 rc = LNetEQAlloc(eqsz, LNET_EQ_HANDLER_NONE,
1092 &the_lnet.ln_rc_eqh);
1095 CERROR("Can't allocate EQ(%d): %d\n", eqsz, rc);
1099 the_lnet.ln_rc_state = LNET_RC_STATE_RUNNING;
1101 rc = PTR_ERR(kthread_run(lnet_router_checker,
1102 NULL, "router_checker"));
1103 if (IS_ERR_VALUE(rc)) {
1104 CERROR("Can't start router checker thread: %d\n", rc);
1105 /* block until event callback signals exit */
1106 down(&the_lnet.ln_rc_signal);
1107 rc = LNetEQFree(the_lnet.ln_rc_eqh);
1109 the_lnet.ln_rc_state = LNET_RC_STATE_SHUTDOWN;
1114 if (check_routers_before_use) {
1115 /* Note that a helpful side-effect of pinging all known routers
1116 * at startup is that it makes them drop stale connections they
1117 * may have to a previous instance of me. */
1118 lnet_wait_known_routerstate();
1125 lnet_router_checker_stop (void)
1129 if (the_lnet.ln_rc_state == LNET_RC_STATE_SHUTDOWN)
1132 LASSERT (the_lnet.ln_rc_state == LNET_RC_STATE_RUNNING);
1133 the_lnet.ln_rc_state = LNET_RC_STATE_STOPPING;
1136 /* block until event callback signals exit */
1137 down(&the_lnet.ln_rc_signal);
1139 lnet_router_checker();
1141 LASSERT(the_lnet.ln_rc_state == LNET_RC_STATE_SHUTDOWN);
1143 rc = LNetEQFree(the_lnet.ln_rc_eqh);
1149 lnet_prune_rc_data(int wait_unlink)
1151 lnet_rc_data_t *rcd;
1152 lnet_rc_data_t *tmp;
1157 if (likely(the_lnet.ln_rc_state == LNET_RC_STATE_RUNNING &&
1158 cfs_list_empty(&the_lnet.ln_rcd_deathrow) &&
1159 cfs_list_empty(&the_lnet.ln_rcd_zombie)))
1162 CFS_INIT_LIST_HEAD(&head);
1164 lnet_net_lock(LNET_LOCK_EX);
1166 if (the_lnet.ln_rc_state != LNET_RC_STATE_RUNNING) {
1167 /* router checker is stopping, prune all */
1168 cfs_list_for_each_entry(lp, &the_lnet.ln_routers,
1170 if (lp->lp_rcd == NULL)
1173 LASSERT(cfs_list_empty(&lp->lp_rcd->rcd_list));
1174 cfs_list_add(&lp->lp_rcd->rcd_list,
1175 &the_lnet.ln_rcd_deathrow);
1180 /* unlink all RCDs on deathrow list */
1181 cfs_list_splice_init(&the_lnet.ln_rcd_deathrow, &head);
1183 if (!cfs_list_empty(&head)) {
1184 lnet_net_unlock(LNET_LOCK_EX);
1186 cfs_list_for_each_entry(rcd, &head, rcd_list)
1187 LNetMDUnlink(rcd->rcd_mdh);
1189 lnet_net_lock(LNET_LOCK_EX);
1192 cfs_list_splice_init(&head, &the_lnet.ln_rcd_zombie);
1194 /* release all zombie RCDs */
1195 while (!cfs_list_empty(&the_lnet.ln_rcd_zombie)) {
1196 cfs_list_for_each_entry_safe(rcd, tmp, &the_lnet.ln_rcd_zombie,
1198 if (LNetHandleIsInvalid(rcd->rcd_mdh))
1199 cfs_list_move(&rcd->rcd_list, &head);
1202 wait_unlink = wait_unlink &&
1203 !cfs_list_empty(&the_lnet.ln_rcd_zombie);
1205 lnet_net_unlock(LNET_LOCK_EX);
1207 while (!cfs_list_empty(&head)) {
1208 rcd = cfs_list_entry(head.next,
1209 lnet_rc_data_t, rcd_list);
1210 cfs_list_del_init(&rcd->rcd_list);
1211 lnet_destroy_rc_data(rcd);
1218 CDEBUG(((i & (-i)) == i) ? D_WARNING : D_NET,
1219 "Waiting for rc buffers to unlink\n");
1220 cfs_pause(cfs_time_seconds(1) / 4);
1222 lnet_net_lock(LNET_LOCK_EX);
1225 lnet_net_unlock(LNET_LOCK_EX);
1229 #if defined(__KERNEL__) && defined(LNET_ROUTER)
1232 lnet_router_checker(void *arg)
1237 cfs_block_allsigs();
1239 LASSERT (the_lnet.ln_rc_state == LNET_RC_STATE_RUNNING);
1241 while (the_lnet.ln_rc_state == LNET_RC_STATE_RUNNING) {
1246 cpt = lnet_net_lock_current();
1248 version = the_lnet.ln_routers_version;
1250 cfs_list_for_each(entry, &the_lnet.ln_routers) {
1251 rtr = cfs_list_entry(entry, lnet_peer_t, lp_rtr_list);
1253 cpt2 = lnet_cpt_of_nid_locked(rtr->lp_nid);
1255 lnet_net_unlock(cpt);
1258 /* the routers list has changed */
1259 if (version != the_lnet.ln_routers_version)
1263 lnet_ping_router_locked(rtr);
1265 /* NB dropped lock */
1266 if (version != the_lnet.ln_routers_version) {
1267 /* the routers list has changed */
1272 if (the_lnet.ln_routing)
1273 lnet_update_ni_status_locked();
1275 lnet_net_unlock(cpt);
1277 lnet_prune_rc_data(0); /* don't wait for UNLINK */
1279 /* Call cfs_pause() here always adds 1 to load average
1280 * because kernel counts # active tasks as nr_running
1281 * + nr_uninterruptible. */
1282 schedule_timeout_and_set_state(TASK_INTERRUPTIBLE,
1283 cfs_time_seconds(1));
1286 LASSERT(the_lnet.ln_rc_state == LNET_RC_STATE_STOPPING);
1288 lnet_prune_rc_data(1); /* wait for UNLINK */
1290 the_lnet.ln_rc_state = LNET_RC_STATE_SHUTDOWN;
1291 up(&the_lnet.ln_rc_signal);
1292 /* The unlink event callback will signal final completion */
1297 lnet_destroy_rtrbuf(lnet_rtrbuf_t *rb, int npages)
1299 int sz = offsetof(lnet_rtrbuf_t, rb_kiov[npages]);
1301 while (--npages >= 0)
1302 __free_page(rb->rb_kiov[npages].kiov_page);
1304 LIBCFS_FREE(rb, sz);
1308 lnet_new_rtrbuf(lnet_rtrbufpool_t *rbp, int cpt)
1310 int npages = rbp->rbp_npages;
1311 int sz = offsetof(lnet_rtrbuf_t, rb_kiov[npages]);
1316 LIBCFS_CPT_ALLOC(rb, lnet_cpt_table(), cpt, sz);
1322 for (i = 0; i < npages; i++) {
1323 page = cfs_page_cpt_alloc(lnet_cpt_table(), cpt,
1324 __GFP_ZERO | GFP_IOFS);
1327 __free_page(rb->rb_kiov[i].kiov_page);
1329 LIBCFS_FREE(rb, sz);
1333 rb->rb_kiov[i].kiov_len = PAGE_CACHE_SIZE;
1334 rb->rb_kiov[i].kiov_offset = 0;
1335 rb->rb_kiov[i].kiov_page = page;
1342 lnet_rtrpool_free_bufs(lnet_rtrbufpool_t *rbp)
1344 int npages = rbp->rbp_npages;
1348 if (rbp->rbp_nbuffers == 0) /* not initialized or already freed */
1351 LASSERT (cfs_list_empty(&rbp->rbp_msgs));
1352 LASSERT (rbp->rbp_credits == rbp->rbp_nbuffers);
1354 while (!cfs_list_empty(&rbp->rbp_bufs)) {
1355 LASSERT (rbp->rbp_credits > 0);
1357 rb = cfs_list_entry(rbp->rbp_bufs.next,
1358 lnet_rtrbuf_t, rb_list);
1359 cfs_list_del(&rb->rb_list);
1360 lnet_destroy_rtrbuf(rb, npages);
1364 LASSERT (rbp->rbp_nbuffers == nbuffers);
1365 LASSERT (rbp->rbp_credits == nbuffers);
1367 rbp->rbp_nbuffers = rbp->rbp_credits = 0;
1371 lnet_rtrpool_alloc_bufs(lnet_rtrbufpool_t *rbp, int nbufs, int cpt)
1376 if (rbp->rbp_nbuffers != 0) {
1377 LASSERT (rbp->rbp_nbuffers == nbufs);
1381 for (i = 0; i < nbufs; i++) {
1382 rb = lnet_new_rtrbuf(rbp, cpt);
1385 CERROR("Failed to allocate %d router bufs of %d pages\n",
1386 nbufs, rbp->rbp_npages);
1390 rbp->rbp_nbuffers++;
1392 rbp->rbp_mincredits++;
1393 cfs_list_add(&rb->rb_list, &rbp->rbp_bufs);
1395 /* No allocation "under fire" */
1396 /* Otherwise we'd need code to schedule blocked msgs etc */
1397 LASSERT (!the_lnet.ln_routing);
1400 LASSERT (rbp->rbp_credits == nbufs);
1405 lnet_rtrpool_init(lnet_rtrbufpool_t *rbp, int npages)
1407 CFS_INIT_LIST_HEAD(&rbp->rbp_msgs);
1408 CFS_INIT_LIST_HEAD(&rbp->rbp_bufs);
1410 rbp->rbp_npages = npages;
1411 rbp->rbp_credits = 0;
1412 rbp->rbp_mincredits = 0;
1416 lnet_rtrpools_free(void)
1418 lnet_rtrbufpool_t *rtrp;
1421 if (the_lnet.ln_rtrpools == NULL) /* uninitialized or freed */
1424 cfs_percpt_for_each(rtrp, i, the_lnet.ln_rtrpools) {
1425 lnet_rtrpool_free_bufs(&rtrp[0]);
1426 lnet_rtrpool_free_bufs(&rtrp[1]);
1427 lnet_rtrpool_free_bufs(&rtrp[2]);
1430 cfs_percpt_free(the_lnet.ln_rtrpools);
1431 the_lnet.ln_rtrpools = NULL;
1435 lnet_nrb_tiny_calculate(int npages)
1437 int nrbs = LNET_NRB_TINY;
1439 if (tiny_router_buffers < 0) {
1440 LCONSOLE_ERROR_MSG(0x10c,
1441 "tiny_router_buffers=%d invalid when "
1442 "routing enabled\n", tiny_router_buffers);
1446 if (tiny_router_buffers > 0)
1447 nrbs = tiny_router_buffers;
1449 nrbs /= LNET_CPT_NUMBER;
1450 return max(nrbs, LNET_NRB_TINY_MIN);
1454 lnet_nrb_small_calculate(int npages)
1456 int nrbs = LNET_NRB_SMALL;
1458 if (small_router_buffers < 0) {
1459 LCONSOLE_ERROR_MSG(0x10c,
1460 "small_router_buffers=%d invalid when "
1461 "routing enabled\n", small_router_buffers);
1465 if (small_router_buffers > 0)
1466 nrbs = small_router_buffers;
1468 nrbs /= LNET_CPT_NUMBER;
1469 return max(nrbs, LNET_NRB_SMALL_MIN);
1473 lnet_nrb_large_calculate(int npages)
1475 int nrbs = LNET_NRB_LARGE;
1477 if (large_router_buffers < 0) {
1478 LCONSOLE_ERROR_MSG(0x10c,
1479 "large_router_buffers=%d invalid when "
1480 "routing enabled\n", large_router_buffers);
1484 if (large_router_buffers > 0)
1485 nrbs = large_router_buffers;
1487 nrbs /= LNET_CPT_NUMBER;
1488 return max(nrbs, LNET_NRB_LARGE_MIN);
1492 lnet_rtrpools_alloc(int im_a_router)
1494 lnet_rtrbufpool_t *rtrp;
1495 int large_pages = (LNET_MTU + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT;
1496 int small_pages = 1;
1503 if (!strcmp(forwarding, "")) {
1504 /* not set either way */
1507 } else if (!strcmp(forwarding, "disabled")) {
1508 /* explicitly disabled */
1510 } else if (!strcmp(forwarding, "enabled")) {
1511 /* explicitly enabled */
1513 LCONSOLE_ERROR_MSG(0x10b, "'forwarding' not set to either "
1514 "'enabled' or 'disabled'\n");
1518 nrb_tiny = lnet_nrb_tiny_calculate(0);
1522 nrb_small = lnet_nrb_small_calculate(small_pages);
1526 nrb_large = lnet_nrb_large_calculate(large_pages);
1530 the_lnet.ln_rtrpools = cfs_percpt_alloc(lnet_cpt_table(),
1532 sizeof(lnet_rtrbufpool_t));
1533 if (the_lnet.ln_rtrpools == NULL) {
1534 LCONSOLE_ERROR_MSG(0x10c,
1535 "Failed to initialize router buffe pool\n");
1539 cfs_percpt_for_each(rtrp, i, the_lnet.ln_rtrpools) {
1540 lnet_rtrpool_init(&rtrp[0], 0);
1541 rc = lnet_rtrpool_alloc_bufs(&rtrp[0], nrb_tiny, i);
1545 lnet_rtrpool_init(&rtrp[1], small_pages);
1546 rc = lnet_rtrpool_alloc_bufs(&rtrp[1], nrb_small, i);
1550 lnet_rtrpool_init(&rtrp[2], large_pages);
1551 rc = lnet_rtrpool_alloc_bufs(&rtrp[2], nrb_large, i);
1556 lnet_net_lock(LNET_LOCK_EX);
1557 the_lnet.ln_routing = 1;
1558 lnet_net_unlock(LNET_LOCK_EX);
1563 lnet_rtrpools_free();
1568 lnet_notify(lnet_ni_t *ni, lnet_nid_t nid, int alive, cfs_time_t when)
1570 struct lnet_peer *lp = NULL;
1571 cfs_time_t now = cfs_time_current();
1572 int cpt = lnet_cpt_of_nid(nid);
1574 LASSERT (!cfs_in_interrupt ());
1576 CDEBUG (D_NET, "%s notifying %s: %s\n",
1577 (ni == NULL) ? "userspace" : libcfs_nid2str(ni->ni_nid),
1578 libcfs_nid2str(nid),
1579 alive ? "up" : "down");
1582 LNET_NIDNET(ni->ni_nid) != LNET_NIDNET(nid)) {
1583 CWARN ("Ignoring notification of %s %s by %s (different net)\n",
1584 libcfs_nid2str(nid), alive ? "birth" : "death",
1585 libcfs_nid2str(ni->ni_nid));
1589 /* can't do predictions... */
1590 if (cfs_time_after(when, now)) {
1591 CWARN ("Ignoring prediction from %s of %s %s "
1592 "%ld seconds in the future\n",
1593 (ni == NULL) ? "userspace" : libcfs_nid2str(ni->ni_nid),
1594 libcfs_nid2str(nid), alive ? "up" : "down",
1595 cfs_duration_sec(cfs_time_sub(when, now)));
1599 if (ni != NULL && !alive && /* LND telling me she's down */
1600 !auto_down) { /* auto-down disabled */
1601 CDEBUG(D_NET, "Auto-down disabled\n");
1607 if (the_lnet.ln_shutdown) {
1608 lnet_net_unlock(cpt);
1612 lp = lnet_find_peer_locked(the_lnet.ln_peer_tables[cpt], nid);
1615 lnet_net_unlock(cpt);
1616 CDEBUG(D_NET, "%s not found\n", libcfs_nid2str(nid));
1620 /* We can't fully trust LND on reporting exact peer last_alive
1621 * if he notifies us about dead peer. For example ksocklnd can
1622 * call us with when == _time_when_the_node_was_booted_ if
1623 * no connections were successfully established */
1624 if (ni != NULL && !alive && when < lp->lp_last_alive)
1625 when = lp->lp_last_alive;
1627 lnet_notify_locked(lp, ni == NULL, alive, when);
1629 lnet_ni_notify_locked(ni, lp);
1631 lnet_peer_decref_locked(lp);
1633 lnet_net_unlock(cpt);
1636 EXPORT_SYMBOL(lnet_notify);
1639 lnet_get_tunables (void)
1647 lnet_notify (lnet_ni_t *ni, lnet_nid_t nid, int alive, cfs_time_t when)
1653 lnet_router_checker (void)
1655 static time_t last = 0;
1656 static int running = 0;
1658 time_t now = cfs_time_current_sec();
1659 int interval = now - last;
1664 /* It's no use to call me again within a sec - all intervals and
1665 * timeouts are measured in seconds */
1666 if (last != 0 && interval < 2)
1670 interval > MAX(live_router_check_interval,
1671 dead_router_check_interval))
1672 CNETERR("Checker(%d/%d) not called for %d seconds\n",
1673 live_router_check_interval, dead_router_check_interval,
1676 LASSERT(LNET_CPT_NUMBER == 1);
1679 LASSERT(!running); /* recursion check */
1685 if (the_lnet.ln_rc_state == LNET_RC_STATE_STOPPING)
1686 lnet_prune_rc_data(0); /* unlink all rcd and nowait */
1688 /* consume all pending events */
1693 /* NB ln_rc_eqh must be the 1st in 'eventqs' otherwise the
1694 * recursion breaker in LNetEQPoll would fail */
1695 rc = LNetEQPoll(&the_lnet.ln_rc_eqh, 1, 0, &ev, &i);
1696 if (rc == 0) /* no event pending */
1699 /* NB a lost SENT prevents me from pinging a router again */
1700 if (rc == -EOVERFLOW) {
1701 CERROR("Dropped an event!!!\n");
1707 lnet_router_checker_event(&ev);
1710 if (the_lnet.ln_rc_state == LNET_RC_STATE_STOPPING) {
1711 lnet_prune_rc_data(1); /* release rcd */
1712 the_lnet.ln_rc_state = LNET_RC_STATE_SHUTDOWN;
1717 LASSERT (the_lnet.ln_rc_state == LNET_RC_STATE_RUNNING);
1721 version = the_lnet.ln_routers_version;
1722 cfs_list_for_each_entry (rtr, &the_lnet.ln_routers, lp_rtr_list) {
1723 lnet_ping_router_locked(rtr);
1724 LASSERT (version == the_lnet.ln_routers_version);
1729 running = 0; /* lock only needed for the recursion check */
1733 /* NB lnet_peers_start_down depends on me,
1734 * so must be called before any peer creation */
1736 lnet_get_tunables (void)
1740 s = getenv("LNET_ROUTER_PING_TIMEOUT");
1741 if (s != NULL) router_ping_timeout = atoi(s);
1743 s = getenv("LNET_LIVE_ROUTER_CHECK_INTERVAL");
1744 if (s != NULL) live_router_check_interval = atoi(s);
1746 s = getenv("LNET_DEAD_ROUTER_CHECK_INTERVAL");
1747 if (s != NULL) dead_router_check_interval = atoi(s);
1749 /* This replaces old lnd_notify mechanism */
1750 check_routers_before_use = 1;
1751 if (dead_router_check_interval <= 0)
1752 dead_router_check_interval = 30;
1756 lnet_rtrpools_free(void)
1761 lnet_rtrpools_alloc(int im_a_arouter)