diff --git a/ldiskfs/kernel_patches/series/ldiskfs-2.6-suse.series b/ldiskfs/kernel_patches/series/ldiskfs-2.6-suse.series
index cff99dd4218917f2e0de667d7672fb688d9ae052..65e8dcdfa2b5969610649412ab8e78c4b433a10b 100644
--- a/ldiskfs/kernel_patches/series/ldiskfs-2.6-suse.series
+++ b/ldiskfs/kernel_patches/series/ldiskfs-2.6-suse.series
@@ -1,3 +1,4 @@
+header-guards-2.6-suse.patch
 ext3-wantedi-2.6-suse.patch
 ext3-san-jdike-2.6-suse.patch
 iopen-2.6-suse.patch 
@@ -7,3 +8,4 @@ ext3-init-generation-2.6-suse.patch
 ext3-ea-in-inode-2.6-suse.patch
 export-ext3-2.6-suse.patch
 ext3-include-fixes-2.6-suse.patch
+ext3-xattr-header-move-2.6.suse.patch
diff --git a/lnet/archdep.m4 b/lnet/archdep.m4
index 95c9b4ad8b2fd038702482d7adfc07b33e223829..f8d8576c17cfe4cf6e38f9c94b97251e7afc95cb 100644
--- a/lnet/archdep.m4
+++ b/lnet/archdep.m4
@@ -19,11 +19,20 @@ AC_ARG_WITH([cray-portals],
 	AC_HELP_STRING([--with-cray-portals=path],
 		       [path to cray portals]),
 	[
-		CRAY_PORTALS_INCLUDE="-I$with_cray_portals"
-		AC_DEFINE(CRAY_PORTALS, 1, [Building with Cray Portals])
+	        if test "$with_cray_portals" != no; then
+			if test -r $with_cray_portals/include/portals/api.h ; then
+				CRAY_PORTALS_INCLUDE="-I$with_cray_portals/include"
+				AC_DEFINE(CRAY_PORTALS, 1, [Building with Cray Portals])
+			else
+				AC_MSG_ERROR([--with-cray-portals specified badly])
+                        fi
+                fi
 	],[with_cray_portals=no])
 AC_MSG_RESULT([$with_cray_portals])
+
 AM_CONDITIONAL(CRAY_PORTALS, test x$with_cray_portals != xno)
+
+# -------- enable tests and utils? -------
 if test x$enable_tests = xno ; then
 	AC_MSG_NOTICE([disabling tests])
 	enable_tests=no
diff --git a/lnet/include/linux/libcfs.h b/lnet/include/linux/libcfs.h
index f33e56ffbb580905f51b61cf28772146408b12fb..99d3877059f0caeaf08fdb34c67bb9f788b8b382 100644
--- a/lnet/include/linux/libcfs.h
+++ b/lnet/include/linux/libcfs.h
@@ -6,6 +6,28 @@
 
 #define PORTAL_DEBUG
 
+#ifdef __linux__
+# include <asm/types.h>
+# if defined(__powerpc__) && !defined(__KERNEL__)
+#  define __KERNEL__
+#  include <asm/timex.h>
+#  undef __KERNEL__
+# else
+#  include <asm/timex.h>
+# endif
+#else
+# include <sys/types.h>
+typedef u_int32_t __u32;
+typedef u_int64_t __u64;
+#endif
+
+#ifdef __KERNEL__
+# include <linux/time.h>
+#else
+# include <sys/time.h>
+# define do_gettimeofday(tv) gettimeofday(tv, NULL);
+#endif
+
 #ifndef offsetof
 # define offsetof(typ,memb)     ((int)((char *)&(((typ *)0)->memb)))
 #endif
diff --git a/lnet/include/lnet/api-support.h b/lnet/include/lnet/api-support.h
index db83ae7dc755dc141d13c76c8705ce9ce2f04694..cfae78c013de30890855444090a2de720e1543f0 100644
--- a/lnet/include/lnet/api-support.h
+++ b/lnet/include/lnet/api-support.h
@@ -1,5 +1,3 @@
-# define DEBUG_SUBSYSTEM S_PORTALS
-# define PORTAL_DEBUG
 
 #include "build_check.h"
 
diff --git a/lnet/include/lnet/lnetctl.h b/lnet/include/lnet/lnetctl.h
index 12ef47ac6d7c8180bccaf3274af689a379d74405..f3fdaafedcfe0f0f59c140bd66011b8e1e3f8a52 100644
--- a/lnet/include/lnet/lnetctl.h
+++ b/lnet/include/lnet/lnetctl.h
@@ -23,6 +23,10 @@
 #ifndef _PTLCTL_H_
 #define _PTLCTL_H_
 
+#include <portals/types.h>
+#include <linux/kp30.h>
+#include <linux/libcfs.h>
+
 #define PORTALS_DEV_ID 0
 #define PORTALS_DEV_PATH "/dev/portals"
 #define OBD_DEV_ID 1
diff --git a/lnet/include/lnet/ptlctl.h b/lnet/include/lnet/ptlctl.h
index 12ef47ac6d7c8180bccaf3274af689a379d74405..f3fdaafedcfe0f0f59c140bd66011b8e1e3f8a52 100644
--- a/lnet/include/lnet/ptlctl.h
+++ b/lnet/include/lnet/ptlctl.h
@@ -23,6 +23,10 @@
 #ifndef _PTLCTL_H_
 #define _PTLCTL_H_
 
+#include <portals/types.h>
+#include <linux/kp30.h>
+#include <linux/libcfs.h>
+
 #define PORTALS_DEV_ID 0
 #define PORTALS_DEV_PATH "/dev/portals"
 #define OBD_DEV_ID 1
diff --git a/lnet/include/lnet/types.h b/lnet/include/lnet/types.h
index 51b557cc44b177237b786d1f7fdf328dd9cd0c55..ef2712b0b2ec39613fdd610d6b781f3c0f95ef4a 100644
--- a/lnet/include/lnet/types.h
+++ b/lnet/include/lnet/types.h
@@ -3,28 +3,7 @@
 
 #include "build_check.h"
 
