Whamcloud - gitweb
Branch HEAD
[fs/lustre-release.git] / lnet / lnet / lib-move.c
index f598c0b..c174762 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,
@@ -140,8 +140,8 @@ lnet_match_md(int index, int op_mask, lnet_process_id_t src,
               lnet_libmd_t **md_out)
 {
         lnet_portal_t    *ptl = &the_lnet.ln_portals[index];
-        struct list_head *tmp;
         lnet_me_t        *me;
+        lnet_me_t        *tmp;
         lnet_libmd_t     *md;
         int               rc;
 
@@ -154,11 +154,10 @@ lnet_match_md(int index, int op_mask, lnet_process_id_t src,
                 return LNET_MATCHMD_DROP;
         }
 
-        list_for_each (tmp, &ptl->ptl_ml) {
-                me = list_entry(tmp, lnet_me_t, me_list);
+        list_for_each_entry_safe (me, tmp, &ptl->ptl_ml, me_list) {
                 md = me->me_md;
 
-                 /* ME attached but MD not attached yet */
+                /* ME attached but MD not attached yet */
                 if (md == NULL)
                         continue;
 
@@ -485,7 +484,7 @@ lnet_copy_kiov2kiov (unsigned int ndiov, lnet_kiov_t *diov, unsigned int doffset
         LASSERT (!in_interrupt ());
 
         LASSERT (ndiov > 0);
-        while (doffset > diov->kiov_len) {
+        while (doffset >= diov->kiov_len) {
                 doffset -= diov->kiov_len;
                 diov++;
                 ndiov--;
@@ -493,7 +492,7 @@ lnet_copy_kiov2kiov (unsigned int ndiov, lnet_kiov_t *diov, unsigned int doffset
         }
 
         LASSERT (nsiov > 0);
-        while (soffset > siov->kiov_len) {
+        while (soffset >= siov->kiov_len) {
                 soffset -= siov->kiov_len;
                 siov++;
                 nsiov--;
@@ -565,7 +564,7 @@ lnet_copy_kiov2iov (unsigned int niov, struct iovec *iov, unsigned int iovoffset
         LASSERT (!in_interrupt ());
 
         LASSERT (niov > 0);
-        while (iovoffset > iov->iov_len) {
+        while (iovoffset >= iov->iov_len) {
                 iovoffset -= iov->iov_len;
                 iov++;
                 niov--;
@@ -573,7 +572,7 @@ lnet_copy_kiov2iov (unsigned int niov, struct iovec *iov, unsigned int iovoffset
         }
 
         LASSERT (nkiov > 0);
-        while (kiovoffset > kiov->kiov_len) {
+        while (kiovoffset >= kiov->kiov_len) {
                 kiovoffset -= kiov->kiov_len;
                 kiov++;
                 nkiov--;
@@ -634,7 +633,7 @@ lnet_copy_iov2kiov (unsigned int nkiov, lnet_kiov_t *kiov, unsigned int kiovoffs
         LASSERT (!in_interrupt ());
 
         LASSERT (nkiov > 0);
-        while (kiovoffset > kiov->kiov_len) {
+        while (kiovoffset >= kiov->kiov_len) {
                 kiovoffset -= kiov->kiov_len;
                 kiov++;
                 nkiov--;
@@ -642,7 +641,7 @@ lnet_copy_iov2kiov (unsigned int nkiov, lnet_kiov_t *kiov, unsigned int kiovoffs
         }
 
         LASSERT (niov > 0);
-        while (iovoffset > iov->iov_len) {
+        while (iovoffset >= iov->iov_len) {
                 iovoffset -= iov->iov_len;
                 iov++;
                 niov--;
@@ -1131,7 +1130,7 @@ lnet_return_credits_locked (lnet_msg_t *msg)
         }
         
         if (msg->msg_peerrtrcredit) {
-                /* give pack peer router credits */
+                /* give back peer router credits */
                 msg->msg_peerrtrcredit = 0;
                 
                 LASSERT((rxpeer->lp_rtrcredits < 0) == !list_empty(&rxpeer->lp_rtrq));
@@ -1432,7 +1431,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 +1621,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);
 
@@ -1637,15 +1639,15 @@ lnet_parse_put(lnet_ni_t *ni, lnet_msg_t *msg)
                 /* fall through */
 
         case LNET_MATCHMD_DROP:
-                CWARN("Dropping PUT from %s portal %d match "LPU64
-                      " offset %d length %d: %d\n",
-                      libcfs_id2str(src), index, 
-                      hdr->msg.put.match_bits, 
-                      hdr->msg.put.offset, rlength, rc);
+                CDEBUG(D_NETERROR,
+                       "Dropping PUT from %s portal %d match "LPU64
+                       " offset %d length %d: %d\n",
+                       libcfs_id2str(src), index, 
+                       hdr->msg.put.match_bits, 
+                       hdr->msg.put.offset, rlength, rc);
                 LNET_UNLOCK();
 
                 return ENOENT;          /* +ve: OK but no match */
-
         }
 }
 
@@ -1674,13 +1676,14 @@ lnet_parse_get(lnet_ni_t *ni, lnet_msg_t *msg, int rdma_get)
                            hdr->msg.get.match_bits, msg,
                            &mlength, &offset, &md);
         if (rc == LNET_MATCHMD_DROP) {
-                CWARN("Dropping GET from %s portal %d match "LPU64
-                      " offset %d length %d\n",
-                      libcfs_id2str(src), 
-                      hdr->msg.get.ptl_index, 
-                      hdr->msg.get.match_bits, 
-                      hdr->msg.get.src_offset,
-                      hdr->msg.get.sink_length);
+                CDEBUG(D_NETERROR,
+                       "Dropping GET from %s portal %d match "LPU64
+                       " offset %d length %d\n",
+                       libcfs_id2str(src), 
+                       hdr->msg.get.ptl_index, 
+                       hdr->msg.get.match_bits, 
+                       hdr->msg.get.src_offset,
+                       hdr->msg.get.sink_length);
                 LNET_UNLOCK();
                 return ENOENT;                  /* +ve: OK but no match */
         }
@@ -1741,12 +1744,12 @@ lnet_parse_reply(lnet_ni_t *ni, lnet_msg_t *msg)
         /* NB handles only looked up by creator (no flips) */
         md = lnet_wire_handle2md(&hdr->msg.reply.dst_wmd);
         if (md == NULL || md->md_threshold == 0) {
-                CWARN("%s: Dropping REPLY from %s for %s "
-                      "MD "LPX64"."LPX64"\n", 
-                      libcfs_nid2str(ni->ni_nid), libcfs_id2str(src),
-                      (md == NULL) ? "invalid" : "inactive",
-                      hdr->msg.reply.dst_wmd.wh_interface_cookie,
-                      hdr->msg.reply.dst_wmd.wh_object_cookie);
+                CDEBUG(D_NETERROR, "%s: Dropping REPLY from %s for %s "
+                       "MD "LPX64"."LPX64"\n", 
+                       libcfs_nid2str(ni->ni_nid), libcfs_id2str(src),
+                       (md == NULL) ? "invalid" : "inactive",
+                       hdr->msg.reply.dst_wmd.wh_interface_cookie,
+                       hdr->msg.reply.dst_wmd.wh_object_cookie);
 
                 LNET_UNLOCK();
                 return ENOENT;                  /* +ve: OK but no match */
@@ -1759,9 +1762,9 @@ lnet_parse_reply(lnet_ni_t *ni, lnet_msg_t *msg)
 
         if (mlength < rlength &&
             (md->md_options & LNET_MD_TRUNCATE) == 0) {
-                CERROR ("%s: Dropping REPLY from %s length %d "
-                        "for MD "LPX64" would overflow (%d)\n",
-                        libcfs_nid2str(ni->ni_nid), libcfs_id2str(src),
+                CDEBUG(D_NETERROR, "%s: Dropping REPLY from %s length %d "
+                       "for MD "LPX64" would overflow (%d)\n",
+                       libcfs_nid2str(ni->ni_nid), libcfs_id2str(src),
                         rlength, hdr->msg.reply.dst_wmd.wh_object_cookie,
                         mlength);
                 LNET_UNLOCK();
@@ -1814,14 +1817,13 @@ lnet_parse_ack(lnet_ni_t *ni, lnet_msg_t *msg)
         /* NB handles only looked up by creator (no flips) */
         md = lnet_wire_handle2md(&hdr->msg.ack.dst_wmd);
         if (md == NULL || md->md_threshold == 0) {
-#if 0
                 /* Don't moan; this is expected */
-                CERROR ("%s: Dropping ACK from %s to %s MD "LPX64"."LPX64"\n",
-                        libcfs_nid2str(ni->ni_nid), libcfs_id2str(src),
-                        (md == NULL) ? "invalid" : "inactive",
-                        hdr->msg.ack.dst_wmd.wh_interface_cookie,
-                        hdr->msg.ack.dst_wmd.wh_object_cookie);
-#endif
+                CDEBUG(D_NET,
+                       "%s: Dropping ACK from %s to %s MD "LPX64"."LPX64"\n",
+                       libcfs_nid2str(ni->ni_nid), libcfs_id2str(src),
+                       (md == NULL) ? "invalid" : "inactive",
+                       hdr->msg.ack.dst_wmd.wh_interface_cookie,
+                       hdr->msg.ack.dst_wmd.wh_object_cookie);
                 LNET_UNLOCK();
                 return ENOENT;                  /* +ve! */
         }
@@ -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;
         }
 
@@ -2422,7 +2424,7 @@ LNetGet(lnet_nid_t self, lnet_handle_md_t mdh,
 }
 
 int
-LNetDist (lnet_nid_t dstnid, lnet_nid_t *srcnidp, int *orderp)
+LNetDist (lnet_nid_t dstnid, lnet_nid_t *srcnidp, __u32 *orderp)
 {
        struct list_head *e;
         lnet_ni_t        *ni;
@@ -2430,7 +2432,7 @@ LNetDist (lnet_nid_t dstnid, lnet_nid_t *srcnidp, int *orderp)
         lnet_remotenet_t *rnet;
         __u32             dstnet = LNET_NIDNET(dstnid);
         int               hops;
-        int               order = 2;
+        __u32             order = 2;
 
         /* if !local_nid_dist_zero, I don't return a distance of 0 ever
          * (when lustre sees a distance of 0, it substitutes 0@lo), so I