Whamcloud - gitweb
- fixed typo in a comment.
[fs/lustre-release.git] / lnet / lnet / lib-move.c
index 1627064..20eceed 100644 (file)
@@ -36,7 +36,7 @@ static void lnet_drop_delayed_put(lnet_msg_t *msg, char *reason);
 
 #define LNET_MATCHMD_NONE     0   /* Didn't match */
 #define LNET_MATCHMD_OK       1   /* Matched OK */
-#define LNET_MATCHMD_DROP     2   /* Must be disarded */
+#define LNET_MATCHMD_DROP     2   /* Must be discarded */
 
 static int
 lnet_try_match_md (int index, int op_mask, lnet_process_id_t src,
@@ -1432,7 +1432,10 @@ LNetClearLazyPortal(int portal)
                 return 0;
         }
 
-        CDEBUG(D_NET, "clearing portal %d lazy\n", portal);
+        if (the_lnet.ln_shutdown)
+                CWARN ("Active lazy portal %d on exit\n", portal);
+        else
+                CDEBUG (D_NET, "clearing portal %d lazy\n", portal);
 
         /* grab all the blocked messages atomically */
         list_add(&zombies, &ptl->ptl_msgq);
@@ -1619,7 +1622,7 @@ lnet_parse_put(lnet_ni_t *ni, lnet_msg_t *msg)
                 
         case LNET_MATCHMD_NONE:
                 rc = lnet_eager_recv_locked(msg);
-                if (rc == 0) {
+                if (rc == 0 && !the_lnet.ln_shutdown) {
                         list_add_tail(&msg->msg_list, 
                                       &the_lnet.ln_portals[index].ptl_msgq);
 
@@ -1645,7 +1648,6 @@ lnet_parse_put(lnet_ni_t *ni, lnet_msg_t *msg)
                 LNET_UNLOCK();
 
                 return ENOENT;          /* +ve: OK but no match */
-
         }
 }
 
@@ -2054,8 +2056,8 @@ lnet_parse(lnet_ni_t *ni, lnet_hdr_t *hdr, lnet_nid_t from_nid,
         msg = lnet_msg_alloc();
         if (msg == NULL) {
                 CERROR("%s, src %s: Dropping %s (out of memory)\n",
-                       libcfs_nid2str(from_nid), libcfs_nid2str(src_nid)
-                       lnet_msgtyp2str(type));
+                       libcfs_nid2str(from_nid), libcfs_nid2str(src_nid)
+                       lnet_msgtyp2str(type));
                 goto drop;
         }
 
@@ -2500,3 +2502,76 @@ LNetDist (lnet_nid_t dstnid, lnet_nid_t *srcnidp, int *orderp)
         return -EHOSTUNREACH;
 }
 
+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;
+        
+        /* 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) {
+                list_for_each(tmp, &rnet->lrn_routes) {
+                        if (nnids == maxnids) {
+                                LNET_UNLOCK();
+                                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_UNLOCK();
+
+        /* set async on all the routers */
+        while (nnids-- > 0) {
+                id.pid = LUSTRE_SRV_LNET_PID;
+                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
+}
+