Whamcloud - gitweb
i=liang,b=18450:
[fs/lustre-release.git] / lnet / klnds / gmlnd / gmlnd_comm.c
index 0ef2436..2957365 100644 (file)
@@ -1,23 +1,39 @@
 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
  * vim:expandtab:shiftwidth=8:tabstop=8:
  *
- * Copyright (c) 2003 Los Alamos National Laboratory (LANL)
- * Copyright (C) 2005 Cluster File Systems, Inc. All rights reserved.
+ * GPL HEADER START
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
- *   This file is part of Lustre, http://www.lustre.org/
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 only,
+ * as published by the Free Software Foundation.
  *
- *   Lustre is free software; you can redistribute it and/or
- *   modify it under the terms of version 2 of the GNU General Public
- *   License as published by the Free Software Foundation.
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License version 2 for more details (a copy is included
+ * in the LICENSE file that accompanied this code).
  *
- *   Lustre is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License
+ * version 2 along with this program; If not, see
+ * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
  *
- *   You should have received a copy of the GNU General Public License
- *   along with Lustre; if not, write to the Free Software
- *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ * GPL HEADER END
+ */
+/*
+ * Copyright  2008 Sun Microsystems, Inc. All rights reserved
+ * Use is subject to license terms.
+ *
+ * Copyright (c) 2003 Los Alamos National Laboratory (LANL)
+ */
+/*
+ * This file is part of Lustre, http://www.lustre.org/
+ * Lustre is a trademark of Sun Microsystems, Inc.
  */
 
 /*
@@ -46,8 +62,7 @@ gmnal_pack_msg(gmnal_ni_t *gmni, gmnal_msg_t *msg,
         msg->gmm_magic    = GMNAL_MSG_MAGIC;
         msg->gmm_version  = GMNAL_MSG_VERSION;
         msg->gmm_type     = type;
-        msg->gmm_srcnid   = lnet_ptlcompat_srcnid(gmni->gmni_ni->ni_nid,
-                                                  dstnid);
+        msg->gmm_srcnid   = gmni->gmni_ni->ni_nid;
         msg->gmm_dstnid   = dstnid;
 }
 
@@ -110,8 +125,7 @@ gmnal_unpack_msg(gmnal_ni_t *gmni, gmnal_rx_t *rx)
                 return -EPROTO;
         }
 
-        if (!lnet_ptlcompat_matchnid(gmni->gmni_ni->ni_nid,
-                                     msg->gmm_dstnid)) {
+        if (gmni->gmni_ni->ni_nid != msg->gmm_dstnid) {
                 CERROR("Bad dst nid from %u: %s\n",
                        rx->rx_recv_gmid, libcfs_nid2str(msg->gmm_dstnid));
                 return -EPROTO;
@@ -433,9 +447,11 @@ gmnal_rx_thread(void *arg)
 
         cfs_daemonize("gmnal_rxd");
 
-        down(&gmni->gmni_rx_mutex);
-
         while (!gmni->gmni_shutdown) {
+                rc = down_interruptible(&gmni->gmni_rx_mutex);
+                LASSERT (rc == 0 || rc == -EINTR);
+                if (rc != 0)
+                        continue;
 
                 spin_lock(&gmni->gmni_gm_lock);
                 rxevent = gm_blocking_receive_no_spin(gmni->gmni_port);
@@ -444,6 +460,7 @@ gmnal_rx_thread(void *arg)
                 switch (GM_RECV_EVENT_TYPE(rxevent)) {
                 default:
                         gm_unknown(gmni->gmni_port, rxevent);
+                        up(&gmni->gmni_rx_mutex);
                         continue;
 
                 case GM_FAST_RECV_EVENT:
@@ -503,12 +520,8 @@ gmnal_rx_thread(void *arg)
 
                 if (rc < 0)                     /* parse failure */
                         gmnal_post_rx(gmni, rx);
-
-                down(&gmni->gmni_rx_mutex);
         }
 
-        up(&gmni->gmni_rx_mutex);
-
         CDEBUG(D_NET, "exiting\n");
         atomic_dec(&gmni->gmni_nthreads);
         return 0;