Whamcloud - gitweb
LU-4423 lnet: don't use iovec instead of kvec
[fs/lustre-release.git] / lnet / lnet / lib-move.c
index 4211e4f..17a62c8 100644 (file)
@@ -27,7 +27,7 @@
  * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2012, 2013, Intel Corporation.
+ * Copyright (c) 2012, 2015, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -54,8 +54,6 @@ lnet_fail_nid(lnet_nid_t nid, unsigned int threshold)
        struct list_head *next;
        struct list_head  cull;
 
-       LASSERT(the_lnet.ln_init);
-
        /* NB: use lnet_net_lock(0) to serialize operations on test peers */
         if (threshold != 0) {
                 /* Adding a new entry */
@@ -158,7 +156,7 @@ fail_peer (lnet_nid_t nid, int outgoing)
 }
 
 unsigned int
-lnet_iov_nob (unsigned int niov, struct iovec *iov)
+lnet_iov_nob(unsigned int niov, struct kvec *iov)
 {
         unsigned int nob = 0;
 
@@ -171,9 +169,9 @@ lnet_iov_nob (unsigned int niov, struct iovec *iov)
 EXPORT_SYMBOL(lnet_iov_nob);
 
 void
-lnet_copy_iov2iov (unsigned int ndiov, struct iovec *diov, unsigned int doffset,
-                   unsigned int nsiov, struct iovec *siov, unsigned int soffset,
-                   unsigned int nob)
+lnet_copy_iov2iov(unsigned int ndiov, struct kvec *diov, unsigned int doffset,
+                 unsigned int nsiov, struct kvec *siov, unsigned int soffset,
+                 unsigned int nob)
 {
         /* NB diov, siov are READ-ONLY */
         unsigned int  this_nob;
@@ -230,9 +228,9 @@ lnet_copy_iov2iov (unsigned int ndiov, struct iovec *diov, unsigned int doffset,
 EXPORT_SYMBOL(lnet_copy_iov2iov);
 
 int
-lnet_extract_iov (int dst_niov, struct iovec *dst,
-                  int src_niov, struct iovec *src,
-                  unsigned int offset, unsigned int len)
+lnet_extract_iov(int dst_niov, struct kvec *dst,
+                int src_niov, struct kvec *src,
+                unsigned int offset, unsigned int len)
 {
         /* Initialise 'dst' to the subset of 'src' starting at 'offset',
          * for exactly 'len' bytes, and return the number of entries.
@@ -276,50 +274,9 @@ lnet_extract_iov (int dst_niov, struct iovec *dst,
 }
 EXPORT_SYMBOL(lnet_extract_iov);
 
-#ifndef __KERNEL__
-unsigned int
-lnet_kiov_nob (unsigned int niov, lnet_kiov_t *kiov)
-{
-        LASSERT (0);
-        return (0);
-}
-
-void
-lnet_copy_kiov2kiov (unsigned int ndkiov, lnet_kiov_t *dkiov, unsigned int doffset,
-                     unsigned int nskiov, lnet_kiov_t *skiov, unsigned int soffset,
-                     unsigned int nob)
-{
-        LASSERT (0);
-}
-
-void
-lnet_copy_kiov2iov (unsigned int niov, struct iovec *iov, unsigned int iovoffset,
-                    unsigned int nkiov, lnet_kiov_t *kiov, unsigned int kiovoffset,
-                    unsigned int nob)
-{
-        LASSERT (0);
-}
-
-void
-lnet_copy_iov2kiov (unsigned int nkiov, lnet_kiov_t *kiov, unsigned int kiovoffset,
-                    unsigned int niov, struct iovec *iov, unsigned int iovoffset,
-                    unsigned int nob)
-{
-        LASSERT (0);
-}
-
-int
-lnet_extract_kiov (int dst_niov, lnet_kiov_t *dst,
-                   int src_niov, lnet_kiov_t *src,
-                   unsigned int offset, unsigned int len)
-{
-        LASSERT (0);
-}
-
-#else /* __KERNEL__ */
 
 unsigned int
-lnet_kiov_nob (unsigned int niov, lnet_kiov_t *kiov)
+lnet_kiov_nob(unsigned int niov, lnet_kiov_t *kiov)
 {
         unsigned int  nob = 0;
 
@@ -332,9 +289,9 @@ lnet_kiov_nob (unsigned int niov, lnet_kiov_t *kiov)
 EXPORT_SYMBOL(lnet_kiov_nob);
 
 void
-lnet_copy_kiov2kiov (unsigned int ndiov, lnet_kiov_t *diov, unsigned int doffset,
-                     unsigned int nsiov, lnet_kiov_t *siov, unsigned int soffset,
-                     unsigned int nob)
+lnet_copy_kiov2kiov(unsigned int ndiov, lnet_kiov_t *diov, unsigned int doffset,
+                   unsigned int nsiov, lnet_kiov_t *siov, unsigned int soffset,
+                   unsigned int nob)
 {
        /* NB diov, siov are READ-ONLY */
        unsigned int    this_nob;
@@ -414,7 +371,7 @@ lnet_copy_kiov2kiov (unsigned int ndiov, lnet_kiov_t *diov, unsigned int doffset
 EXPORT_SYMBOL(lnet_copy_kiov2kiov);
 
 void
-lnet_copy_kiov2iov (unsigned int niov, struct iovec *iov, unsigned int iovoffset,
+lnet_copy_kiov2iov (unsigned int niov, struct kvec *iov, unsigned int iovoffset,
                     unsigned int nkiov, lnet_kiov_t *kiov, unsigned int kiovoffset,
                     unsigned int nob)
 {
@@ -484,9 +441,9 @@ lnet_copy_kiov2iov (unsigned int niov, struct iovec *iov, unsigned int iovoffset
 EXPORT_SYMBOL(lnet_copy_kiov2iov);
 
 void
-lnet_copy_iov2kiov (unsigned int nkiov, lnet_kiov_t *kiov, unsigned int kiovoffset,
-                    unsigned int niov, struct iovec *iov, unsigned int iovoffset,
-                    unsigned int nob)
+lnet_copy_iov2kiov(unsigned int nkiov, lnet_kiov_t *kiov, unsigned int kiovoffset,
+                  unsigned int niov, struct kvec *iov, unsigned int iovoffset,
+                  unsigned int nob)
 {
        /* NB kiov, iov are READ-ONLY */
        unsigned int    this_nob;
@@ -553,9 +510,9 @@ lnet_copy_iov2kiov (unsigned int nkiov, lnet_kiov_t *kiov, unsigned int kiovoffs
 EXPORT_SYMBOL(lnet_copy_iov2kiov);
 
 int
-lnet_extract_kiov (int dst_niov, lnet_kiov_t *dst,
-                   int src_niov, lnet_kiov_t *src,
-                   unsigned int offset, unsigned int len)
+lnet_extract_kiov(int dst_niov, lnet_kiov_t *dst,
+                 int src_niov, lnet_kiov_t *src,
+                 unsigned int offset, unsigned int len)
 {
         /* Initialise 'dst' to the subset of 'src' starting at 'offset',
          * for exactly 'len' bytes, and return the number of entries.
@@ -601,14 +558,13 @@ lnet_extract_kiov (int dst_niov, lnet_kiov_t *dst,
         }
 }
 EXPORT_SYMBOL(lnet_extract_kiov);
-#endif
 
 void
 lnet_ni_recv(lnet_ni_t *ni, void *private, lnet_msg_t *msg, int delayed,
              unsigned int offset, unsigned int mlen, unsigned int rlen)
 {
        unsigned int  niov = 0;
-       struct iovec *iov = NULL;
+       struct kvec *iov = NULL;
        lnet_kiov_t  *kiov = NULL;
        int           rc;
 
@@ -641,7 +597,7 @@ lnet_ni_recv(lnet_ni_t *ni, void *private, lnet_msg_t *msg, int delayed,
                 lnet_finalize(ni, msg, rc);
 }
 
-void
+static void
 lnet_setpayloadbuffer(lnet_msg_t *msg)
 {
         lnet_libmd_t *md = msg->msg_md;
@@ -662,7 +618,7 @@ lnet_setpayloadbuffer(lnet_msg_t *msg)
 
 void
 lnet_prep_send(lnet_msg_t *msg, int type, lnet_process_id_t target,
-               unsigned int offset, unsigned int len) 
+              unsigned int offset, unsigned int len)
 {
         msg->msg_type = type;
         msg->msg_target = target;
@@ -681,7 +637,7 @@ lnet_prep_send(lnet_msg_t *msg, int type, lnet_process_id_t target,
         msg->msg_hdr.payload_length = cpu_to_le32(len);
 }
 
-void
+static void
 lnet_ni_send(lnet_ni_t *ni, lnet_msg_t *msg)
 {
        void   *priv = msg->msg_private;
@@ -696,7 +652,7 @@ lnet_ni_send(lnet_ni_t *ni, lnet_msg_t *msg)
                lnet_finalize(ni, msg, rc);
 }
 
-int
+static int
 lnet_ni_eager_recv(lnet_ni_t *ni, lnet_msg_t *msg)
 {
        int     rc;
@@ -721,7 +677,7 @@ lnet_ni_eager_recv(lnet_ni_t *ni, lnet_msg_t *msg)
 }
 
 /* NB: caller shall hold a ref on 'lp' as I'd drop lnet_net_lock */
-void
+static void
 lnet_ni_query_locked(lnet_ni_t *ni, lnet_peer_t *lp)
 {
        cfs_time_t last_alive = 0;
@@ -773,7 +729,7 @@ lnet_peer_is_alive (lnet_peer_t *lp, cfs_time_t now)
 
 /* NB: returns 1 when alive, 0 when dead, negative when error;
  *     may drop the lnet_net_lock */
-int
+static int
 lnet_peer_alive_locked (lnet_peer_t *lp)
 {
         cfs_time_t now = cfs_time_current();
@@ -912,9 +868,8 @@ lnet_post_send_locked(lnet_msg_t *msg, int do_send)
        return LNET_CREDIT_OK;
 }
 
-#ifdef __KERNEL__
 
-lnet_rtrbufpool_t *
+static lnet_rtrbufpool_t *
 lnet_msg2bufpool(lnet_msg_t *msg)
 {
        lnet_rtrbufpool_t       *rbp;
@@ -934,7 +889,7 @@ lnet_msg2bufpool(lnet_msg_t *msg)
        return rbp;
 }
 
-int
+static int
 lnet_post_routed_recv_locked (lnet_msg_t *msg, int do_recv)
 {
        /* lnet_parse is going to lnet_net_unlock immediately after this, so it
@@ -1007,7 +962,6 @@ lnet_post_routed_recv_locked (lnet_msg_t *msg, int do_recv)
        }
        return LNET_CREDIT_OK;
 }
-#endif
 
 void
 lnet_return_tx_credits_locked(lnet_msg_t *msg)
@@ -1067,7 +1021,6 @@ lnet_return_tx_credits_locked(lnet_msg_t *msg)
         }
 }
 
-#ifdef __KERNEL__
 void
 lnet_schedule_blocked_locked(lnet_rtrbufpool_t *rbp)
 {
@@ -1081,7 +1034,6 @@ lnet_schedule_blocked_locked(lnet_rtrbufpool_t *rbp)
 
        (void)lnet_post_routed_recv_locked(msg, 1);
 }
-#endif
 
 void
 lnet_drop_routed_msgs_locked(struct list_head *list, int cpt)
@@ -1110,7 +1062,6 @@ void
 lnet_return_rx_credits_locked(lnet_msg_t *msg)
 {
        lnet_peer_t     *rxpeer = msg->msg_rxpeer;
-#ifdef __KERNEL__
        lnet_msg_t      *msg2;
 
        if (msg->msg_rtrcredit) {
@@ -1144,9 +1095,11 @@ lnet_return_rx_credits_locked(lnet_msg_t *msg)
                /* It is possible that a user has lowered the desired number of
                 * buffers in this pool.  Make sure we never put back
                 * more buffers than the stated number. */
-               if (rbp->rbp_credits >= rbp->rbp_nbuffers) {
-                       /* Discard this buffer so we don't have too many. */
+               if (unlikely(rbp->rbp_credits >= rbp->rbp_req_nbuffers)) {
+                       /* Discard this buffer so we don't have too
+                        * many. */
                        lnet_destroy_rtrbuf(rb, rbp->rbp_npages);
+                       rbp->rbp_nbuffers--;
                } else {
                        list_add(&rb->rb_list, &rbp->rbp_bufs);
                        rbp->rbp_credits++;
@@ -1178,10 +1131,6 @@ routing_off:
                        (void) lnet_post_routed_recv_locked(msg2, 1);
                }
        }
-#else
-       LASSERT(!msg->msg_rtrcredit);
-       LASSERT(!msg->msg_peerrtrcredit);
-#endif
        if (rxpeer != NULL) {
                msg->msg_rxpeer = NULL;
                lnet_peer_decref_locked(rxpeer);
@@ -1193,6 +1142,8 @@ lnet_compare_routes(lnet_route_t *r1, lnet_route_t *r2)
 {
        lnet_peer_t *p1 = r1->lr_gateway;
        lnet_peer_t *p2 = r2->lr_gateway;
+       int r1_hops = (r1->lr_hops == LNET_UNDEFINED_HOPS) ? 1 : r1->lr_hops;
+       int r2_hops = (r2->lr_hops == LNET_UNDEFINED_HOPS) ? 1 : r2->lr_hops;
 
        if (r1->lr_priority < r2->lr_priority)
                return 1;
@@ -1200,10 +1151,10 @@ lnet_compare_routes(lnet_route_t *r1, lnet_route_t *r2)
        if (r1->lr_priority > r2->lr_priority)
                return -1;
 
-       if (r1->lr_hops < r2->lr_hops)
+       if (r1_hops < r2_hops)
                return 1;
 
-       if (r1->lr_hops > r2->lr_hops)
+       if (r1_hops > r2_hops)
                return -1;
 
        if (p1->lp_txqnob < p2->lp_txqnob)
@@ -1376,19 +1327,6 @@ lnet_send(lnet_nid_t src_nid, lnet_msg_t *msg, lnet_nid_t rtr_nid)
                 }
                 LASSERT (lp->lp_ni == src_ni);
         } else {
-#ifndef __KERNEL__
-               lnet_net_unlock(cpt);
-
-                /* NB
-                 * - once application finishes computation, check here to update
-                 *   router states before it waits for pending IO in LNetEQPoll
-                 * - recursion breaker: router checker sends no message
-                 *   to remote networks */
-                if (the_lnet.ln_rc_state == LNET_RC_STATE_RUNNING)
-                        lnet_router_checker();
-
-               lnet_net_lock(cpt);
-#endif
                /* sending to a remote network */
                lp = lnet_find_route_locked(src_ni, dst_nid, rtr_nid);
                if (lp == NULL) {
@@ -1503,6 +1441,7 @@ lnet_parse_put(lnet_ni_t *ni, lnet_msg_t *msg)
        lnet_hdr_t              *hdr = &msg->msg_hdr;
        struct lnet_match_info  info;
        int                     rc;
+       bool                    ready_delay;
 
        /* Convert put fields to host byte order */
        hdr->msg.put.match_bits = le64_to_cpu(hdr->msg.put.match_bits);
@@ -1518,6 +1457,7 @@ lnet_parse_put(lnet_ni_t *ni, lnet_msg_t *msg)
        info.mi_mbits   = hdr->msg.put.match_bits;
 
        msg->msg_rx_ready_delay = ni->ni_lnd->lnd_eager_recv == NULL;
+       ready_delay = msg->msg_rx_ready_delay;
 
  again:
        rc = lnet_ptl_match_md(&info, msg);
@@ -1530,12 +1470,16 @@ lnet_parse_put(lnet_ni_t *ni, lnet_msg_t *msg)
                 return 0;
 
         case LNET_MATCHMD_NONE:
-               if (msg->msg_rx_delayed) /* attached on delayed list */
+               if (ready_delay)
+                       /* no eager_recv or has already called it, should
+                        * have been attached on delayed list */
                        return 0;
 
                rc = lnet_ni_eager_recv(ni, msg);
-               if (rc == 0)
+               if (rc == 0) {
+                       ready_delay = true;
                        goto again;
+               }
                /* fall through */
 
        case LNET_MATCHMD_DROP:
@@ -1664,7 +1608,7 @@ lnet_parse_reply(lnet_ni_t *ni, lnet_msg_t *msg)
         }
 
         CDEBUG(D_NET, "%s: Reply from %s of length %d/%d into md "LPX64"\n",
-               libcfs_nid2str(ni->ni_nid), libcfs_id2str(src), 
+              libcfs_nid2str(ni->ni_nid), libcfs_id2str(src),
                mlength, rlength, hdr->msg.reply.dst_wmd.wh_object_cookie);
 
        lnet_msg_attach_md(msg, md, 0, mlength);
@@ -1717,7 +1661,7 @@ lnet_parse_ack(lnet_ni_t *ni, lnet_msg_t *msg)
         }
 
         CDEBUG(D_NET, "%s: ACK from %s into md "LPX64"\n",
-               libcfs_nid2str(ni->ni_nid), libcfs_id2str(src), 
+              libcfs_nid2str(ni->ni_nid), libcfs_id2str(src),
                hdr->msg.ack.dst_wmd.wh_object_cookie);
 
        lnet_msg_attach_md(msg, md, 0, 0);
@@ -1740,7 +1684,6 @@ lnet_parse_forward_locked(lnet_ni_t *ni, lnet_msg_t *msg)
 {
        int     rc = 0;
 
-#ifdef __KERNEL__
        if (!the_lnet.ln_routing)
                return -ECANCELED;
 
@@ -1757,9 +1700,6 @@ lnet_parse_forward_locked(lnet_ni_t *ni, lnet_msg_t *msg)
 
        if (rc == 0)
                rc = lnet_post_routed_recv_locked(msg, 0);
-#else
-       LBUG();
-#endif
        return rc;
 }
 
@@ -1808,7 +1748,6 @@ lnet_msgtyp2str (int type)
                 return ("<UNKNOWN>");
         }
 }
-EXPORT_SYMBOL(lnet_msgtyp2str);
 
 void
 lnet_print_hdr(lnet_hdr_t * hdr)
@@ -2055,6 +1994,19 @@ lnet_parse(lnet_ni_t *ni, lnet_hdr_t *hdr, lnet_nid_t from_nid,
                goto drop;
        }
 
+       if (lnet_isrouter(msg->msg_rxpeer)) {
+               lnet_peer_set_alive(msg->msg_rxpeer);
+               if (avoid_asym_router_failure &&
+                   LNET_NIDNET(src_nid) != LNET_NIDNET(from_nid)) {
+                       /* received a remote message from router, update
+                        * remote NI status on this router.
+                        * NB: multi-hop routed message will be ignored.
+                        */
+                       lnet_router_ni_update_locked(msg->msg_rxpeer,
+                                                    LNET_NIDNET(src_nid));
+               }
+       }
+
        lnet_msg_commit(msg, cpt);
 
        /* message delay simulation */
@@ -2224,7 +2176,6 @@ LNetPut(lnet_nid_t self, lnet_handle_md_t mdh, lnet_ack_req_t ack,
        int                     cpt;
        int                     rc;
 
-       LASSERT(the_lnet.ln_init);
        LASSERT(the_lnet.ln_refcount > 0);
 
        if (!list_empty(&the_lnet.ln_test_peers) &&     /* normally we don't */
@@ -2272,14 +2223,14 @@ LNetPut(lnet_nid_t self, lnet_handle_md_t mdh, lnet_ack_req_t ack,
 
         /* NB handles only looked up by creator (no flips) */
         if (ack == LNET_ACK_REQ) {
-                msg->msg_hdr.msg.put.ack_wmd.wh_interface_cookie = 
+               msg->msg_hdr.msg.put.ack_wmd.wh_interface_cookie =
                         the_lnet.ln_interface_cookie;
-                msg->msg_hdr.msg.put.ack_wmd.wh_object_cookie = 
+               msg->msg_hdr.msg.put.ack_wmd.wh_object_cookie =
                         md->md_lh.lh_cookie;
         } else {
-                msg->msg_hdr.msg.put.ack_wmd.wh_interface_cookie = 
+               msg->msg_hdr.msg.put.ack_wmd.wh_interface_cookie =
                         LNET_WIRE_HANDLE_COOKIE_NONE;
-                msg->msg_hdr.msg.put.ack_wmd.wh_object_cookie = 
+               msg->msg_hdr.msg.put.ack_wmd.wh_object_cookie =
                         LNET_WIRE_HANDLE_COOKIE_NONE;
         }
 
@@ -2330,7 +2281,7 @@ lnet_create_reply_msg (lnet_ni_t *ni, lnet_msg_t *getmsg)
 
         if (getmd->md_threshold == 0) {
                 CERROR ("%s: Dropping REPLY from %s for inactive MD %p\n",
-                        libcfs_nid2str(ni->ni_nid), libcfs_id2str(peer_id), 
+                       libcfs_nid2str(ni->ni_nid), libcfs_id2str(peer_id),
                         getmd);
                lnet_res_unlock(cpt);
                goto drop;
@@ -2423,7 +2374,6 @@ LNetGet(lnet_nid_t self, lnet_handle_md_t mdh,
        int                     cpt;
        int                     rc;
 
-        LASSERT (the_lnet.ln_init);
         LASSERT (the_lnet.ln_refcount > 0);
 
        if (!list_empty(&the_lnet.ln_test_peers) &&     /* normally we don't */
@@ -2523,7 +2473,6 @@ LNetDist(lnet_nid_t dstnid, lnet_nid_t *srcnidp, __u32 *orderp)
          * keep order 0 free for 0@lo and order 1 free for a local NID
          * match */
 
-        LASSERT (the_lnet.ln_init);
         LASSERT (the_lnet.ln_refcount > 0);
 
        cpt = lnet_net_lock_current();
@@ -2564,22 +2513,29 @@ LNetDist(lnet_nid_t dstnid, lnet_nid_t *srcnidp, __u32 *orderp)
                if (rnet->lrn_net == dstnet) {
                        lnet_route_t *route;
                        lnet_route_t *shortest = NULL;
+                       __u32 shortest_hops = LNET_UNDEFINED_HOPS;
+                       __u32 route_hops;
 
                        LASSERT(!list_empty(&rnet->lrn_routes));
 
                        list_for_each_entry(route, &rnet->lrn_routes,
                                            lr_list) {
+                               route_hops = route->lr_hops;
+                               if (route_hops == LNET_UNDEFINED_HOPS)
+                                       route_hops = 1;
                                if (shortest == NULL ||
-                                   route->lr_hops < shortest->lr_hops)
+                                   route_hops < shortest_hops) {
                                        shortest = route;
+                                       shortest_hops = route_hops;
+                               }
                        }
 
-                        LASSERT (shortest != NULL);
-                        hops = shortest->lr_hops;
-                        if (srcnidp != NULL)
-                                *srcnidp = shortest->lr_gateway->lp_ni->ni_nid;
-                        if (orderp != NULL)
-                                *orderp = order;
+                       LASSERT(shortest != NULL);
+                       hops = shortest_hops;
+                       if (srcnidp != NULL)
+                               *srcnidp = shortest->lr_gateway->lp_ni->ni_nid;
+                       if (orderp != NULL)
+                               *orderp = order;
                        lnet_net_unlock(cpt);
                        return hops + 1;
                }
@@ -2590,94 +2546,3 @@ LNetDist(lnet_nid_t dstnid, lnet_nid_t *srcnidp, __u32 *orderp)
        return -EHOSTUNREACH;
 }
 EXPORT_SYMBOL(LNetDist);
-
-/**
- * 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;
-       struct list_head *tmp;
-        lnet_route_t     *route;
-        lnet_nid_t       *nids;
-        int               nnids;
-        int               maxnids = 256;
-        int               rc = 0;
-        int               rc2;
-       int                     cpt;
-
-        /* 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 */
-       cpt = lnet_net_lock_current();
-       rnet = lnet_find_net_locked(LNET_NIDNET(id.nid));
-       if (rnet != NULL) {
-               list_for_each(tmp, &rnet->lrn_routes) {
-                       if (nnids == maxnids) {
-                               lnet_net_unlock(cpt);
-                                LIBCFS_FREE(nids, maxnids * sizeof(*nids));
-                                maxnids *= 2;
-                                goto again;
-                        }
-
-                       route = list_entry(tmp, lnet_route_t, lr_list);
-                       nids[nnids++] = route->lr_gateway->lp_nid;
-               }
-       }
-       lnet_net_unlock(cpt);
-
-        /* set async on all the routers */
-        while (nnids-- > 0) {
-               id.pid = LNET_PID_LUSTRE;
-                id.nid = nids[nnids];
-
-                ni = lnet_net2ni(LNET_NIDNET(id.nid));
-                if (ni == NULL)
-                        continue;
-
-                if (ni->ni_lnd->lnd_setasync != NULL) {
-                        rc2 = (ni->ni_lnd->lnd_setasync)(ni, id, nasync);
-                        if (rc2 != 0)
-                                rc = rc2;
-                }
-                lnet_ni_decref(ni);
-        }
-
-        LIBCFS_FREE(nids, maxnids * sizeof(*nids));
-        return rc;
-#endif
-}
-EXPORT_SYMBOL(LNetSetAsync);