- LNET_UNLOCK();
- return 1;
- }
-
- order++;
- }
-
- cfs_list_for_each (e, &the_lnet.ln_remote_nets) {
- rnet = cfs_list_entry(e, lnet_remotenet_t, lrn_list);
-
- if (rnet->lrn_net == dstnet) {
- lnet_route_t *route;
- lnet_route_t *shortest = NULL;
-
- LASSERT (!cfs_list_empty(&rnet->lrn_routes));
-
- cfs_list_for_each_entry(route, &rnet->lrn_routes,
- lr_list) {
- if (shortest == NULL ||
- route->lr_hops < shortest->lr_hops)
- shortest = route;
- }
-
- LASSERT (shortest != NULL);
- hops = shortest->lr_hops;
- if (srcnidp != NULL)
- *srcnidp = shortest->lr_gateway->lp_ni->ni_nid;
- if (orderp != NULL)
- *orderp = order;
- LNET_UNLOCK();
- return hops + 1;
- }
- order++;
- }
-
- LNET_UNLOCK();
- return -EHOSTUNREACH;
-}
-
-/**
- * Set the number of asynchronous messages expected from a target process.
- *
- * This function is only meaningful for userspace callers. It's a no-op when
- * called from kernel.
- *
- * Asynchronous messages are those that can come from a target when the
- * userspace process is not waiting for IO to complete; e.g., AST callbacks
- * from Lustre servers. Specifying the expected number of such messages
- * allows them to be eagerly received when user process is not running in
- * LNet; otherwise network errors may occur.
- *
- * \param id Process ID of the target process.
- * \param nasync Number of asynchronous messages expected from the target.
- *
- * \return 0 on success, and an error code otherwise.
- */
-int
-LNetSetAsync(lnet_process_id_t id, int nasync)
-{
-#ifdef __KERNEL__
- return 0;
-#else
- lnet_ni_t *ni;
- lnet_remotenet_t *rnet;
- cfs_list_t *tmp;
- lnet_route_t *route;
- lnet_nid_t *nids;
- int nnids;
- int maxnids = 256;
- int rc = 0;
- int rc2;
-
- /* Target on a local network? */
- ni = lnet_net2ni(LNET_NIDNET(id.nid));
- if (ni != NULL) {
- if (ni->ni_lnd->lnd_setasync != NULL)
- rc = (ni->ni_lnd->lnd_setasync)(ni, id, nasync);
- lnet_ni_decref(ni);
- return rc;
- }
-
- /* Target on a remote network: apply to routers */
- again:
- LIBCFS_ALLOC(nids, maxnids * sizeof(*nids));
- if (nids == NULL)
- return -ENOMEM;
- nnids = 0;
-
- /* Snapshot all the router NIDs */
- LNET_LOCK();
- rnet = lnet_find_net_locked(LNET_NIDNET(id.nid));
- if (rnet != NULL) {
- cfs_list_for_each(tmp, &rnet->lrn_routes) {
- if (nnids == maxnids) {
- LNET_UNLOCK();
- LIBCFS_FREE(nids, maxnids * sizeof(*nids));
- maxnids *= 2;
- goto again;
- }
-
- route = cfs_list_entry(tmp, lnet_route_t, lr_list);
- nids[nnids++] = route->lr_gateway->lp_nid;
- }
- }
- LNET_UNLOCK();
-
- /* set async on all the routers */
- while (nnids-- > 0) {
- id.pid = LUSTRE_SRV_LNET_PID;
- id.nid = nids[nnids];