-#ifdef __linux__
-# include <asm/types.h>
-# if defined(__powerpc__) && !defined(__KERNEL__)
-#  define __KERNEL__
-#  include <asm/timex.h>
-#  undef __KERNEL__
-# else
-#  include <asm/timex.h>
-# endif
-#else
-# include <sys/types.h>
-typedef u_int32_t __u32;
-typedef u_int64_t __u64;
-#endif
-
-#ifdef __KERNEL__
-# include <linux/time.h>
-#else
-# include <sys/time.h>
-# define do_gettimeofday(tv) gettimeofday(tv, NULL);
-#endif
-
+#include <linux/libcfs.h>
 #include <portals/errno.h>
 
 /* This implementation uses the same type for API function return codes and
diff --git a/lnet/lnet/api-eq.c b/lnet/lnet/api-eq.c
index 7fc95fabf62e689165791ee6a85fdd42c54a9097..03060435293a15043ec16af0d730079495ba779b 100644
--- a/lnet/lnet/api-eq.c
+++ b/lnet/lnet/api-eq.c
@@ -23,6 +23,7 @@
  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
+#define DEBUG_SUBSYSTEM S_PORTALS
 #include <portals/api-support.h>
 
 int ptl_get_event (ptl_eq_t *eq, ptl_event_t *ev)
diff --git a/lnet/lnet/api-init.c b/lnet/lnet/api-init.c
index 08d615d8a23c0155f50a436de25bdd97311951bb..9a9871484929b749b3d9ac13231a9d6d55d24f74 100644
--- a/lnet/lnet/api-init.c
+++ b/lnet/lnet/api-init.c
@@ -23,6 +23,7 @@
  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
+#define DEBUG_SUBSYSTEM S_PORTALS
 #include <portals/api-support.h>
 
 int PtlInit(int *max_interfaces)
diff --git a/lnet/lnet/api-me.c b/lnet/lnet/api-me.c
index 219aa5e08191ffb70e53894e8331b01a0138b1ff..37f01509edcb56164d655d0450e063a34577481f 100644
--- a/lnet/lnet/api-me.c
+++ b/lnet/lnet/api-me.c
@@ -23,5 +23,6 @@
  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
+#define DEBUG_SUBSYSTEM S_PORTALS
 #include <portals/api-support.h>
 
diff --git a/lnet/lnet/api-ni.c b/lnet/lnet/api-ni.c
index 81afd0a5ee70af6b653804dda6bdb70837204e60..4f37d1314a7f2bf0076eaae0adb9cfa83a3654d0 100644
--- a/lnet/lnet/api-ni.c
+++ b/lnet/lnet/api-ni.c
@@ -23,6 +23,7 @@
  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
+#define DEBUG_SUBSYSTEM S_PORTALS
 #include <portals/api-support.h>
 
 int ptl_init;
diff --git a/lnet/ulnds/Makefile.am b/lnet/ulnds/Makefile.am
index 4c842a1ae3ef2451f7805e844fb9d0dbb9fd371f..1681250fca5f7b3c43704ab09e9d7630d50ade93 100644
--- a/lnet/ulnds/Makefile.am
+++ b/lnet/ulnds/Makefile.am
@@ -2,7 +2,9 @@ if LIBLUSTRE
 noinst_LIBRARIES = libtcpnal.a
 endif
 
+if !CRAY_PORTALS
 pkginclude_HEADERS =  pqtimer.h dispatch.h table.h timer.h connection.h ipmap.h bridge.h procbridge.h
 libtcpnal_a_SOURCES = debug.c pqtimer.c select.c table.c pqtimer.h dispatch.h table.h timer.h address.c procapi.c proclib.c connection.c tcpnal.c connection.h
 libtcpnal_a_CPPFLAGS = $(LLCPPFLAGS)
 libtcpnal_a_CFLAGS = $(LLCFLAGS)
+endif
\ No newline at end of file
diff --git a/lnet/ulnds/socklnd/Makefile.am b/lnet/ulnds/socklnd/Makefile.am
index 4c842a1ae3ef2451f7805e844fb9d0dbb9fd371f..1681250fca5f7b3c43704ab09e9d7630d50ade93 100644
--- a/lnet/ulnds/socklnd/Makefile.am
+++ b/lnet/ulnds/socklnd/Makefile.am
@@ -2,7 +2,9 @@ if LIBLUSTRE
 noinst_LIBRARIES = libtcpnal.a
 endif
 
+if !CRAY_PORTALS
 pkginclude_HEADERS =  pqtimer.h dispatch.h table.h timer.h connection.h ipmap.h bridge.h procbridge.h
 libtcpnal_a_SOURCES = debug.c pqtimer.c select.c table.c pqtimer.h dispatch.h table.h timer.h address.c procapi.c proclib.c connection.c tcpnal.c connection.h
 libtcpnal_a_CPPFLAGS = $(LLCPPFLAGS)
 libtcpnal_a_CFLAGS = $(LLCFLAGS)
+endif
\ No newline at end of file
diff --git a/lnet/utils/Makefile.am b/lnet/utils/Makefile.am
index 15c1774b2b469c439a874347d9962cff405dd30c..a14df1c27c3dbc53c67ef93993ed716c9acecfdc 100644
--- a/lnet/utils/Makefile.am
+++ b/lnet/utils/Makefile.am
@@ -9,28 +9,34 @@
 
 if LIBLUSTRE
 noinst_LIBRARIES = libuptlctl.a
-libuptlctl_a_SOURCES = portals.c debug.c l_ioctl.c parser.c parser.h
+libuptlctl_a_SOURCES = portals.c debug.c l_ioctl.c
 libuptlctl_a_CPPFLAGS = $(LLCPPFLAGS)
 libuptlctl_a_CFLAGS = $(LLCFLAGS)
 endif
 
-sbin_PROGRAMS = acceptor ptlctl debugctl routerstat wirecheck gmnalnid
+sbin_PROGRAMS = debugctl
+
 lib_LIBRARIES = libptlctl.a
 
+libptlctl_a_SOURCES = portals.c debug.c l_ioctl.c parser.c parser.h
+
+if !CRAY_PORTALS
+sbin_PROGRAMS += acceptor ptlctl routerstat wirecheck gmnalnid
+
 acceptor_SOURCES = acceptor.c
 
 wirecheck_SOURCES = wirecheck.c
 
-libptlctl_a_SOURCES = portals.c debug.c l_ioctl.c parser.c parser.h
-
 gmnalnid_SOURCES = gmnalnid.c
 
 ptlctl_SOURCES = ptlctl.c
 ptlctl_LDADD =  -L. -lptlctl $(LIBREADLINE) $(LIBEFENCE)
 ptlctl_DEPENDENCIES = libptlctl.a
 
+routerstat_SOURCES = routerstat.c
+endif
+
 debugctl_SOURCES = debugctl.c
 debugctl_LDADD = -L. -lptlctl $(LIBREADLINE) $(LIBEFENCE)
 debugctl_DEPENDENCIES = libptlctl.a
 
-routerstat_SOURCES = routerstat.c
diff --git a/lnet/utils/parser.c b/lnet/utils/parser.c
index 82b4022590a59e671b454c333ae773a26a918252..b91295b34541c8cc5e7efab1727cbc33afbfb78d 100644
--- a/lnet/utils/parser.c
+++ b/lnet/utils/parser.c
@@ -642,68 +642,6 @@ int Parser_arg2int(const char *inp, long *result, int base)
                 return 1;
 }
 
-/* Convert human readable size string to and int; "1k" -> 1000 */
-int Parser_size (int *sizep, char *str) {
-        int size;
-        char mod[32];
-
-        switch (sscanf (str, "%d%1[gGmMkK]", &size, mod)) {
-        default:
-                return (-1);
-
-        case 1:
-                *sizep = size;
-                return (0);
-
-        case 2:
-                switch (*mod) {
-                case 'g':
-                case 'G':
-                        *sizep = size << 30;
-                        return (0);
-
-                case 'm':
-                case 'M':
-                        *sizep = size << 20;
-                        return (0);
-
-                case 'k':
-                case 'K':
-                        *sizep = size << 10;
-                        return (0);
-
-                default:
-                        *sizep = size;
-                        return (0);
-                }
-        }
-}
-
-/* Convert a string boolean to an int; "enable" -> 1 */
-int Parser_bool (int *b, char *str) {
-        if (!strcasecmp (str, "no") ||
-            !strcasecmp (str, "n") ||
-            !strcasecmp (str, "off") ||
-            !strcasecmp (str, "down") ||
-            !strcasecmp (str, "disable"))
-        {
-                *b = 0;
-                return (0);
-        }
-        
-        if (!strcasecmp (str, "yes") ||
-            !strcasecmp (str, "y") ||
-            !strcasecmp (str, "on") ||
-            !strcasecmp (str, "up") ||
-            !strcasecmp (str, "enable"))
-        {
-                *b = 1;
-                return (0);
-        }
-        
-        return (-1);
-}
-
 int Parser_quit(int argc, char **argv)
 {
         argc = argc;
diff --git a/lnet/utils/parser.h b/lnet/utils/parser.h
index 44e8f2a4fadfef23ae7f914513ac919ae2f6e475..9e7e95a3b4073503ddeb443b6e7d231cb20ad189 100644
--- a/lnet/utils/parser.h
+++ b/lnet/utils/parser.h
@@ -64,10 +64,4 @@ char *Parser_strarg(char *inp, const char *prompt, const char *deft,
 /* Extracts an integer from a string  with a base */
 int Parser_arg2int(const char *inp, long *result, int base);
 
-/* Convert human readable size string to and int; "1k" -> 1000 */
-int Parser_size(int *sizep, char *str);
-
-/* Convert a string boolean to an int; "enable" -> 1 */
-int Parser_bool(int *b, char *str);
-
 #endif
diff --git a/lnet/utils/portals.c b/lnet/utils/portals.c
index f078099a260e02288ef2181b28b526874128f9dc..859c5deb1f7c224d536f2d928140ee424df731cc 100644
--- a/lnet/utils/portals.c
+++ b/lnet/utils/portals.c
@@ -87,6 +87,68 @@ static name2num_t nalnames[] = {
 
 static cfg_record_cb_t g_record_cb;
 
+/* Convert a string boolean to an int; "enable" -> 1 */
+int ptl_parse_bool (int *b, char *str) {
+        if (!strcasecmp (str, "no") ||
+            !strcasecmp (str, "n") ||
+            !strcasecmp (str, "off") ||
+            !strcasecmp (str, "down") ||
+            !strcasecmp (str, "disable"))
+        {
+                *b = 0;
+                return (0);
+        }
+        
+        if (!strcasecmp (str, "yes") ||
+            !strcasecmp (str, "y") ||
+            !strcasecmp (str, "on") ||
+            !strcasecmp (str, "up") ||
+            !strcasecmp (str, "enable"))
+        {
+                *b = 1;
+                return (0);
+        }
+        
+        return (-1);
+}
+
+/* Convert human readable size string to and int; "1k" -> 1000 */
+int ptl_parse_size (int *sizep, char *str) {
+        int size;
+        char mod[32];
+
+        switch (sscanf (str, "%d%1[gGmMkK]", &size, mod)) {
+        default:
+                return (-1);
+
+        case 1:
+                *sizep = size;
+                return (0);
+
+        case 2:
+                switch (*mod) {
+                case 'g':
+                case 'G':
+                        *sizep = size << 30;
+                        return (0);
+
+                case 'm':
+                case 'M':
+                        *sizep = size << 20;
+                        return (0);
+
+                case 'k':
+                case 'K':
+                        *sizep = size << 10;
+                        return (0);
+
+                default:
+                        *sizep = size;
+                        return (0);
+                }
+        }
+}
+
 int 
 ptl_set_cfg_record_cb(cfg_record_cb_t cb)
 {
@@ -303,16 +365,40 @@ ptl_parse_nid (ptl_nid_t *nidp, char *str)
         return (-1);
 }
 
+__u64 ptl_nid2u64(ptl_nid_t nid)
+{
+        switch (sizeof (nid)) {
+        case 8:
+                return (nid);
+        case 4:
+                return ((__u32)nid);
+        default:
+                fprintf(stderr, "Unexpected sizeof(ptl_nid_t) == %d\n", sizeof(nid));
+                abort();
+                /* notreached */
+                return (-1);
+        }
+}
+
 char *
 ptl_nid2str (char *buffer, ptl_nid_t nid)
 {
-        __u32           addr = htonl((__u32)nid); /* back to NETWORK byte order */
-        struct hostent *he = gethostbyaddr ((const char *)&addr, sizeof (addr), AF_INET);
+        __u64           nid64 = ptl_nid2u64(nid);
+        struct hostent *he;
+
+        if ((nid64 & ~((__u64)((__u32)-1))) != 0) {
+                /* top bits set */
+                he = NULL;
+        } else {
+                __u32 addr = htonl((__u32)nid); /* back to NETWORK byte order */
+
+                he = gethostbyaddr ((const char *)&addr, sizeof (addr), AF_INET);
+        }
 
         if (he != NULL)
                 strcpy (buffer, he->h_name);
         else
-                sprintf (buffer, LPX64, nid);
+                sprintf (buffer, LPX64, nid64);
         
         return (buffer);
 }
@@ -1008,7 +1094,7 @@ int jt_ptl_mynid(int argc, char **argv)
         char *nidstr;
         struct portals_cfg pcfg;
         ptl_nid_t mynid;
-        
+
         if (argc > 2) {
                 fprintf(stderr, "usage: %s [NID]\n", argv[0]);
                 fprintf(stderr, "NID defaults to the primary IP address of the machine.\n");
@@ -1042,7 +1128,8 @@ int jt_ptl_mynid(int argc, char **argv)
                 fprintf(stderr, "setting my NID failed: %s\n",
                        strerror(errno));
         else
-                printf("registered my nid "LPX64" (%s)\n", mynid, hostname);
+                printf("registered my nid "LPX64" (%s)\n", 
+                       ptl_nid2u64(mynid), hostname);
         return 0;
 }
 
@@ -1100,7 +1187,7 @@ jt_ptl_rxmem (int argc, char **argv)
         
         if (argc > 1)
         {
-                if (Parser_size (&size, argv[1]) != 0 || size < 0)
+                if (ptl_parse_size (&size, argv[1]) != 0 || size < 0)
                 {
                         fprintf (stderr, "Can't parse size %s\n", argv[1]);
                         return (0);
@@ -1119,7 +1206,7 @@ jt_ptl_txmem (int argc, char **argv)
         
         if (argc > 1)
         {
-                if (Parser_size (&size, argv[1]) != 0 || size < 0)
+                if (ptl_parse_size (&size, argv[1]) != 0 || size < 0)
                 {
                         fprintf (stderr, "Can't parse size %s\n", argv[1]);
                         return (0);
@@ -1137,7 +1224,7 @@ jt_ptl_nagle (int argc, char **argv)
 
         if (argc > 1)
         {
-                if (Parser_bool (&enable, argv[1]) != 0)
+                if (ptl_parse_bool (&enable, argv[1]) != 0)
                 {
                         fprintf (stderr, "Can't parse boolean %s\n", argv[1]);
                         return (-1);
@@ -1260,7 +1347,8 @@ jt_ptl_del_route (int argc, char **argv)
         rc = pcfg_ioctl(&pcfg);
         if (rc != 0) 
         {
-                fprintf (stderr, "NAL_CMD_DEL_ROUTE ("LPX64") failed: %s\n", nid, strerror (errno));
+                fprintf (stderr, "NAL_CMD_DEL_ROUTE ("LPX64") failed: %s\n", 
+                         ptl_nid2u64(nid), strerror (errno));
                 return (-1);
         }
         
@@ -1290,7 +1378,7 @@ jt_ptl_notify_router (int argc, char **argv)
                 return (-1);
         }
 
-        if (Parser_bool (&enable, argv[2]) != 0) {
+        if (ptl_parse_bool (&enable, argv[2]) != 0) {
                 fprintf (stderr, "Can't parse boolean %s\n", argv[2]);
                 return (-1);
         }
@@ -1322,7 +1410,7 @@ jt_ptl_notify_router (int argc, char **argv)
         if (rc != 0) 
         {
                 fprintf (stderr, "NAL_CMD_NOTIFY_ROUTER ("LPX64") failed: %s\n",
-                         nid, strerror (errno));
+                         ptl_nid2u64(nid), strerror (errno));
                 return (-1);
         }
         
diff --git a/lustre/configure.in b/lustre/configure.in
index 6b34c41dd276c66811c5a05f00ea5d21b77f3850..1427c8c65207da59c5f7c483442df4270ee5a752 100644
--- a/lustre/configure.in
+++ b/lustre/configure.in
@@ -171,7 +171,7 @@ AC_SUBST(INCLUDE_RULES)
 LUSTRE="$PWD"
 AC_SUBST(LUSTRE)
 
-# cray portals turns these off
+#
 AM_CONDITIONAL(UTILS, test x$enable_utils = xyes)
 AM_CONDITIONAL(TESTS, test x$enable_tests = xyes)
 
diff --git a/lustre/include/linux/lustre_net.h b/lustre/include/linux/lustre_net.h
index 198221cfd988875099d6db37562fe479cc7f681f..aae0442482b4915977f7e70161474880280e6acf 100644
--- a/lustre/include/linux/lustre_net.h
+++ b/lustre/include/linux/lustre_net.h
@@ -509,6 +509,11 @@ struct ptlrpc_service {
         struct ptlrpc_srv_ni srv_interfaces[0];
 };
 
+static inline char *ptlrpc_peernid2str(struct ptlrpc_peer *p, char *str)
+{
+        return (portals_nid2str(p->peer_ni->pni_number, p->peer_nid, str));
+}
+
 /* ptlrpc/events.c */
 extern struct ptlrpc_ni ptlrpc_interfaces[];
 extern int              ptlrpc_ninterfaces;
diff --git a/lustre/kernel_patches/series/ldiskfs-2.6-suse.series b/lustre/kernel_patches/series/ldiskfs-2.6-suse.series
index cff99dd4218917f2e0de667d7672fb688d9ae052..65e8dcdfa2b5969610649412ab8e78c4b433a10b 100644
--- a/lustre/kernel_patches/series/ldiskfs-2.6-suse.series
+++ b/lustre/kernel_patches/series/ldiskfs-2.6-suse.series
@@ -1,3 +1,4 @@
+header-guards-2.6-suse.patch
 ext3-wantedi-2.6-suse.patch
 ext3-san-jdike-2.6-suse.patch
 iopen-2.6-suse.patch 
@@ -7,3 +8,4 @@ ext3-init-generation-2.6-suse.patch
 ext3-ea-in-inode-2.6-suse.patch
 export-ext3-2.6-suse.patch
 ext3-include-fixes-2.6-suse.patch
+ext3-xattr-header-move-2.6.suse.patch
diff --git a/lustre/ldlm/ldlm_lib.c b/lustre/ldlm/ldlm_lib.c
index 57d1058ca1ca3dcdf5edbcaf257eb65c1ee17670..2dce8a46a348ce784909d11d38be3635e7dc13f0 100644
--- a/lustre/ldlm/ldlm_lib.c
+++ b/lustre/ldlm/ldlm_lib.c
@@ -406,8 +406,19 @@ int target_handle_connect(struct ptlrpc_request *req, svc_handler_t handler)
         obd_str2uuid (&cluuid, str);
 
         /* XXX extract a nettype and format accordingly */
-        snprintf(remote_uuid.uuid, sizeof remote_uuid,
-                 "NET_"LPX64"_UUID", req->rq_peer.peer_nid);
+        switch (sizeof(ptl_nid_t)) {
+                /* NB the casts only avoid compiler warnings */
+        case 8:
+                snprintf(remote_uuid.uuid, sizeof remote_uuid,
+                         "NET_"LPX64"_UUID", (__u64)req->rq_peer.peer_nid);
+                break;
+        case 4:
+                snprintf(remote_uuid.uuid, sizeof remote_uuid,
+                         "NET_%x_UUID", (__u32)req->rq_peer.peer_nid);
+                break;
+        default:
+                LBUG();
+        }
 
         spin_lock_bh(&target->obd_processing_task_lock);
         abort_recovery = target->obd_abort_recovery;
diff --git a/lustre/ldlm/ldlm_lock.c b/lustre/ldlm/ldlm_lock.c
index e10ac647748e0440887d17fe90c631e93c8c47d0..ec0727862e4d0b0a2555643de91e0c2025ecee8c 100644
--- a/lustre/ldlm/ldlm_lock.c
+++ b/lustre/ldlm/ldlm_lock.c
@@ -1166,20 +1166,16 @@ void ldlm_lock_dump(int level, struct ldlm_lock *lock, int pos)
         if (lock->l_conn_export != NULL)
                 obd = lock->l_conn_export->exp_obd;
         if (lock->l_export && lock->l_export->exp_connection) {
-                CDEBUG(level, "  Node: NID "LPX64" (%s) on %s (rhandle: "LPX64")\n",
-                       lock->l_export->exp_connection->c_peer.peer_nid,
-                       portals_nid2str(lock->l_export->exp_connection->c_peer.peer_ni->pni_number,
-                                       lock->l_export->exp_connection->c_peer.peer_nid, str),
+                CDEBUG(level, "  Node: NID %s on %s (rhandle: "LPX64")\n",
+                       ptlrpc_peernid2str(&lock->l_export->exp_connection->c_peer, str),
                        lock->l_export->exp_connection->c_peer.peer_ni->pni_name,
                        lock->l_remote_handle.cookie);
         } else if (obd == NULL) {
                 CDEBUG(level, "  Node: local\n");
         } else {
                 struct obd_import *imp = obd->u.cli.cl_import;
-                CDEBUG(level, "  Node: NID "LPX64" (%s) on %s (rhandle: "LPX64")\n",
-                       imp->imp_connection->c_peer.peer_nid,
-                       portals_nid2str(imp->imp_connection->c_peer.peer_ni->pni_number,
-                                       imp->imp_connection->c_peer.peer_nid, str),
+                CDEBUG(level, "  Node: NID %s on %s (rhandle: "LPX64")\n",
+                       ptlrpc_peernid2str(&imp->imp_connection->c_peer, str),
                        imp->imp_connection->c_peer.peer_ni->pni_name,
                        lock->l_remote_handle.cookie);
         }
diff --git a/lustre/ldlm/ldlm_lockd.c b/lustre/ldlm/ldlm_lockd.c
index 251816f4a7f952f072527f3bf2e6ff104626d82a..5ddba662c484b3f45592ea8d29848a637eddee67 100644
--- a/lustre/ldlm/ldlm_lockd.c
+++ b/lustre/ldlm/ldlm_lockd.c
@@ -185,13 +185,10 @@ static void waiting_locks_callback(unsigned long unused)
                         break;
 
                 LDLM_ERROR(lock, "lock callback timer expired: evicting client "
-                           "%s@%s nid "LPX64" (%s) ",
+                           "%s@%s nid %s ",
                            lock->l_export->exp_client_uuid.uuid,
                            lock->l_export->exp_connection->c_remote_uuid.uuid,
-                           lock->l_export->exp_connection->c_peer.peer_nid,
-                           portals_nid2str(lock->l_export->exp_connection->c_peer.peer_ni->pni_number,
-                                           lock->l_export->exp_connection->c_peer.peer_nid,
-                                           str));
+                           ptlrpc_peernid2str(&lock->l_export->exp_connection->c_peer, str));
 
                 spin_lock_bh(&expired_lock_thread.elt_lock);
                 list_del(&lock->l_pending_chain);
@@ -309,19 +306,18 @@ int ldlm_del_waiting_lock(struct ldlm_lock *lock)
 
 static void ldlm_failed_ast(struct ldlm_lock *lock, int rc,const char *ast_type)
 {
-        const struct ptlrpc_connection *conn = lock->l_export->exp_connection;
+        struct ptlrpc_connection *conn = lock->l_export->exp_connection;
         char str[PTL_NALFMT_SIZE];
 
         CERROR("%s AST failed (%d) for res "LPU64"/"LPU64
-               ", mode %s: evicting client %s@%s NID "LPX64" (%s)\n",
+               ", mode %s: evicting client %s@%s NID %s\n",
                ast_type, rc,
                lock->l_resource->lr_name.name[0],
                lock->l_resource->lr_name.name[1],
                ldlm_lockname[lock->l_granted_mode],
                lock->l_export->exp_client_uuid.uuid,
-               conn->c_remote_uuid.uuid, conn->c_peer.peer_nid,
-               portals_nid2str(conn->c_peer.peer_ni->pni_number,
-                               conn->c_peer.peer_nid, str));
+               conn->c_remote_uuid.uuid,
+               ptlrpc_peernid2str(&conn->c_peer, str));
         ptlrpc_fail_export(lock->l_export);
 }
 
@@ -329,12 +325,14 @@ static int ldlm_handle_ast_error(struct ldlm_lock *lock,
                                  struct ptlrpc_request *req, int rc,
                                  const char *ast_type)
 {
+        char str[PTL_NALFMT_SIZE];
+
         if (rc == -ETIMEDOUT || rc == -EINTR || rc == -ENOTCONN) {
                 LASSERT(lock->l_export);
                 if (lock->l_export->exp_libclient) {
-                        LDLM_DEBUG(lock, "%s AST to liblustre client (nid "
-                                   LPU64") timeout, just cancelling lock",
-                                   ast_type, req->rq_peer.peer_nid);
+                        LDLM_DEBUG(lock, "%s AST to liblustre client (nid %s)"
+                                   " timeout, just cancelling lock", ast_type,
+                                   ptlrpc_peernid2str(&req->rq_peer, str));
                         ldlm_lock_cancel(lock);
                         rc = -ERESTART;
                 } else {
@@ -343,13 +341,14 @@ static int ldlm_handle_ast_error(struct ldlm_lock *lock,
                 }
         } else if (rc) {
                 if (rc == -EINVAL)
-                        LDLM_DEBUG(lock, "client (nid "LPU64") returned %d"
+                        LDLM_DEBUG(lock, "client (nid %s) returned %d"
                                    " from %s AST - normal race",
-                                   req->rq_peer.peer_nid,
+                                   ptlrpc_peernid2str(&req->rq_peer, str),
                                    req->rq_repmsg->status, ast_type);
                 else
-                        LDLM_ERROR(lock, "client (nid "LPU64") returned %d "
-                                   "from %s AST", req->rq_peer.peer_nid,
+                        LDLM_ERROR(lock, "client (nid %s) returned %d "
+                                   "from %s AST", 
+                                   ptlrpc_peernid2str(&req->rq_peer, str),
                                    (req->rq_repmsg != NULL) ?
                                    req->rq_repmsg->status : 0, ast_type);
                 ldlm_lock_cancel(lock);
@@ -737,12 +736,10 @@ int ldlm_handle_cancel(struct ptlrpc_request *req)
         lock = ldlm_handle2lock(&dlm_req->lock_handle1);
         if (!lock) {
                 CERROR("received cancel for unknown lock cookie "LPX64
-                       " from client %s nid "LPX64" (%s)\n",
+                       " from client %s nid %s\n",
                        dlm_req->lock_handle1.cookie,
                        req->rq_export->exp_client_uuid.uuid,
-                       req->rq_peer.peer_nid,
-                       portals_nid2str(req->rq_peer.peer_ni->pni_number,
-                                       req->rq_peer.peer_nid, str));
+                       ptlrpc_peernid2str(&req->rq_peer, str));
                 LDLM_DEBUG_NOLOCK("server-side cancel handler stale lock "
                                   "(cookie "LPU64")",
                                   dlm_req->lock_handle1.cookie);
@@ -967,12 +964,11 @@ static int ldlm_callback_handler(struct ptlrpc_request *req)
         if (req->rq_export == NULL) {
                 struct ldlm_request *dlm_req;
 
-                CDEBUG(D_RPCTRACE, "operation %d from nid "LPX64" (%s) with bad "
+                CDEBUG(D_RPCTRACE, "operation %d from nid %s with bad "
                        "export cookie "LPX64" (ptl req %d/rep %d); this is "
                        "normal if this node rebooted with a lock held\n",
-                       req->rq_reqmsg->opc, req->rq_peer.peer_nid,
-                       portals_nid2str(req->rq_peer.peer_ni->pni_number,
-                                       req->rq_peer.peer_nid, str),
+                       req->rq_reqmsg->opc,
+                       ptlrpc_peernid2str(&req->rq_peer, str),
                        req->rq_reqmsg->handle.cookie,
                        req->rq_request_portal, req->rq_reply_portal);
 
diff --git a/lustre/ldlm/ldlm_request.c b/lustre/ldlm/ldlm_request.c
index f52d37d76469313d318ad2488ebd4a899c3a0127..7540b699036107a7a36c3eb8188e47df8490917f 100644
--- a/lustre/ldlm/ldlm_request.c
+++ b/lustre/ldlm/ldlm_request.c
@@ -559,9 +559,11 @@ int ldlm_cli_cancel(struct lustre_handle *lockh)
                 rc = ptlrpc_queue_wait(req);
 
                 if (rc == ESTALE) {
-                        CERROR("client/server (nid "LPU64") out of sync--not "
-                               "fatal\n",
-                               req->rq_import->imp_connection->c_peer.peer_nid);
+                        char str[PTL_NALFMT_SIZE];
+                        CERROR("client/server (nid %s) out of sync"
+                               " -- not fatal\n",
+                               ptlrpc_peernid2str(&req->rq_import->
+                                                  imp_connection->c_peer, str));
                 } else if (rc == -ETIMEDOUT) {
                         ptlrpc_req_finished(req);
                         GOTO(restart, rc);
diff --git a/lustre/liblustre/llite_lib.c b/lustre/liblustre/llite_lib.c
index 31aef171be43c144076bd44148b1186e7f6d8970..0b549c068bc809bdbff7e93906e67919102b6990 100644
--- a/lustre/liblustre/llite_lib.c
+++ b/lustre/liblustre/llite_lib.c
@@ -24,6 +24,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <assert.h>
+#include <signal.h>
 #include <sys/types.h>
 #include <sys/queue.h>
 
@@ -42,7 +43,6 @@
  */
 #undef LIST_HEAD
 
-#include <portals/api-support.h> /* needed for ptpctl.h */
 #include <portals/ptlctl.h>	/* needed for parse_dump */
 #include <procbridge.h>
 
diff --git a/lustre/liblustre/tests/echo_test.c b/lustre/liblustre/tests/echo_test.c
index 59bbac7b684db30aae3581a3eeee1bc50f025124..ca2caaaf9daf9c6f8daedc2b3053ce1ce2a6e11b 100644
--- a/lustre/liblustre/tests/echo_test.c
+++ b/lustre/liblustre/tests/echo_test.c
@@ -3,7 +3,6 @@
 #include <sys/socket.h>
 #include <arpa/inet.h>
 
-#include <portals/api-support.h> /* needed for ptpctl.h */
 #include <portals/ptlctl.h>	/* needed for parse_dump */
 
 
diff --git a/lustre/llite/special.c b/lustre/llite/special.c
index 352849e0ed9cb2e98230ea14fe928fbdeb6139b1..084381e75bcf1d61b45ddcf9d21d468b2454026f 100644
--- a/lustre/llite/special.c
+++ b/lustre/llite/special.c
@@ -200,7 +200,7 @@ static int ll_special_ioctl(struct inode *inode, struct file *filp,
 
         if (pfop && *pfop && (*pfop)->ioctl) {
                 struct file_operations *sfops = filp->f_op;
-
+			
                 rc = (*pfop)->ioctl(inode, filp, cmd, arg);
 
                 /* sometimes, file_operations will be changed in ioctl */
diff --git a/lustre/mds/mds_reint.c b/lustre/mds/mds_reint.c
index d4b13f741a8a3b7c6a25a88f2d5b349a51c3e54f..295f24f9b8ddf155d007bd06e4833bc150de5998 100644
--- a/lustre/mds/mds_reint.c
+++ b/lustre/mds/mds_reint.c
@@ -278,6 +278,7 @@ void mds_steal_ack_locks(struct ptlrpc_request *req)
         struct ptlrpc_reply_state *oldrep;
         struct ptlrpc_service     *svc;
         unsigned long              flags;
+        char                       str[PTL_NALFMT_SIZE];
         int                        i;
 
         /* CAVEAT EMPTOR: spinlock order */
@@ -299,10 +300,10 @@ void mds_steal_ack_locks(struct ptlrpc_request *req)
                 list_del_init (&oldrep->rs_exp_list);
 
                 CWARN("Stealing %d locks from rs %p x"LPD64".t"LPD64
-                      " o%d NID"LPX64"\n",
+                      " o%d NID %s\n",
                       oldrep->rs_nlocks, oldrep,
                       oldrep->rs_xid, oldrep->rs_transno, oldrep->rs_msg.opc,
-                      exp->exp_connection->c_peer.peer_nid);
+                      ptlrpc_peernid2str(&exp->exp_connection->c_peer, str));
 
                 for (i = 0; i < oldrep->rs_nlocks; i++)
                         ptlrpc_save_lock(req,
diff --git a/lustre/osc/osc_request.c b/lustre/osc/osc_request.c
index 52662b926e79a37f05c79546f202731d63962a88..85f33d51ff645fc28be44132f9fe0423f9843d37 100644
--- a/lustre/osc/osc_request.c
+++ b/lustre/osc/osc_request.c
@@ -859,7 +859,7 @@ static int osc_brw_fini_request(struct ptlrpc_request *req, struct obdo *oa,
                 obd_count cksum = cksum_pages(rc, page_count, pga);
                 char str[PTL_NALFMT_SIZE];
 
-                portals_nid2str(peer->peer_ni->pni_number, peer->peer_nid, str);
+                ptlrpc_peernid2str(peer, str);
 
                 cksum_counter++;
                 if (server_cksum != cksum) {
diff --git a/lustre/ost/ost_handler.c b/lustre/ost/ost_handler.c
index 5d8b535ab846597e75080b471c10d1deaed85b13..71582746cbfe959ea9d3afee0a507c85d782f42c 100644
--- a/lustre/ost/ost_handler.c
+++ b/lustre/ost/ost_handler.c
@@ -517,23 +517,17 @@ static int ost_brw_read(struct ptlrpc_request *req)
                 }
                 if (req->rq_reqmsg->conn_cnt == req->rq_export->exp_conn_cnt) {
                         CERROR("bulk IO comms error: "
-                               "evicting %s@%s nid "LPX64" (%s)\n",
+                               "evicting %s@%s nid %s\n",
                                req->rq_export->exp_client_uuid.uuid,
                                req->rq_export->exp_connection->c_remote_uuid.uuid,
-                               req->rq_peer.peer_nid,
-                               portals_nid2str(req->rq_peer.peer_ni->pni_number,
-                                               req->rq_peer.peer_nid,
-                                               str));
+                               ptlrpc_peernid2str(&req->rq_peer, str));
                         ptlrpc_fail_export(req->rq_export);
                 } else {
                         CERROR("ignoring bulk IO comms error: "
-                               "client reconnected %s@%s nid "LPX64" (%s)\n",  
+                               "client reconnected %s@%s nid %s\n",  
                                req->rq_export->exp_client_uuid.uuid,
                                req->rq_export->exp_connection->c_remote_uuid.uuid,
-                               req->rq_peer.peer_nid,
-                               portals_nid2str(req->rq_peer.peer_ni->pni_number,
-                                               req->rq_peer.peer_nid,
-                                               str));
+                               ptlrpc_peernid2str(&req->rq_peer, str));
                 }
         }
 
@@ -666,8 +660,7 @@ static int ost_brw_write(struct ptlrpc_request *req, struct obd_trans_info *oti)
                 obd_count client_cksum = body->oa.o_cksum;
                 obd_count cksum = ost_checksum_bulk(desc);
 
-                portals_nid2str(req->rq_connection->c_peer.peer_ni->pni_number,
-                                req->rq_connection->c_peer.peer_nid, str);
+                ptlrpc_peernid2str(&req->rq_connection->c_peer, str);
                 if (client_cksum != cksum) {
                         CERROR("Bad checksum: client %x, server %x, client NID "
                                LPX64" (%s)\n", client_cksum, cksum,
@@ -727,23 +720,17 @@ static int ost_brw_write(struct ptlrpc_request *req, struct obd_trans_info *oti)
                 }
                 if (req->rq_reqmsg->conn_cnt == req->rq_export->exp_conn_cnt) {
                         CERROR("bulk IO comms error: "
-                               "evicting %s@%s nid "LPX64" (%s)\n",
+                               "evicting %s@%s nid %s\n",
                                req->rq_export->exp_client_uuid.uuid,
                                req->rq_export->exp_connection->c_remote_uuid.uuid,
-                               req->rq_peer.peer_nid,
-                               portals_nid2str(req->rq_peer.peer_ni->pni_number,
-                                               req->rq_peer.peer_nid,
-                                               str));
+                               ptlrpc_peernid2str(&req->rq_peer, str));
                         ptlrpc_fail_export(req->rq_export);
                 } else {
                         CERROR("ignoring bulk IO comms error: "
-                               "client reconnected %s@%s nid "LPX64" (%s)\n",
+                               "client reconnected %s@%s nid %s\n",
                                req->rq_export->exp_client_uuid.uuid,
                                req->rq_export->exp_connection->c_remote_uuid.uuid,
-                               req->rq_peer.peer_nid,
-                               portals_nid2str(req->rq_peer.peer_ni->pni_number,
-                                               req->rq_peer.peer_nid,
-                                               str));
+                               ptlrpc_peernid2str(&req->rq_peer, str));
                 }        
         }
         RETURN(rc);
diff --git a/lustre/portals/archdep.m4 b/lustre/portals/archdep.m4
index 95c9b4ad8b2fd038702482d7adfc07b33e223829..f8d8576c17cfe4cf6e38f9c94b97251e7afc95cb 100644
--- a/lustre/portals/archdep.m4
+++ b/lustre/portals/archdep.m4
@@ -19,11 +19,20 @@ AC_ARG_WITH([cray-portals],
 	AC_HELP_STRING([--with-cray-portals=path],
 		       [path to cray portals]),
 	[
-		CRAY_PORTALS_INCLUDE="-I$with_cray_portals"
-		AC_DEFINE(CRAY_PORTALS, 1, [Building with Cray Portals])
+	        if test "$with_cray_portals" != no; then
+			if test -r $with_cray_portals/include/portals/api.h ; then
+				CRAY_PORTALS_INCLUDE="-I$with_cray_portals/include"
+				AC_DEFINE(CRAY_PORTALS, 1, [Building with Cray Portals])
+			else
+				AC_MSG_ERROR([--with-cray-portals specified badly])
+                        fi
+                fi
 	],[with_cray_portals=no])
 AC_MSG_RESULT([$with_cray_portals])
+
 AM_CONDITIONAL(CRAY_PORTALS, test x$with_cray_portals != xno)
+
+# -------- enable tests and utils? -------
 if test x$enable_tests = xno ; then
 	AC_MSG_NOTICE([disabling tests])
 	enable_tests=no
diff --git a/lustre/portals/include/linux/libcfs.h b/lustre/portals/include/linux/libcfs.h
index f33e56ffbb580905f51b61cf28772146408b12fb..99d3877059f0caeaf08fdb34c67bb9f788b8b382 100644
--- a/lustre/portals/include/linux/libcfs.h
+++ b/lustre/portals/include/linux/libcfs.h
@@ -6,6 +6,28 @@
 
 #define PORTAL_DEBUG
 
+#ifdef __linux__
+# include <asm/types.h>
+# if defined(__powerpc__) && !defined(__KERNEL__)
+#  define __KERNEL__
+#  include <asm/timex.h>
+#  undef __KERNEL__
+# else
+#  include <asm/timex.h>
+# endif
+#else
+# include <sys/types.h>
+typedef u_int32_t __u32;
+typedef u_int64_t __u64;
+#endif
+
+#ifdef __KERNEL__
+# include <linux/time.h>
+#else
+# include <sys/time.h>
+# define do_gettimeofday(tv) gettimeofday(tv, NULL);
+#endif
+
 #ifndef offsetof
 # define offsetof(typ,memb)     ((int)((char *)&(((typ *)0)->memb)))
 #endif
diff --git a/lustre/portals/include/portals/api-support.h b/lustre/portals/include/portals/api-support.h
index db83ae7dc755dc141d13c76c8705ce9ce2f04694..cfae78c013de30890855444090a2de720e1543f0 100644
--- a/lustre/portals/include/portals/api-support.h
+++ b/lustre/portals/include/portals/api-support.h
@@ -1,5 +1,3 @@
-# define DEBUG_SUBSYSTEM S_PORTALS
-# define PORTAL_DEBUG
 
 #include "build_check.h"
 
diff --git a/lustre/portals/include/portals/ptlctl.h b/lustre/portals/include/portals/ptlctl.h
index 12ef47ac6d7c8180bccaf3274af689a379d74405..f3fdaafedcfe0f0f59c140bd66011b8e1e3f8a52 100644
--- a/lustre/portals/include/portals/ptlctl.h
+++ b/lustre/portals/include/portals/ptlctl.h
@@ -23,6 +23,10 @@
 #ifndef _PTLCTL_H_
 #define _PTLCTL_H_
 
+#include <portals/types.h>
+#include <linux/kp30.h>
+#include <linux/libcfs.h>
+
 #define PORTALS_DEV_ID 0
 #define PORTALS_DEV_PATH "/dev/portals"
 #define OBD_DEV_ID 1
diff --git a/lustre/portals/include/portals/types.h b/lustre/portals/include/portals/types.h
index 51b557cc44b177237b786d1f7fdf328dd9cd0c55..ef2712b0b2ec39613fdd610d6b781f3c0f95ef4a 100644
--- a/lustre/portals/include/portals/types.h
+++ b/lustre/portals/include/portals/types.h
@@ -3,28 +3,7 @@
 
 #include "build_check.h"
 
-#ifdef __linux__
-# include <asm/types.h>
-# if defined(__powerpc__) && !defined(__KERNEL__)
-#  define __KERNEL__
-#  include <asm/timex.h>
-#  undef __KERNEL__
-# else
-#  include <asm/timex.h>
-# endif
-#else
-# include <sys/types.h>
-typedef u_int32_t __u32;
-typedef u_int64_t __u64;
-#endif
-
-#ifdef __KERNEL__
-# include <linux/time.h>
-#else
-# include <sys/time.h>
-# define do_gettimeofday(tv) gettimeofday(tv, NULL);
-#endif
-
+#include <linux/libcfs.h>
 #include <portals/errno.h>
 
 /* This implementation uses the same type for API function return codes and
diff --git a/lustre/portals/portals/api-eq.c b/lustre/portals/portals/api-eq.c
index 7fc95fabf62e689165791ee6a85fdd42c54a9097..03060435293a15043ec16af0d730079495ba779b 100644
--- a/lustre/portals/portals/api-eq.c
+++ b/lustre/portals/portals/api-eq.c
@@ -23,6 +23,7 @@
  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
+#define DEBUG_SUBSYSTEM S_PORTALS
 #include <portals/api-support.h>
 
 int ptl_get_event (ptl_eq_t *eq, ptl_event_t *ev)
diff --git a/lustre/portals/portals/api-init.c b/lustre/portals/portals/api-init.c
index 08d615d8a23c0155f50a436de25bdd97311951bb..9a9871484929b749b3d9ac13231a9d6d55d24f74 100644
--- a/lustre/portals/portals/api-init.c
+++ b/lustre/portals/portals/api-init.c
@@ -23,6 +23,7 @@
  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
+#define DEBUG_SUBSYSTEM S_PORTALS
 #include <portals/api-support.h>
 
 int PtlInit(int *max_interfaces)
diff --git a/lustre/portals/portals/api-me.c b/lustre/portals/portals/api-me.c
index 219aa5e08191ffb70e53894e8331b01a0138b1ff..37f01509edcb56164d655d0450e063a34577481f 100644
--- a/lustre/portals/portals/api-me.c
+++ b/lustre/portals/portals/api-me.c
@@ -23,5 +23,6 @@
  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
+#define DEBUG_SUBSYSTEM S_PORTALS
 #include <portals/api-support.h>
 
diff --git a/lustre/portals/portals/api-ni.c b/lustre/portals/portals/api-ni.c
index 81afd0a5ee70af6b653804dda6bdb70837204e60..4f37d1314a7f2bf0076eaae0adb9cfa83a3654d0 100644
--- a/lustre/portals/portals/api-ni.c
+++ b/lustre/portals/portals/api-ni.c
@@ -23,6 +23,7 @@
  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
+#define DEBUG_SUBSYSTEM S_PORTALS
 #include <portals/api-support.h>
 
 int ptl_init;
diff --git a/lustre/portals/unals/Makefile.am b/lustre/portals/unals/Makefile.am
index 4c842a1ae3ef2451f7805e844fb9d0dbb9fd371f..1681250fca5f7b3c43704ab09e9d7630d50ade93 100644
--- a/lustre/portals/unals/Makefile.am
+++ b/lustre/portals/unals/Makefile.am
@@ -2,7 +2,9 @@ if LIBLUSTRE
 noinst_LIBRARIES = libtcpnal.a
 endif
 
+if !CRAY_PORTALS
 pkginclude_HEADERS =  pqtimer.h dispatch.h table.h timer.h connection.h ipmap.h bridge.h procbridge.h
 libtcpnal_a_SOURCES = debug.c pqtimer.c select.c table.c pqtimer.h dispatch.h table.h timer.h address.c procapi.c proclib.c connection.c tcpnal.c connection.h
 libtcpnal_a_CPPFLAGS = $(LLCPPFLAGS)
 libtcpnal_a_CFLAGS = $(LLCFLAGS)
+endif
\ No newline at end of file
diff --git a/lustre/portals/utils/Makefile.am b/lustre/portals/utils/Makefile.am
index 15c1774b2b469c439a874347d9962cff405dd30c..a14df1c27c3dbc53c67ef93993ed716c9acecfdc 100644
--- a/lustre/portals/utils/Makefile.am
+++ b/lustre/portals/utils/Makefile.am
@@ -9,28 +9,34 @@
 
 if LIBLUSTRE
 noinst_LIBRARIES = libuptlctl.a
-libuptlctl_a_SOURCES = portals.c debug.c l_ioctl.c parser.c parser.h
+libuptlctl_a_SOURCES = portals.c debug.c l_ioctl.c
 libuptlctl_a_CPPFLAGS = $(LLCPPFLAGS)
 libuptlctl_a_CFLAGS = $(LLCFLAGS)
 endif
 
-sbin_PROGRAMS = acceptor ptlctl debugctl routerstat wirecheck gmnalnid
+sbin_PROGRAMS = debugctl
+
 lib_LIBRARIES = libptlctl.a
 
+libptlctl_a_SOURCES = portals.c debug.c l_ioctl.c parser.c parser.h
+
+if !CRAY_PORTALS
+sbin_PROGRAMS += acceptor ptlctl routerstat wirecheck gmnalnid
+
 acceptor_SOURCES = acceptor.c
 
 wirecheck_SOURCES = wirecheck.c
 
-libptlctl_a_SOURCES = portals.c debug.c l_ioctl.c parser.c parser.h
-
 gmnalnid_SOURCES = gmnalnid.c
 
 ptlctl_SOURCES = ptlctl.c
 ptlctl_LDADD =  -L. -lptlctl $(LIBREADLINE) $(LIBEFENCE)
 ptlctl_DEPENDENCIES = libptlctl.a
 
+routerstat_SOURCES = routerstat.c
+endif
+
 debugctl_SOURCES = debugctl.c
 debugctl_LDADD = -L. -lptlctl $(LIBREADLINE) $(LIBEFENCE)
 debugctl_DEPENDENCIES = libptlctl.a
 
-routerstat_SOURCES = routerstat.c
diff --git a/lustre/portals/utils/parser.c b/lustre/portals/utils/parser.c
index 82b4022590a59e671b454c333ae773a26a918252..b91295b34541c8cc5e7efab1727cbc33afbfb78d 100644
--- a/lustre/portals/utils/parser.c
+++ b/lustre/portals/utils/parser.c
@@ -642,68 +642,6 @@ int Parser_arg2int(const char *inp, long *result, int base)
                 return 1;
 }
 
-/* Convert human readable size string to and int; "1k" -> 1000 */
-int Parser_size (int *sizep, char *str) {
-        int size;
-        char mod[32];
-
-        switch (sscanf (str, "%d%1[gGmMkK]", &size, mod)) {
-        default:
-                return (-1);
-
-        case 1:
-                *sizep = size;
-                return (0);
-
-        case 2:
-                switch (*mod) {
-                case 'g':
-                case 'G':
-                        *sizep = size << 30;
-                        return (0);
-
-                case 'm':
-                case 'M':
-                        *sizep = size << 20;
-                        return (0);
-
-                case 'k':
-                case 'K':
-                        *sizep = size << 10;
-                        return (0);
-
-                default:
-                        *sizep = size;
-                        return (0);
-                }
-        }
-}
-
-/* Convert a string boolean to an int; "enable" -> 1 */
-int Parser_bool (int *b, char *str) {
-        if (!strcasecmp (str, "no") ||
-            !strcasecmp (str, "n") ||
-            !strcasecmp (str, "off") ||
-            !strcasecmp (str, "down") ||
-            !strcasecmp (str, "disable"))
-        {
-                *b = 0;
-                return (0);
-        }
-        
-        if (!strcasecmp (str, "yes") ||
-            !strcasecmp (str, "y") ||
-            !strcasecmp (str, "on") ||
-            !strcasecmp (str, "up") ||
-            !strcasecmp (str, "enable"))
-        {
-                *b = 1;
-                return (0);
-        }
-        
-        return (-1);
-}
-
 int Parser_quit(int argc, char **argv)
 {
         argc = argc;
diff --git a/lustre/portals/utils/parser.h b/lustre/portals/utils/parser.h
index 44e8f2a4fadfef23ae7f914513ac919ae2f6e475..9e7e95a3b4073503ddeb443b6e7d231cb20ad189 100644
--- a/lustre/portals/utils/parser.h
+++ b/lustre/portals/utils/parser.h
@@ -64,10 +64,4 @@ char *Parser_strarg(char *inp, const char *prompt, const char *deft,
 /* Extracts an integer from a string  with a base */
 int Parser_arg2int(const char *inp, long *result, int base);
 
-/* Convert human readable size string to and int; "1k" -> 1000 */
-int Parser_size(int *sizep, char *str);
-
-/* Convert a string boolean to an int; "enable" -> 1 */
-int Parser_bool(int *b, char *str);
-
 #endif
diff --git a/lustre/portals/utils/portals.c b/lustre/portals/utils/portals.c
index f078099a260e02288ef2181b28b526874128f9dc..859c5deb1f7c224d536f2d928140ee424df731cc 100644
--- a/lustre/portals/utils/portals.c
+++ b/lustre/portals/utils/portals.c
@@ -87,6 +87,68 @@ static name2num_t nalnames[] = {
 
 static cfg_record_cb_t g_record_cb;
 
+/* Convert a string boolean to an int; "enable" -> 1 */
+int ptl_parse_bool (int *b, char *str) {
+        if (!strcasecmp (str, "no") ||
+            !strcasecmp (str, "n") ||
+            !strcasecmp (str, "off") ||
+            !strcasecmp (str, "down") ||
+            !strcasecmp (str, "disable"))
+        {
+                *b = 0;
+                return (0);
+        }
+        
+        if (!strcasecmp (str, "yes") ||
+            !strcasecmp (str, "y") ||
+            !strcasecmp (str, "on") ||
+            !strcasecmp (str, "up") ||
+            !strcasecmp (str, "enable"))
+        {
+                *b = 1;
+                return (0);
+        }
+        
+        return (-1);
+}
+
+/* Convert human readable size string to and int; "1k" -> 1000 */
+int ptl_parse_size (int *sizep, char *str) {
+        int size;
+        char mod[32];
+
+        switch (sscanf (str, "%d%1[gGmMkK]", &size, mod)) {
+        default:
+                return (-1);
+
+        case 1:
+                *sizep = size;
+                return (0);
+
+        case 2:
+                switch (*mod) {
+                case 'g':
+                case 'G':
+                        *sizep = size << 30;
+                        return (0);
+
+                case 'm':
+                case 'M':
+                        *sizep = size << 20;
+                        return (0);
+
+                case 'k':
+                case 'K':
+                        *sizep = size << 10;
+                        return (0);
+
+                default:
+                        *sizep = size;
+                        return (0);
+                }
+        }
+}
+
 int 
 ptl_set_cfg_record_cb(cfg_record_cb_t cb)
 {
@@ -303,16 +365,40 @@ ptl_parse_nid (ptl_nid_t *nidp, char *str)
         return (-1);
 }
 
+__u64 ptl_nid2u64(ptl_nid_t nid)
+{
+        switch (sizeof (nid)) {
+        case 8:
+                return (nid);
+        case 4:
+                return ((__u32)nid);
+        default:
+                fprintf(stderr, "Unexpected sizeof(ptl_nid_t) == %d\n", sizeof(nid));
+                abort();
+                /* notreached */
+                return (-1);
+        }
+}
+
 char *
 ptl_nid2str (char *buffer, ptl_nid_t nid)
 {
-        __u32           addr = htonl((__u32)nid); /* back to NETWORK byte order */
-        struct hostent *he = gethostbyaddr ((const char *)&addr, sizeof (addr), AF_INET);
+        __u64           nid64 = ptl_nid2u64(nid);
+        struct hostent *he;
+
+        if ((nid64 & ~((__u64)((__u32)-1))) != 0) {
+                /* top bits set */
+                he = NULL;
+        } else {
+                __u32 addr = htonl((__u32)nid); /* back to NETWORK byte order */
+
+                he = gethostbyaddr ((const char *)&addr, sizeof (addr), AF_INET);
+        }
 
         if (he != NULL)
                 strcpy (buffer, he->h_name);
         else
-                sprintf (buffer, LPX64, nid);
+                sprintf (buffer, LPX64, nid64);
         
         return (buffer);
 }
@@ -1008,7 +1094,7 @@ int jt_ptl_mynid(int argc, char **argv)
         char *nidstr;
         struct portals_cfg pcfg;
         ptl_nid_t mynid;
-        
+
         if (argc > 2) {
                 fprintf(stderr, "usage: %s [NID]\n", argv[0]);
                 fprintf(stderr, "NID defaults to the primary IP address of the machine.\n");
@@ -1042,7 +1128,8 @@ int jt_ptl_mynid(int argc, char **argv)
                 fprintf(stderr, "setting my NID failed: %s\n",
                        strerror(errno));
         else
-                printf("registered my nid "LPX64" (%s)\n", mynid, hostname);
+                printf("registered my nid "LPX64" (%s)\n", 
+                       ptl_nid2u64(mynid), hostname);
         return 0;
 }
 
@@ -1100,7 +1187,7 @@ jt_ptl_rxmem (int argc, char **argv)
         
         if (argc > 1)
         {
-                if (Parser_size (&size, argv[1]) != 0 || size < 0)
+                if (ptl_parse_size (&size, argv[1]) != 0 || size < 0)
                 {
                         fprintf (stderr, "Can't parse size %s\n", argv[1]);
                         return (0);
@@ -1119,7 +1206,7 @@ jt_ptl_txmem (int argc, char **argv)
         
         if (argc > 1)
         {
-                if (Parser_size (&size, argv[1]) != 0 || size < 0)
+                if (ptl_parse_size (&size, argv[1]) != 0 || size < 0)
                 {
                         fprintf (stderr, "Can't parse size %s\n", argv[1]);
                         return (0);
@@ -1137,7 +1224,7 @@ jt_ptl_nagle (int argc, char **argv)
 
         if (argc > 1)
         {
-                if (Parser_bool (&enable, argv[1]) != 0)
+                if (ptl_parse_bool (&enable, argv[1]) != 0)
                 {
                         fprintf (stderr, "Can't parse boolean %s\n", argv[1]);
                         return (-1);
@@ -1260,7 +1347,8 @@ jt_ptl_del_route (int argc, char **argv)
         rc = pcfg_ioctl(&pcfg);
         if (rc != 0) 
         {
-                fprintf (stderr, "NAL_CMD_DEL_ROUTE ("LPX64") failed: %s\n", nid, strerror (errno));
+                fprintf (stderr, "NAL_CMD_DEL_ROUTE ("LPX64") failed: %s\n", 
+                         ptl_nid2u64(nid), strerror (errno));
                 return (-1);
         }
         
@@ -1290,7 +1378,7 @@ jt_ptl_notify_router (int argc, char **argv)
                 return (-1);
         }
 
-        if (Parser_bool (&enable, argv[2]) != 0) {
+        if (ptl_parse_bool (&enable, argv[2]) != 0) {
                 fprintf (stderr, "Can't parse boolean %s\n", argv[2]);
                 return (-1);
         }
@@ -1322,7 +1410,7 @@ jt_ptl_notify_router (int argc, char **argv)
         if (rc != 0) 
         {
                 fprintf (stderr, "NAL_CMD_NOTIFY_ROUTER ("LPX64") failed: %s\n",
-                         nid, strerror (errno));
+                         ptl_nid2u64(nid), strerror (errno));
                 return (-1);
         }
         
diff --git a/lustre/ptlrpc/client.c b/lustre/ptlrpc/client.c
index 9820a4c2df60f8fb0db3603b37533d19c00e4ab0..0cbcff24c383875907772a8a2366f423a8c2a294 100644
--- a/lustre/ptlrpc/client.c
+++ b/lustre/ptlrpc/client.c
@@ -519,6 +519,7 @@ static int after_reply(struct ptlrpc_request *req)
 
 static int ptlrpc_send_new_req(struct ptlrpc_request *req)
 {
+        char                   str[PTL_NALFMT_SIZE];
         struct obd_import     *imp;
         unsigned long          flags;
         int rc;
@@ -563,11 +564,11 @@ static int ptlrpc_send_new_req(struct ptlrpc_request *req)
 
         req->rq_reqmsg->status = current->pid;
         CDEBUG(D_RPCTRACE, "Sending RPC pname:cluuid:pid:xid:ni:nid:opc"
-               " %s:%s:%d:"LPU64":%s:"LPX64":%d\n", current->comm,
+               " %s:%s:%d:"LPU64":%s:%s:%d\n", current->comm,
                imp->imp_obd->obd_uuid.uuid, req->rq_reqmsg->status,
                req->rq_xid,
                imp->imp_connection->c_peer.peer_ni->pni_name,
-               imp->imp_connection->c_peer.peer_nid,
+               ptlrpc_peernid2str(&imp->imp_connection->c_peer, str),
                req->rq_reqmsg->opc);
 
         rc = ptl_send_rpc(req);
@@ -581,6 +582,7 @@ static int ptlrpc_send_new_req(struct ptlrpc_request *req)
 
 int ptlrpc_check_set(struct ptlrpc_request_set *set)
 {
+        char str[PTL_NALFMT_SIZE];
         unsigned long flags;
         struct list_head *tmp;
         int force_timer_recalc = 0;
@@ -779,11 +781,11 @@ int ptlrpc_check_set(struct ptlrpc_request_set *set)
                 }
 
                 CDEBUG(D_RPCTRACE, "Completed RPC pname:cluuid:pid:xid:ni:nid:"
-                       "opc %s:%s:%d:"LPU64":%s:"LPX64":%d\n", current->comm,
+                       "opc %s:%s:%d:"LPU64":%s:%s:%d\n", current->comm,
                        imp->imp_obd->obd_uuid.uuid, req->rq_reqmsg->status,
                        req->rq_xid,
                        imp->imp_connection->c_peer.peer_ni->pni_name,
-                       imp->imp_connection->c_peer.peer_nid,
+                       ptlrpc_peernid2str(&imp->imp_connection->c_peer, str),
                        req->rq_reqmsg->opc);
 
                 set->set_remaining--;
@@ -1292,6 +1294,7 @@ void ptlrpc_retain_replayable_request(struct ptlrpc_request *req,
 
 int ptlrpc_queue_wait(struct ptlrpc_request *req)
 {
+        char str[PTL_NALFMT_SIZE];
         int rc = 0;
         int brc;
         struct l_wait_info lwi;
@@ -1308,11 +1311,11 @@ int ptlrpc_queue_wait(struct ptlrpc_request *req)
         req->rq_reqmsg->status = current->pid;
         LASSERT(imp->imp_obd != NULL);
         CDEBUG(D_RPCTRACE, "Sending RPC pname:cluuid:pid:xid:ni:nid:opc "
-               "%s:%s:%d:"LPU64":%s:"LPX64":%d\n", current->comm,
+               "%s:%s:%d:"LPU64":%s:%s:%d\n", current->comm,
                imp->imp_obd->obd_uuid.uuid,
                req->rq_reqmsg->status, req->rq_xid,
                imp->imp_connection->c_peer.peer_ni->pni_name,
-               imp->imp_connection->c_peer.peer_nid,
+               ptlrpc_peernid2str(&imp->imp_connection->c_peer, str),
                req->rq_reqmsg->opc);
 
         /* Mark phase here for a little debug help */
@@ -1395,11 +1398,11 @@ restart:
         DEBUG_REQ(D_NET, req, "-- done sleeping");
 
         CDEBUG(D_RPCTRACE, "Completed RPC pname:cluuid:pid:xid:ni:nid:opc "
-               "%s:%s:%d:"LPU64":%s:"LPX64":%d\n", current->comm,
+               "%s:%s:%d:"LPU64":%s:%s:%d\n", current->comm,
                imp->imp_obd->obd_uuid.uuid,
                req->rq_reqmsg->status, req->rq_xid,
                imp->imp_connection->c_peer.peer_ni->pni_name,
-               imp->imp_connection->c_peer.peer_nid,
+               ptlrpc_peernid2str(&imp->imp_connection->c_peer, str),
                req->rq_reqmsg->opc);
 
         spin_lock_irqsave(&imp->imp_lock, flags);
diff --git a/lustre/ptlrpc/connection.c b/lustre/ptlrpc/connection.c
index c6a4163e9c4f4b89abf3a5f4ce54ab16126404a6..2e0d889da6fd6386ac9b2a8e072a3c061ffa39af 100644
--- a/lustre/ptlrpc/connection.c
+++ b/lustre/ptlrpc/connection.c
@@ -37,15 +37,17 @@ static struct list_head conn_unused_list;
 
 void ptlrpc_dump_connections(void)
 {
+        char str[PTL_NALFMT_SIZE];
         struct list_head *tmp;
         struct ptlrpc_connection *c;
         ENTRY;
 
         list_for_each(tmp, &conn_list) {
                 c = list_entry(tmp, struct ptlrpc_connection, c_link);
-                CERROR("Connection %p/%s has refcount %d (nid="LPX64" on %s)\n",
+                CERROR("Connection %p/%s has refcount %d (nid=%s on %s)\n",
                        c, c->c_remote_uuid.uuid, atomic_read(&c->c_refcount),
-                       c->c_peer.peer_nid, c->c_peer.peer_ni->pni_name);
+                       ptlrpc_peernid2str(&c->c_peer, str),
+                       c->c_peer.peer_ni->pni_name);
         }
         EXIT;
 }
@@ -53,13 +55,14 @@ void ptlrpc_dump_connections(void)
 struct ptlrpc_connection *ptlrpc_get_connection(struct ptlrpc_peer *peer,
                                                 struct obd_uuid *uuid)
 {
+        char str[PTL_NALFMT_SIZE];
         struct list_head *tmp, *pos;
         struct ptlrpc_connection *c;
         ENTRY;
 
 
-        CDEBUG(D_INFO, "peer is "LPX64" on %s\n",
-               peer->peer_nid, peer->peer_ni->pni_name);
+        CDEBUG(D_INFO, "peer is %s on %s\n",
+               ptlrpc_peernid2str(peer, str), peer->peer_ni->pni_name);
 
         spin_lock(&conn_lock);
         list_for_each(tmp, &conn_list) {
@@ -106,6 +109,7 @@ struct ptlrpc_connection *ptlrpc_get_connection(struct ptlrpc_peer *peer,
 
 int ptlrpc_put_connection(struct ptlrpc_connection *c)
 {
+        char str[PTL_NALFMT_SIZE];
         int rc = 0;
         ENTRY;
 
@@ -114,8 +118,9 @@ int ptlrpc_put_connection(struct ptlrpc_connection *c)
                 RETURN(0);
         }
 
-        CDEBUG (D_INFO, "connection=%p refcount %d to "LPX64" on %s\n",
-                c, atomic_read(&c->c_refcount) - 1, c->c_peer.peer_nid,
+        CDEBUG (D_INFO, "connection=%p refcount %d to %s on %s\n",
+                c, atomic_read(&c->c_refcount) - 1, 
+                ptlrpc_peernid2str(&c->c_peer, str),
                 c->c_peer.peer_ni->pni_name);
 
         if (atomic_dec_and_test(&c->c_refcount)) {
@@ -134,10 +139,12 @@ int ptlrpc_put_connection(struct ptlrpc_connection *c)
 
 struct ptlrpc_connection *ptlrpc_connection_addref(struct ptlrpc_connection *c)
 {
+        char str[PTL_NALFMT_SIZE];
         ENTRY;
         atomic_inc(&c->c_refcount);
-        CDEBUG (D_INFO, "connection=%p refcount %d to "LPX64" on %s\n",
-                c, atomic_read(&c->c_refcount), c->c_peer.peer_nid,
+        CDEBUG (D_INFO, "connection=%p refcount %d to %s on %s\n",
+                c, atomic_read(&c->c_refcount),
+                ptlrpc_peernid2str(&c->c_peer, str),
                 c->c_peer.peer_ni->pni_name);
         RETURN(c);
 }
@@ -151,6 +158,7 @@ void ptlrpc_init_connection(void)
 
 void ptlrpc_cleanup_connection(void)
 {
+        char str[PTL_NALFMT_SIZE];
         struct list_head *tmp, *pos;
         struct ptlrpc_connection *c;
 
@@ -162,9 +170,10 @@ void ptlrpc_cleanup_connection(void)
         }
         list_for_each_safe(tmp, pos, &conn_list) {
                 c = list_entry(tmp, struct ptlrpc_connection, c_link);
-                CERROR("Connection %p/%s has refcount %d (nid="LPX64" on %s)\n",
+                CERROR("Connection %p/%s has refcount %d (nid=%s on %s)\n",
                        c, c->c_remote_uuid.uuid, atomic_read(&c->c_refcount),
-                       c->c_peer.peer_nid, c->c_peer.peer_ni->pni_name);
+                       ptlrpc_peernid2str(&c->c_peer, str),
+                       c->c_peer.peer_ni->pni_name);
                 list_del(&c->c_link);
                 OBD_FREE(c, sizeof(*c));
         }
diff --git a/lustre/ptlrpc/events.c b/lustre/ptlrpc/events.c
index 26a9bb46b2e4f6c1cc927e6b9a9d04fb0435e66f..cd35bd3807ead118243d3b8870fc59db6e20db7b 100644
--- a/lustre/ptlrpc/events.c
+++ b/lustre/ptlrpc/events.c
@@ -31,6 +31,12 @@
 #include <linux/lustre_net.h>
 #include "ptlrpc_internal.h"
 
+#if !defined(__KERNEL__) && defined(CRAY_PORTALS)
+/* forward ref in events.c */
+static void cray_portals_callback(ptl_event_t *ev);
+#endif
+
+
 struct ptlrpc_ni  ptlrpc_interfaces[NAL_MAX_NR];
 int               ptlrpc_ninterfaces;
 
@@ -158,6 +164,7 @@ void request_in_callback(ptl_event_t *ev)
         struct ptlrpc_srv_ni              *srv_ni = rqbd->rqbd_srv_ni;
         struct ptlrpc_service             *service = srv_ni->sni_service;
         struct ptlrpc_request             *req;
+        char                              str[PTL_NALFMT_SIZE];
         unsigned long                     flags;
         ENTRY;
 
@@ -188,8 +195,10 @@ void request_in_callback(ptl_event_t *ev)
                 OBD_ALLOC_GFP(req, sizeof(*req), GFP_ATOMIC);
                 if (req == NULL) {
                         CERROR("Can't allocate incoming request descriptor: "
-                               "Dropping %s RPC from "LPX64"\n",
-                               service->srv_name, ev->initiator.nid);
+                               "Dropping %s RPC from %s\n",
+                               service->srv_name, 
+                               portals_nid2str(srv_ni->sni_ni->pni_number,
+                                               ev->initiator.nid, str));
                         return;
                 }
         }
diff --git a/lustre/ptlrpc/niobuf.c b/lustre/ptlrpc/niobuf.c
index 9f8765b9e925a9c30d72d055fb690accf5bbec46..55d8e9c83b6688f37e8efec5d77337bfaa4e8b65 100644
--- a/lustre/ptlrpc/niobuf.c
+++ b/lustre/ptlrpc/niobuf.c
@@ -43,11 +43,9 @@ static int ptl_send_buf (ptl_handle_md_t *mdh, void *base, int len,
 
         LASSERT (portal != 0);
         LASSERT (conn != NULL);
-        CDEBUG (D_INFO, "conn=%p ni %s nid "LPX64" (%s) on %s\n",
+        CDEBUG (D_INFO, "conn=%p ni %s nid %s on %s\n",
                 conn, conn->c_peer.peer_ni->pni_name,
-                conn->c_peer.peer_nid,
-                portals_nid2str(conn->c_peer.peer_ni->pni_number,
-                                conn->c_peer.peer_nid, str),
+                ptlrpc_peernid2str(&conn->c_peer, str),
                 conn->c_peer.peer_ni->pni_name);
 
         remote_id.nid = conn->c_peer.peer_nid,
@@ -83,8 +81,9 @@ static int ptl_send_buf (ptl_handle_md_t *mdh, void *base, int len,
                 /* We're going to get an UNLINK event when I unlink below,
                  * which will complete just like any other failed send, so
                  * I fall through and return success here! */
-                CERROR("PtlPut("LPU64", %d, "LPD64") failed: %d\n",
-                       remote_id.nid, portal, xid, rc);
+                CERROR("PtlPut(%s, %d, "LPD64") failed: %d\n",
+                       ptlrpc_peernid2str(&conn->c_peer, str),
+                       portal, xid, rc);
                 rc2 = PtlMDUnlink(*mdh);
                 LASSERT (rc2 == PTL_OK);
         }
@@ -100,6 +99,7 @@ int ptlrpc_start_bulk_transfer (struct ptlrpc_bulk_desc *desc)
         ptl_process_id_t    remote_id;
         ptl_md_t            md;
         __u64               xid;
+        char                str[PTL_NALFMT_SIZE];
         ENTRY;
 
         if (OBD_FAIL_CHECK_ONCE(OBD_FAIL_PTLRPC_BULK_PUT_NET)) 
@@ -138,9 +138,9 @@ int ptlrpc_start_bulk_transfer (struct ptlrpc_bulk_desc *desc)
         remote_id.pid = 0;
 
         CDEBUG(D_NET, "Transferring %u pages %u bytes via portal %d on %s "
-               "nid "LPX64" pid %d xid "LPX64"\n", desc->bd_iov_count,
+               "nid %s pid %d xid "LPX64"\n", desc->bd_iov_count,
                desc->bd_nob, desc->bd_portal, peer->peer_ni->pni_name,
-               remote_id.nid, remote_id.pid, xid);
+               ptlrpc_peernid2str(peer, str), remote_id.pid, xid);
 
         /* Network is about to get at the memory */
         desc->bd_network_rw = 1;
@@ -156,8 +156,9 @@ int ptlrpc_start_bulk_transfer (struct ptlrpc_bulk_desc *desc)
                 /* Can't send, so we unlink the MD bound above.  The UNLINK
                  * event this creates will signal completion with failure,
                  * so we return SUCCESS here! */
-                CERROR("Transfer("LPU64", %d, "LPX64") failed: %d\n",
-                       remote_id.nid, desc->bd_portal, xid, rc);
+                CERROR("Transfer(%s, %d, "LPX64") failed: %d\n",
+                       ptlrpc_peernid2str(peer, str),
+                       desc->bd_portal, xid, rc);
                 rc2 = PtlMDUnlink(desc->bd_md_h);
                 LASSERT (rc2 == PTL_OK);
         }
diff --git a/lustre/ptlrpc/ptlrpc_internal.h b/lustre/ptlrpc/ptlrpc_internal.h
index 42648cfb9c7328823a5f6626b2d26e8a2d4bdcf2..81f46dc21f1da6533b977e1551b242aad70b5ded 100644
--- a/lustre/ptlrpc/ptlrpc_internal.h
+++ b/lustre/ptlrpc/ptlrpc_internal.h
@@ -108,11 +108,6 @@ enum {
 
 int ptlrpc_expire_one_request(struct ptlrpc_request *req);
 
-#if !defined(__KERNEL__) && defined(CRAY_PORTALS)
-/* forward ref in events.c */
-static void cray_portals_callback(ptl_event_t *ev);
-#endif
-
 /* pers.c */
 void ptlrpc_fill_bulk_md(ptl_md_t *md, struct ptlrpc_bulk_desc *desc);
 void ptlrpc_add_bulk_page(struct ptlrpc_bulk_desc *desc, struct page *page, 
diff --git a/lustre/ptlrpc/service.c b/lustre/ptlrpc/service.c
index 825b240c2b8302d83b85111d773a987e6d5922ea..11238214b66c5eea013086355eab37ce783daacf 100644
--- a/lustre/ptlrpc/service.c
+++ b/lustre/ptlrpc/service.c
@@ -360,6 +360,7 @@ ptlrpc_server_handle_request (struct ptlrpc_service *svc)
         struct timeval         work_end;
         long                   timediff;
         int                    rc;
+        char                   str[PTL_NALFMT_SIZE];
         ENTRY;
 
         spin_lock_irqsave (&svc->srv_lock, flags);
@@ -398,17 +399,18 @@ ptlrpc_server_handle_request (struct ptlrpc_service *svc)
 #endif
         rc = lustre_unpack_msg (request->rq_reqmsg, request->rq_reqlen);
         if (rc != 0) {
-                CERROR ("error unpacking request: ptl %d from "LPX64
+                CERROR ("error unpacking request: ptl %d from %s"
                         " xid "LPU64"\n", svc->srv_req_portal,
-                       request->rq_peer.peer_nid, request->rq_xid);
+                        ptlrpc_peernid2str(&request->rq_peer, str),
+                       request->rq_xid);
                 goto out;
         }
 
         rc = -EINVAL;
         if (request->rq_reqmsg->type != PTL_RPC_MSG_REQUEST) {
-                CERROR("wrong packet type received (type=%u) from "
-                       LPX64"\n", request->rq_reqmsg->type,
-                       request->rq_peer.peer_nid);
+                CERROR("wrong packet type received (type=%u) from %s\n",
+                       request->rq_reqmsg->type,
+                       ptlrpc_peernid2str(&request->rq_peer, str));
                 goto out;
         }
 
@@ -418,9 +420,9 @@ ptlrpc_server_handle_request (struct ptlrpc_service *svc)
          * client's timeout is similar to mine, she'll be timing out this
          * REQ anyway (bug 1502) */
         if (timediff / 1000000 > (long)obd_timeout) {
-                CERROR("Dropping timed-out request from "LPX64
-                       ": %ld seconds old\n",
-                       request->rq_peer.peer_nid, timediff / 1000000);
+                CERROR("Dropping timed-out request from %s: %ld seconds old\n",
+                       ptlrpc_peernid2str(&request->rq_peer, str), 
+                       timediff / 1000000);
                 goto out;
         }
 
@@ -441,26 +443,26 @@ ptlrpc_server_handle_request (struct ptlrpc_service *svc)
         }
 
         CDEBUG(D_RPCTRACE, "Handling RPC pname:cluuid+ref:pid:xid:ni:nid:opc "
-               "%s:%s+%d:%d:"LPU64":%s:"LPX64":%d\n", current->comm,
+               "%s:%s+%d:%d:"LPU64":%s:%s:%d\n", current->comm,
                (request->rq_export ?
                 (char *)request->rq_export->exp_client_uuid.uuid : "0"),
                (request->rq_export ?
                 atomic_read(&request->rq_export->exp_refcount) : -99),
                request->rq_reqmsg->status, request->rq_xid,
                request->rq_peer.peer_ni->pni_name,
-               request->rq_peer.peer_nid,
+               ptlrpc_peernid2str(&request->rq_peer, str),
                request->rq_reqmsg->opc);
 
         rc = svc->srv_handler(request);
         CDEBUG(D_RPCTRACE, "Handled RPC pname:cluuid+ref:pid:xid:ni:nid:opc "
-               "%s:%s+%d:%d:"LPU64":%s:"LPX64":%d\n", current->comm,
+               "%s:%s+%d:%d:"LPU64":%s:%s:%d\n", current->comm,
                (request->rq_export ?
                 (char *)request->rq_export->exp_client_uuid.uuid : "0"),
                (request->rq_export ?
                 atomic_read(&request->rq_export->exp_refcount) : -99),
                request->rq_reqmsg->status, request->rq_xid,
                request->rq_peer.peer_ni->pni_name,
-               request->rq_peer.peer_nid,
+               ptlrpc_peernid2str(&request->rq_peer, str),
                request->rq_reqmsg->opc);
 
 put_conn:
@@ -473,9 +475,9 @@ put_conn:
         timediff = timeval_sub(&work_end, &work_start);
 
         CDEBUG((timediff / 1000000 > (long)obd_timeout) ? D_ERROR : D_HA,
-               "request "LPU64" opc %u from NID "LPX64" processed in %ldus "
+               "request "LPU64" opc %u from NID %s processed in %ldus "
                "(%ldus total)\n", request->rq_xid, request->rq_reqmsg->opc,
-               request->rq_peer.peer_nid,
+               ptlrpc_peernid2str(&request->rq_peer, str),
                timediff, timeval_sub(&work_end, &request->rq_arrival_time));
 
         if (svc->srv_stats != NULL) {
@@ -502,6 +504,7 @@ ptlrpc_server_handle_reply (struct ptlrpc_service *svc)
         struct obd_device         *obd;
         int                        nlocks;
         int                        been_handled;
+        char                       str[PTL_NALFMT_SIZE];
         ENTRY;
 
         spin_lock_irqsave (&svc->srv_lock, flags);
@@ -546,10 +549,11 @@ ptlrpc_server_handle_reply (struct ptlrpc_service *svc)
                 /* If we see this, we should already have seen the warning
                  * in mds_steal_ack_locks()  */
                 CWARN("All locks stolen from rs %p x"LPD64".t"LPD64
-                      " o%d NID"LPX64"\n",
+                      " o%d NID %s\n",
                       rs, 
                       rs->rs_xid, rs->rs_transno,
-                      rs->rs_msg.opc, exp->exp_connection->c_peer.peer_nid);
+                      rs->rs_msg.opc, 
+                      ptlrpc_peernid2str(&exp->exp_connection->c_peer, str));
         }
 
         if ((!been_handled && rs->rs_on_net) || 
diff --git a/lustre/utils/lctl.c b/lustre/utils/lctl.c
index b1c8ca5a87374f7632eb134a03bbdf95d72f89f1..fadd9a6d83348c2b71ffb3cc60481ad87b1f0e10 100644
--- a/lustre/utils/lctl.c
+++ b/lustre/utils/lctl.c
@@ -27,7 +27,6 @@
 
 #include <stdlib.h>
 #include <stdio.h>
-#include <portals/api-support.h>
 #include <portals/ptlctl.h>
 #include "obdctl.h"
 #include "parser.h"
diff --git a/lustre/utils/lfs.c b/lustre/utils/lfs.c
index 658a921157c603cddda818f0e38e27f7e5eddace..2fcf5ad01e1a0a02c07c67dbf7d04e2578f57da5 100644
--- a/lustre/utils/lfs.c
+++ b/lustre/utils/lfs.c
@@ -29,7 +29,6 @@
 #include <getopt.h>
 #include <string.h>
 #include <mntent.h>
-#include <portals/api-support.h>
 #include <portals/ptlctl.h>
 
 #include <liblustre.h>