/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
* vim:expandtab:shiftwidth=8:tabstop=8:
*
- * Copyright (C) 2002 Cluster File Systems, Inc.
+ * Copyright 2008 Sun Microsystems, Inc. All rights reserved
*
* This file is part of Portals
* http://sourceforge.net/projects/sandiaportals/
}
void
-lnet_do_notify (lnet_peer_t *lp)
+lnet_do_notify (lnet_peer_t *lp)
{
lnet_ni_t *ni = lp->lp_ni;
int alive;
int notifylnd;
-
+
LNET_LOCK();
-
+
/* Notify only in 1 thread at any time to ensure ordered notification.
* NB individual events can be missed; the only guarantee is that you
* always get the most recent news */
}
lp->lp_notifying = 1;
-
+
while (lp->lp_notify) {
alive = lp->lp_alive;
notifylnd = lp->lp_notifylnd;
CDEBUG(D_NET, "Auto-down disabled\n");
return 0;
}
-
+
LNET_LOCK();
lp = lnet_find_peer_locked(nid);
lnet_notify_locked(lp, ni == NULL, alive, when);
LNET_UNLOCK();
-
+
lnet_do_notify(lp);
-
+
LNET_LOCK();
lnet_peer_decref_locked(lp);
lnet_add_route (__u32 net, unsigned int hops, lnet_nid_t gateway)
{
struct list_head zombies;
- struct list_head *e;
- lnet_remotenet_t *rnet;
- lnet_remotenet_t *rnet2;
- lnet_route_t *route;
- lnet_route_t *route2;
+ struct list_head *e;
+ lnet_remotenet_t *rnet;
+ lnet_remotenet_t *rnet2;
+ lnet_route_t *route;
+ lnet_route_t *route2;
lnet_ni_t *ni;
int add_route;
int rc;
return -ENOMEM;
}
- INIT_LIST_HEAD(&rnet->lrn_routes);
+ CFS_INIT_LIST_HEAD(&rnet->lrn_routes);
rnet->lrn_net = net;
rnet->lrn_hops = hops;
LASSERT (route2->lr_gateway->lp_nid != gateway);
}
}
-
+
if (add_route) {
ni = route->lr_gateway->lp_ni;
lnet_ni_addref_locked(ni);
-
+
LASSERT (rc == 0);
list_add_tail(&route->lr_list, &rnet2->lrn_routes);
the_lnet.ln_remote_nets_version++;
while (!list_empty(&zombies)) {
route = list_entry(zombies.next, lnet_route_t, lr_list);
list_del(&route->lr_list);
-
+
LNET_LOCK();
+ lnet_rtr_decref_locked(route->lr_gateway);
lnet_peer_decref_locked(route->lr_gateway);
LNET_UNLOCK();
LIBCFS_FREE(route, sizeof(*route));
else if (route->lr_gateway->lp_ni !=
route2->lr_gateway->lp_ni) {
LNET_UNLOCK();
-
+
CERROR("Routes to %s via %s and %s not supported\n",
libcfs_net2str(rnet->lrn_net),
libcfs_nid2str(route->lr_gateway->lp_nid),
}
}
}
-
+
LNET_UNLOCK();
return 0;
}
lnet_get_route (int idx, __u32 *net, __u32 *hops,
lnet_nid_t *gateway, __u32 *alive)
{
- struct list_head *e1;
- struct list_head *e2;
+ struct list_head *e1;
+ struct list_head *e2;
lnet_remotenet_t *rnet;
lnet_route_t *route;
/* The router checker thread has unlinked the rc_md
* and exited. */
LASSERT (the_lnet.ln_rc_state == LNET_RC_STATE_UNLINKING);
- the_lnet.ln_rc_state = LNET_RC_STATE_UNLINKED;
- mutex_up(&the_lnet.ln_rc_signal);
+ the_lnet.ln_rc_state = LNET_RC_STATE_UNLINKED;
+ mutex_up(&the_lnet.ln_rc_signal);
return;
}
- LASSERT (event->type == LNET_EVENT_SEND ||
+ LASSERT (event->type == LNET_EVENT_SEND ||
event->type == LNET_EVENT_REPLY);
-
+
nid = (event->type == LNET_EVENT_SEND) ?
event->target.nid : event->initiator.nid;
if (lnet_isrouter(lp) && /* ignore if no longer a router */
(event->status != 0 ||
event->type == LNET_EVENT_REPLY)) {
-
+
/* A successful REPLY means the router is up. If _any_ comms
* to the router fail I assume it's down (this will happen if
* we ping alive routers to try to detect router death before
int rc;
lnet_handle_md_t mdh;
lnet_peer_t *rtr;
+ lnet_md_t md = {0};
struct list_head *entry;
time_t now;
lnet_process_id_t rtr_id;
int secs;
- cfs_daemonize("router_checker");
- cfs_block_allsigs();
+ cfs_daemonize("router_checker");
+ cfs_block_allsigs();
rtr_id.pid = LUSTRE_SRV_LNET_PID;
LASSERT (the_lnet.ln_rc_state == LNET_RC_STATE_SHUTDOWN);
- rc = LNetMDBind((lnet_md_t){.start = &pinginfo,
- .length = sizeof(pinginfo),
- .threshold = LNET_MD_THRESH_INF,
- .options = LNET_MD_TRUNCATE,
- .eq_handle = the_lnet.ln_rc_eqh},
- LNET_UNLINK,
- &mdh);
+ /* initialize md content */
+ md.start = &pinginfo;
+ md.length = sizeof(pinginfo);
+ md.threshold = LNET_MD_THRESH_INF;
+ md.max_size = 0;
+ md.options = LNET_MD_TRUNCATE,
+ md.user_ptr = NULL;
+ md.eq_handle = the_lnet.ln_rc_eqh;
+
+ rc = LNetMDBind(md, LNET_UNLINK, &mdh);
if (rc < 0) {
CERROR("Can't bind MD: %d\n", rc);
the_lnet.ln_rc_state = LNET_RC_STATE_RUNNING;
mutex_up(&the_lnet.ln_rc_signal); /* let my parent go */
- while (the_lnet.ln_rc_state == LNET_RC_STATE_RUNNING) {
+ while (the_lnet.ln_rc_state == LNET_RC_STATE_RUNNING) {
__u64 version;
LNET_LOCK();
}
if (secs <= 0)
secs = 0;
-
+
if (secs != 0 &&
!rtr->lp_ping_notsent &&
now > rtr->lp_ping_timestamp + secs) {
LNET_RESERVED_PORTAL,
LNET_PROTO_PING_MATCHBITS, 0);
}
-
+
LNET_LOCK();
lnet_peer_decref_locked(rtr);
/* Call cfs_pause() here always adds 1 to load average
* because kernel counts # active tasks as nr_running
* + nr_uninterruptible. */
- set_current_state(CFS_TASK_INTERRUPTIBLE);
cfs_schedule_timeout(CFS_TASK_INTERRUPTIBLE,
cfs_time_seconds(1));
- }
+ }
LASSERT (the_lnet.ln_rc_state == LNET_RC_STATE_STOPTHREAD);
the_lnet.ln_rc_state = LNET_RC_STATE_UNLINKING;
-
+
rc = LNetMDUnlink(mdh);
LASSERT (rc == 0);
/* The unlink event callback will signal final completion */
-
- return 0;
+ return 0;
}
for (;;) {
LNET_LOCK();
-
+
all_known = 1;
list_for_each (entry, &the_lnet.ln_routers) {
rtr = list_entry(entry, lnet_peer_t, lp_rtr_list);
-
+
if (rtr->lp_alive_count == 0) {
all_known = 0;
break;
return;
the_lnet.ln_rc_state = LNET_RC_STATE_STOPTHREAD;
- /* block until event callback signals exit */
- mutex_down(&the_lnet.ln_rc_signal);
+ /* block until event callback signals exit */
+ mutex_down(&the_lnet.ln_rc_signal);
LASSERT (the_lnet.ln_rc_state == LNET_RC_STATE_UNLINKED);
rc = LNetEQFree(the_lnet.ln_rc_eqh);
LASSERT (rc == 0);
-
+
the_lnet.ln_rc_state = LNET_RC_STATE_SHUTDOWN;
}
"\n");
return -EINVAL;
}
-
+
if (live_router_check_interval <= 0 &&
dead_router_check_interval <= 0)
return 0;
- init_mutex_locked(&the_lnet.ln_rc_signal);
+ init_mutex_locked(&the_lnet.ln_rc_signal);
/* EQ size doesn't matter; the callback is guaranteed to get every
* event */
return -ENOMEM;
}
- rc = (int)cfs_kernel_thread(lnet_router_checker, NULL, 0);
- if (rc < 0) {
- CERROR("Can't start router checker thread: %d\n", rc);
+ rc = (int)cfs_kernel_thread(lnet_router_checker, NULL, 0);
+ if (rc < 0) {
+ CERROR("Can't start router checker thread: %d\n", rc);
goto failed;
- }
+ }
- mutex_down(&the_lnet.ln_rc_signal); /* wait for checker to startup */
+ mutex_down(&the_lnet.ln_rc_signal); /* wait for checker to startup */
rc = the_lnet.ln_rc_state;
if (rc < 0) {
the_lnet.ln_rc_state = LNET_RC_STATE_SHUTDOWN;
goto failed;
}
-
+
LASSERT (the_lnet.ln_rc_state == LNET_RC_STATE_RUNNING);
if (check_routers_before_use) {
* may have to a previous instance of me. */
lnet_wait_known_routerstate();
}
-
+
return 0;
-
+
failed:
rc = LNetEQFree(the_lnet.ln_rc_eqh);
LASSERT (rc == 0);
LASSERT (rbp->rbp_nbuffers == nbufs);
return 0;
}
-
+
for (i = 0; i < nbufs; i++) {
rb = lnet_new_rtrbuf(rbp);
lnet_alloc_rtrpools(int im_a_router)
{
int rc;
-
+
if (!strcmp(forwarding, "")) {
/* not set either way */
if (!im_a_router)
"'enabled' or 'disabled'\n");
return -EINVAL;
}
-
+
if (tiny_router_buffers <= 0) {
LCONSOLE_ERROR_MSG(0x10c, "tiny_router_buffers=%d invalid when "
"routing enabled\n", tiny_router_buffers);
LNET_LOCK();
the_lnet.ln_routing = 1;
LNET_UNLOCK();
-
+
return 0;
failed: