From f86dc286fd3cb3e28e69bcc6a048a2efd02521c7 Mon Sep 17 00:00:00 2001
From: Bruce Korb <bruce_korb@xyratex.com>
Date: Sat, 12 Nov 2011 09:34:49 -0800
Subject: [PATCH] lustre-devel packaging

* autoMakefile.am
  Constrain lines to 80 columns (readability)
  Per automake maintainers, configurables should be set to a
    make file macro before use.  Enables "make" time replacement.

* build/autoMakefile.am.toplevel
  Constrain lines to 80 columns (readability)

* libcfs/include/Makefile.am
  Put every header under libcfs/include into nobase_pkginclude_HEADERS.
  Do this at "make install" time to capture

* lnet/autoconf/lustre-lnet.m4
  The body of an m4 (autoconf) macro is indented (readability).
  "LNET_MAX_PAYLOAD" is now a configured value
  lnet/include/lnet/types.h is now a configured file
  Alphabetize and indent the configured files

* lnet/include/Makefile.am
  Collect the neaders into nobase_pkginclude_HEADERS and
  nodist_nobase_pkginclude_HEADERS (just lnet/types.h)

* lnet/include/lnet/Makefile.am
  lnet/include/lnet/types.h is now a configured file

* lnet/include/lnet/types.h
  Renamed to:
* lnet/include/lnet/types.h.in
  Add configured #define for LNET_MAX_PAYLOAD and adjust CPP testing.

* lustre.spec.in
  354 columns in a single line is too much.  Trim the egregious ones.
  add a "%package devel" directive
  In %install section, separate "devel" files from non-devel and list
  them in lustre-devel.files and lustre.files.

* lustre/autoconf/lustre-core.m4
  Add config.h #define for OBD_MAX_IOCTL_BUFFER and make it a
  substitution value as well.
  lustre/include/lustre/Makefile.am is removed.  Do not configure.

* lustre/include/Makefile.am
  The lustre/include/lustre/*.h headers get installed in pkginclude.
  Drop the rest into nodist_pkginclude_HEADER (lustre_ver.h) or
  nobase_pkginclude_HEADER (everything else).

* lustre/include/linux/Makefile.am
  The EXTRA_DIST value is obsolete.

* lustre/include/linux/lustre_acl.h
  Fix spelling of "Should not include directly".

* lustre/include/lustre/Makefile.am
  Obsolete

* lustre/include/lustre_sec.h
  Prefer "__u32" to "uint32_t".  Eliminates need for inttypes.h.

* lustre/include/lustre_ver.h.in
  Add configured #define OBD_MAX_IOCTL_BUFFER

* lustre/utils/Makefile.am
  Move obd.c and lustre_cfg.c sources to convenience library.
---
 autoMakefile.am                   |   36 ++-
 build/autoMakefile.am.toplevel    |   17 +-
 libcfs/include/Makefile.am        |    8 +
 lnet/autoconf/lustre-lnet.m4      |  102 ++++----
 lnet/include/Makefile.am          |   10 +
 lnet/include/lnet/Makefile.am     |    2 +-
 lnet/include/lnet/types.h         |  509 -------------------------------------
 lnet/include/lnet/types.h.in      |  505 ++++++++++++++++++++++++++++++++++++
 lustre.spec.in                    |  156 ++++++++----
 lustre/autoconf/lustre-core.m4    |   13 +-
 lustre/include/Makefile.am        |   71 +++++-
 lustre/include/linux/Makefile.am  |    7 -
 lustre/include/linux/lustre_acl.h |    2 +-
 lustre/include/lustre/Makefile.am |   42 ---
 lustre/include/lustre_sec.h       |    4 +-
 lustre/include/lustre_ver.h.in    |   23 +-
 lustre/utils/Makefile.am          |   12 +-
 17 files changed, 814 insertions(+), 705 deletions(-)
 delete mode 100644 lnet/include/lnet/types.h
 create mode 100644 lnet/include/lnet/types.h.in
 delete mode 100644 lustre/include/lustre/Makefile.am

diff --git a/autoMakefile.am b/autoMakefile.am
index d40970f..65f2263 100644
--- a/autoMakefile.am
+++ b/autoMakefile.am
@@ -1,8 +1,30 @@
-SUBDIRS := @LDISKFS_SUBDIR@ @SPL_SUBDIR@ @ZFS_SUBDIR@ . @LIBSYSIO_SUBDIR@ @SNMP_SUBDIR@ @LUSTREIOKIT_SUBDIR@ @LIBCFS_SUBDIR@ lnet lustre
-DIST_SUBDIRS := @LDISKFS_DIST_SUBDIR@ @SNMP_DIST_SUBDIR@ libsysio lustre-iokit @LIBCFS_SUBDIR@ lnet lustre
+
+SUBDIRS := @LDISKFS_SUBDIR@ \
+	@SPL_SUBDIR@ \
+	@ZFS_SUBDIR@ \
+	. \
+	@LIBSYSIO_SUBDIR@ \
+	@SNMP_SUBDIR@ \
+	@LUSTREIOKIT_SUBDIR@ \
+	@LIBCFS_SUBDIR@ \
+	lnet \
+	lustre
+
+DIST_SUBDIRS := @LDISKFS_DIST_SUBDIR@ \
+	@SNMP_DIST_SUBDIR@ \
+	libsysio \
+	lustre-iokit \
+	@LIBCFS_SUBDIR@ \
+	lnet \
+	lustre
+
 SOURCES_SUBDIRS := @LDISKFS_SUBDIR@ @LIBCFS_SUBDIR@ lnet lustre
 RPM_SUBDIRS := @LDISKFS_SUBDIR@ @LUSTREIOKIT_SUBDIR@
 MODULE_SYMVERS_DEPS = module-symvers
+SYMVERFILE      := @SYMVERFILE@
+LDISKFS_DIR     := @LDISKFS_DIR@
+LDISKFS_SYMVER  := $(LDISKFS_DIR)/$(SYMVERFILE)
+LDISKFS_OBJ     := @LDISKFS_OBJ@
 
 @TESTS_TRUE@BUILD_TESTS = true
 @TESTS_FALSE@BUILD_TESTS = false
@@ -17,14 +39,14 @@ endif
 
 module-symvers-ldiskfs:
 if LDISKFS_ENABLED
-	@if [ -f @LDISKFS_DIR@/@SYMVERFILE@ ]; then \
-		cat @LDISKFS_DIR@/@SYMVERFILE@ >>@SYMVERFILE@; \
-	elif [ -f @LDISKFS_DIR@/ldiskfs/@SYMVERFILE@ ]; then \
-		cat @LDISKFS_DIR@/ldiskfs/@SYMVERFILE@ >>@SYMVERFILE@; \
+	@if [ -f $(LDISKFS_SYMVER) ]; then \
+		cat $(LDISKFS_SYMVER) >> $(SYMVERFILE); \
+	elif [ -f $(LDISKFS_DIR)/ldiskfs/$(SYMVERFILE) ]; then \
+		cat $(LDISKFS_DIR)/ldiskfs/$(SYMVERFILE) >> $(SYMVERFILE); \
 	else \
 		echo -e "\n" \
 		"*** Missing ldiskfs symbols. Ensure you have built ldiskfs:\n"\
-		"*** - @LDISKFS_OBJ@/ldiskfs/@SYMVERFILE@\n"; \
+		"*** - $(LDISKFS_OBJ)/ldiskfs/$(SYMVERFILE)\n"; \
 		exit 1; \
 	fi
 endif # LDISKFS_ENABLED
diff --git a/build/autoMakefile.am.toplevel b/build/autoMakefile.am.toplevel
index 036ee86..fae9d35 100644
--- a/build/autoMakefile.am.toplevel
+++ b/build/autoMakefile.am.toplevel
@@ -1,3 +1,4 @@
+# -*- Mode: Makefile -*-
 # This file is included by each package's toplevel autoMakefile[.am],
 # which must define SUBDIRS as a minimum.
 
@@ -104,16 +105,24 @@ EXTRA_DIST = @PACKAGE_TARNAME@.spec					\
 	build/funcs.sh build/find_linux_rpms build/exit_traps.sh
 
 rpms-real: @PACKAGE_TARNAME@.spec dist Makefile
-	CONFIGURE_ARGS=$$(echo $$(eval echo $(ac_configure_args)) | sed -re 's/--(en|dis)able-tests//'); \
+	CONFIGURE_ARGS=$$(\
+		echo $$(eval echo $(ac_configure_args)) | \
+			sed -re 's/--(en|dis)able-tests//'); \
 	if [ -n "@LINUX@" ]; then \
-		CONFIGURE_ARGS=$$(echo $$(eval echo $$CONFIGURE_ARGS) | sed -re 's/--with-linux=[^ ][^ ]*//'); \
+		CONFIGURE_ARGS=$$(\
+			echo $$(eval echo $$CONFIGURE_ARGS) | \
+				sed -re 's/--with-linux=[^ ][^ ]*//'); \
 		RPMARGS="--define \"kdir @LINUX@\""; \
-		CONFIGURE_ARGS=$$(echo $$(eval echo $$CONFIGURE_ARGS) | sed -re 's/--with-linux-obj=[^ ][^ ]*//'); \
+		CONFIGURE_ARGS=$$(\
+			echo $$(eval echo $$CONFIGURE_ARGS) | \
+				sed -re 's/--with-linux-obj=[^ ][^ ]*//'); \
 		if [ -n "@LINUX_OBJ@" -a "@LINUX_OBJ@" != "@LINUX@" ]; then \
 			RPMARGS="$$RPMARGS --define \"kobjdir @LINUX_OBJ@\""; \
 		fi; \
 	fi; \
-	CONFIGURE_ARGS=$$(echo $$(eval echo $$CONFIGURE_ARGS) | sed -re 's/--with-release=[^ ][^ ]*//'); \
+	CONFIGURE_ARGS=$$(\
+		echo $$(eval echo $$CONFIGURE_ARGS) | \
+			sed -re 's/--with-release=[^ ][^ ]*//'); \
 	RPMARGS="$$RPMARGS --define \"configure_args $$CONFIGURE_ARGS\""; \
 	if ! $(BUILD_TESTS); then \
 		RPMARGS="$$RPMARGS --define \"build_lustre_tests 0\""; \
diff --git a/libcfs/include/Makefile.am b/libcfs/include/Makefile.am
index 8289f5f..fc10eda 100644
--- a/libcfs/include/Makefile.am
+++ b/libcfs/include/Makefile.am
@@ -1 +1,9 @@
 SUBDIRS = libcfs 
+
+if UTILS
+# Assumption notice:  all headers under this directory are distributed
+# If they get configured in the future, the configured headers must
+# be listed separately in nodist_nobase_pkginclude_HEADERS.
+#
+nobase_pkginclude_HEADERS := $(shell find $(SUBDIRS) -name '*.h')
+endif
diff --git a/lnet/autoconf/lustre-lnet.m4 b/lnet/autoconf/lustre-lnet.m4
index 1a070ac..7248e57 100644
--- a/lnet/autoconf/lustre-lnet.m4
+++ b/lnet/autoconf/lustre-lnet.m4
@@ -3,21 +3,22 @@
 #
 # configure maximum payload
 #
-AC_DEFUN([LN_CONFIG_MAX_PAYLOAD],
-[AC_MSG_CHECKING([for non-default maximum LNET payload])
-AC_ARG_WITH([max-payload-mb],
-	AC_HELP_STRING([--with-max-payload-mb=MBytes],
-                       [set maximum lnet payload in MBytes]),
-        [
-		AC_MSG_RESULT([$with_max_payload_mb])
-	        LNET_MAX_PAYLOAD_MB=$with_max_payload_mb
-		LNET_MAX_PAYLOAD="(($with_max_payload_mb)<<20)"
-	], [
-		AC_MSG_RESULT([no])
-		LNET_MAX_PAYLOAD="LNET_MTU"
-	])
-        AC_DEFINE_UNQUOTED(LNET_MAX_PAYLOAD, $LNET_MAX_PAYLOAD,
-			   [Max LNET payload])
+AC_DEFUN([LN_CONFIG_MAX_PAYLOAD],[
+  AC_MSG_CHECKING([for non-default maximum LNET payload])
+  AC_ARG_WITH([max-payload-mb],
+    AC_HELP_STRING([--with-max-payload-mb=MBytes],
+                   [set maximum lnet payload in MBytes]),
+
+    [ AC_MSG_RESULT([$with_max_payload_mb])
+      LNET_MAX_PAYLOAD_MB=$with_max_payload_mb
+      LNET_MAX_PAYLOAD="(($with_max_payload_mb)<<20)"],
+
+    [ AC_MSG_RESULT([no])
+      LNET_MAX_PAYLOAD="LNET_MTU"
+  ])
+  AC_DEFINE_UNQUOTED(LNET_MAX_PAYLOAD, $LNET_MAX_PAYLOAD,
+		     [Max LNET payload])
+  AC_SUBST(LNET_MAX_PAYLOAD)
 ])
 
 #
@@ -735,39 +736,40 @@ AM_CONDITIONAL(BUILD_USOCKLND, test x$USOCKLND = "xusocklnd")
 #
 # files that should be generated with AC_OUTPUT
 #
-AC_DEFUN([LN_CONFIG_FILES],
-[AC_CONFIG_FILES([
-lnet/Kernelenv
-lnet/Makefile
-lnet/autoMakefile
-lnet/autoconf/Makefile
-lnet/doc/Makefile
-lnet/include/Makefile
-lnet/include/lnet/Makefile
-lnet/include/lnet/linux/Makefile
-lnet/klnds/Makefile
-lnet/klnds/autoMakefile
-lnet/klnds/mxlnd/autoMakefile
-lnet/klnds/mxlnd/Makefile
-lnet/klnds/o2iblnd/Makefile
-lnet/klnds/o2iblnd/autoMakefile
-lnet/klnds/qswlnd/Makefile
-lnet/klnds/qswlnd/autoMakefile
-lnet/klnds/ralnd/Makefile
-lnet/klnds/ralnd/autoMakefile
-lnet/klnds/socklnd/Makefile
-lnet/klnds/socklnd/autoMakefile
-lnet/klnds/ptllnd/Makefile
-lnet/klnds/ptllnd/autoMakefile
-lnet/lnet/Makefile
-lnet/lnet/autoMakefile
-lnet/selftest/Makefile
-lnet/selftest/autoMakefile
-lnet/ulnds/Makefile
-lnet/ulnds/autoMakefile
-lnet/ulnds/socklnd/Makefile
-lnet/ulnds/ptllnd/Makefile
-lnet/utils/Makefile
-lnet/include/lnet/darwin/Makefile
-])
+AC_DEFUN([LN_CONFIG_FILES],[
+  AC_CONFIG_FILES([
+    lnet/Kernelenv
+    lnet/Makefile
+    lnet/autoMakefile
+    lnet/autoconf/Makefile
+    lnet/doc/Makefile
+    lnet/include/Makefile
+    lnet/include/lnet/Makefile
+    lnet/include/lnet/darwin/Makefile
+    lnet/include/lnet/linux/Makefile
+    lnet/include/lnet/types.h
+    lnet/klnds/Makefile
+    lnet/klnds/autoMakefile
+    lnet/klnds/mxlnd/Makefile
+    lnet/klnds/mxlnd/autoMakefile
+    lnet/klnds/o2iblnd/Makefile
+    lnet/klnds/o2iblnd/autoMakefile
+    lnet/klnds/ptllnd/Makefile
+    lnet/klnds/ptllnd/autoMakefile
+    lnet/klnds/qswlnd/Makefile
+    lnet/klnds/qswlnd/autoMakefile
+    lnet/klnds/ralnd/Makefile
+    lnet/klnds/ralnd/autoMakefile
+    lnet/klnds/socklnd/Makefile
+    lnet/klnds/socklnd/autoMakefile
+    lnet/lnet/Makefile
+    lnet/lnet/autoMakefile
+    lnet/selftest/Makefile
+    lnet/selftest/autoMakefile
+    lnet/ulnds/Makefile
+    lnet/ulnds/autoMakefile
+    lnet/ulnds/ptllnd/Makefile
+    lnet/ulnds/socklnd/Makefile
+    lnet/utils/Makefile
+  ])
 ])
diff --git a/lnet/include/Makefile.am b/lnet/include/Makefile.am
index 66b3092..010bcf4 100644
--- a/lnet/include/Makefile.am
+++ b/lnet/include/Makefile.am
@@ -1,3 +1,13 @@
+
 SUBDIRS = lnet
 
 EXTRA_DIST = cygwin-ioctl.h
+
+if UTILS
+nobase_pkginclude_HEADERS := $(\
+	shell find $(SUBDIRS) -name '*.h' | \
+	grep -v lnet/types.h )
+
+nodist_nobase_pkginclude_HEADERS := \
+	lnet/types.h
+endif
diff --git a/lnet/include/lnet/Makefile.am b/lnet/include/lnet/Makefile.am
index 9b60bbd..3797f1a 100644
--- a/lnet/include/lnet/Makefile.am
+++ b/lnet/include/lnet/Makefile.am
@@ -7,5 +7,5 @@ endif
 DIST_SUBDIRS := linux darwin
 
 EXTRA_DIST = api.h api-support.h \
-	lib-lnet.h lib-types.h lnet.h lnetctl.h types.h \
+	lib-lnet.h lib-types.h lnet.h lnetctl.h types.h.in \
         socklnd.h ptllnd.h ptllnd_wire.h lnetst.h lnet-sysctl.h
diff --git a/lnet/include/lnet/types.h b/lnet/include/lnet/types.h
deleted file mode 100644
index bb6a5f0..0000000
--- a/lnet/include/lnet/types.h
+++ /dev/null
@@ -1,509 +0,0 @@
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * 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.
- *
- * 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).
- *
- * 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
- *
- * 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 (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- */
-
-#ifndef __LNET_TYPES_H__
-#define __LNET_TYPES_H__
-
-/** \addtogroup lnet
- * @{ */
-
-#include <libcfs/libcfs.h>
-
-/** \addtogroup lnet_addr
- * @{ */
-
-/** Portal reserved for LNet's own use.
- * \see lustre/include/lustre/lustre_idl.h for Lustre portal assignments.
- */
-#define LNET_RESERVED_PORTAL      0
-
-/**
- * Address of an end-point in an LNet network.
- *
- * A node can have multiple end-points and hence multiple addresses.
- * An LNet network can be a simple network (e.g. tcp0) or a network of
- * LNet networks connected by LNet routers. Therefore an end-point address
- * has two parts: network ID, and address within a network.
- *
- * \see LNET_NIDNET, LNET_NIDADDR, and LNET_MKNID.
- */
-typedef __u64 lnet_nid_t;
-/**
- * ID of a process in a node. Shortened as PID to distinguish from
- * lnet_process_id_t, the global process ID.
- */
-typedef __u32 lnet_pid_t;
-
-/** wildcard NID that matches any end-point address */
-#define LNET_NID_ANY      ((lnet_nid_t) -1)
-/** wildcard PID that matches any lnet_pid_t */
-#define LNET_PID_ANY      ((lnet_pid_t) -1)
-
-#ifdef CRAY_XT3
-typedef __u32 lnet_uid_t;
-#define LNET_UID_ANY      ((lnet_uid_t) -1)
-#endif
-
-#define LNET_PID_RESERVED 0xf0000000 /* reserved bits in PID */
-#define LNET_PID_USERFLAG 0x80000000 /* set in userspace peers */
-
-#define LNET_TIME_FOREVER    (-1)
-
-/**
- * Objects maintained by the LNet are accessed through handles. Handle types
- * have names of the form lnet_handle_xx_t, where xx is one of the two letter
- * object type codes ('eq' for event queue, 'md' for memory descriptor, and
- * 'me' for match entry).
- * Each type of object is given a unique handle type to enhance type checking.
- * The type lnet_handle_any_t can be used when a generic handle is needed.
- * Every handle value can be converted into a value of type lnet_handle_any_t
- * without loss of information.
- */
-typedef struct {
-        __u64         cookie;
-} lnet_handle_any_t;
-
-typedef lnet_handle_any_t lnet_handle_eq_t;
-typedef lnet_handle_any_t lnet_handle_md_t;
-typedef lnet_handle_any_t lnet_handle_me_t;
-
-#define LNET_WIRE_HANDLE_COOKIE_NONE   (-1)
-
-/**
- * Invalidate handle \a h.
- */
-static inline void LNetInvalidateHandle(lnet_handle_any_t *h)
-{
-        h->cookie = LNET_WIRE_HANDLE_COOKIE_NONE;
-}
-
-/**
- * Compare handles \a h1 and \a h2.
- *
- * \return 1 if handles are equal, 0 if otherwise.
- */
-static inline int LNetHandleIsEqual (lnet_handle_any_t h1, lnet_handle_any_t h2)
-{
-        return (h1.cookie == h2.cookie);
-}
-
-/**
- * Check whether handle \a h is invalid.
- *
- * \return 1 if handle is invalid, 0 if valid.
- */
-static inline int LNetHandleIsInvalid(lnet_handle_any_t h)
-{
-        return (LNET_WIRE_HANDLE_COOKIE_NONE == h.cookie);
-}
-
-/**
- * Global process ID.
- */
-typedef struct {
-        /** node id */
-        lnet_nid_t nid;
-        /** process id */
-        lnet_pid_t pid;
-} lnet_process_id_t;
-/** @} lnet_addr */
-
-/** \addtogroup lnet_me
- * @{ */
-
-/**
- * Specifies whether the match entry or memory descriptor should be unlinked
- * automatically (LNET_UNLINK) or not (LNET_RETAIN).
- */
-typedef enum {
-        LNET_RETAIN = 0,
-        LNET_UNLINK
-} lnet_unlink_t;
-
-/**
- * Values of the type lnet_ins_pos_t are used to control where a new match
- * entry is inserted. The value LNET_INS_BEFORE is used to insert the new
- * entry before the current entry or before the head of the list. The value
- * LNET_INS_AFTER is used to insert the new entry after the current entry
- * or after the last item in the list.
- */
-typedef enum {
-        LNET_INS_BEFORE,
-        LNET_INS_AFTER
-} lnet_ins_pos_t;
-
-/** @} lnet_me */
-
-/** \addtogroup lnet_md
- * @{ */
-
-/**
- * Defines the visible parts of a memory descriptor. Values of this type
- * are used to initialize memory descriptors.
- */
-typedef struct {
-        /**
-         * Specify the memory region associated with the memory descriptor.
-         * If the options field has:
-         * - LNET_MD_KIOV bit set: The start field points to the starting
-         * address of an array of lnet_kiov_t and the length field specifies
-         * the number of entries in the array. The length can't be bigger
-         * than LNET_MAX_IOV. The lnet_kiov_t is used to describe page-based
-         * fragments that are not necessarily mapped in virtal memory.
-         * - LNET_MD_IOVEC bit set: The start field points to the starting
-         * address of an array of struct iovec and the length field specifies
-         * the number of entries in the array. The length can't be bigger
-         * than LNET_MAX_IOV. The struct iovec is used to describe fragments
-         * that have virtual addresses.
-         * - Otherwise: The memory region is contiguous. The start field
-         * specifies the starting address for the memory region and the
-         * length field specifies its length.
-         *
-         * When the memory region is fragmented, all fragments but the first
-         * one must start on page boundary, and all but the last must end on
-         * page boundary.
-         */
-        void            *start;
-        unsigned int     length;
-        /**
-         * Specifies the maximum number of operations that can be performed
-         * on the memory descriptor. An operation is any action that could
-         * possibly generate an event. In the usual case, the threshold value
-         * is decremented for each operation on the MD. When the threshold
-         * drops to zero, the MD becomes inactive and does not respond to
-         * operations. A threshold value of LNET_MD_THRESH_INF indicates that
-         * there is no bound on the number of operations that may be applied
-         * to a MD.
-         */
-        int              threshold;
-        /**
-         * Specifies the largest incoming request that the memory descriptor
-         * should respond to. When the unused portion of a MD (length -
-         * local offset) falls below this value, the MD becomes inactive and
-         * does not respond to further operations. This value is only used
-         * if the LNET_MD_MAX_SIZE option is set.
-         */
-        int              max_size;
-        /**
-         * Specifies the behavior of the memory descriptor. A bitwise OR
-         * of the following values can be used:
-         * - LNET_MD_OP_PUT: The LNet PUT operation is allowed on this MD.
-         * - LNET_MD_OP_GET: The LNet GET operation is allowed on this MD.
-         * - LNET_MD_MANAGE_REMOTE: The offset used in accessing the memory
-         *   region is provided by the incoming request. By default, the
-         *   offset is maintained locally. When maintained locally, the
-         *   offset is incremented by the length of the request so that
-         *   the next operation (PUT or GET) will access the next part of
-         *   the memory region. Note that only one offset variable exists
-         *   per memory descriptor. If both PUT and GET operations are
-         *   performed on a memory descriptor, the offset is updated each time.
-         * - LNET_MD_TRUNCATE: The length provided in the incoming request can
-         *   be reduced to match the memory available in the region (determined
-         *   by subtracting the offset from the length of the memory region).
-         *   By default, if the length in the incoming operation is greater
-         *   than the amount of memory available, the operation is rejected.
-         * - LNET_MD_ACK_DISABLE: An acknowledgment should not be sent for
-         *   incoming PUT operations, even if requested. By default,
-         *   acknowledgments are sent for PUT operations that request an
-         *   acknowledgment. Acknowledgments are never sent for GET operations.
-         *   The data sent in the REPLY serves as an implicit acknowledgment.
-         * - LNET_MD_KIOV: The start and length fields specify an array of
-         *   lnet_kiov_t.
-         * - LNET_MD_IOVEC: The start and length fields specify an array of
-         *   struct iovec.
-         * - LNET_MD_MAX_SIZE: The max_size field is valid.
-         *
-         * Note:
-         * - LNET_MD_KIOV or LNET_MD_IOVEC allows for a scatter/gather
-         *   capability for memory descriptors. They can't be both set.
-         * - When LNET_MD_MAX_SIZE is set, the total length of the memory
-         *   region (i.e. sum of all fragment lengths) must not be less than
-         *   \a max_size.
-         */
-        unsigned int     options;
-        /**
-         * A user-specified value that is associated with the memory
-         * descriptor. The value does not need to be a pointer, but must fit
-         * in the space used by a pointer. This value is recorded in events
-         * associated with operations on this MD.
-         */
-        void            *user_ptr;
-        /**
-         * A handle for the event queue used to log the operations performed on
-         * the memory region. If this argument is a NULL handle (i.e. nullified
-         * by LNetInvalidateHandle()), operations performed on this memory
-         * descriptor are not logged.
-         */
-        lnet_handle_eq_t eq_handle;
-} lnet_md_t;
-
-/* Max Transfer Unit (minimum supported everywhere) */
-#define LNET_MTU_BITS   20
-#define LNET_MTU        (1<<LNET_MTU_BITS)
-
-/** limit on the number of fragments in discontiguous MDs */
-#define LNET_MAX_IOV    256
-
-/* Max payload size */
-#ifndef LNET_MAX_PAYLOAD
-# error "LNET_MAX_PAYLOAD must be defined in config.h"
-#else
-# if (LNET_MAX_PAYLOAD < LNET_MTU)
-#  error "LNET_MAX_PAYLOAD too small - error in configure --with-max-payload-mb"
-# elif defined(__KERNEL__)
-#  if (LNET_MAX_PAYLOAD > (PAGE_SIZE * LNET_MAX_IOV))
-/*  PAGE_SIZE is a constant: check with cpp! */
-#   error "LNET_MAX_PAYLOAD too large - error in configure --with-max-payload-mb"
-#  endif
-# endif
-#endif
-
-/**
- * Options for the MD structure. See lnet_md_t::options.
- */
-#define LNET_MD_OP_PUT               (1 << 0)
-/** See lnet_md_t::options. */
-#define LNET_MD_OP_GET               (1 << 1)
-/** See lnet_md_t::options. */
-#define LNET_MD_MANAGE_REMOTE        (1 << 2)
-/* unused                            (1 << 3) */
-/** See lnet_md_t::options. */
-#define LNET_MD_TRUNCATE             (1 << 4)
-/** See lnet_md_t::options. */
-#define LNET_MD_ACK_DISABLE          (1 << 5)
-/** See lnet_md_t::options. */
-#define LNET_MD_IOVEC                (1 << 6)
-/** See lnet_md_t::options. */
-#define LNET_MD_MAX_SIZE             (1 << 7)
-/** See lnet_md_t::options. */
-#define LNET_MD_KIOV                 (1 << 8)
-
-/* For compatibility with Cray Portals */
-#define LNET_MD_PHYS                         0
-
-/** Infinite threshold on MD operations. See lnet_md_t::threshold */
-#define LNET_MD_THRESH_INF       (-1)
-
-/* NB lustre portals uses struct iovec internally! */
-typedef struct iovec lnet_md_iovec_t;
-
-/**
- * A page-based fragment of a MD.
- */
-typedef struct {
-        /** Pointer to the page where the fragment resides */
-        cfs_page_t      *kiov_page;
-        /** Length in bytes of the fragment */
-        unsigned int     kiov_len;
-        /**
-         * Starting offset of the fragment within the page. Note that the
-         * end of the fragment must not pass the end of the page; i.e.,
-         * kiov_len + kiov_offset <= CFS_PAGE_SIZE.
-         */
-        unsigned int     kiov_offset;
-} lnet_kiov_t;
-/** @} lnet_md */
-
-/** \addtogroup lnet_eq
- * @{ */
-
-/**
- * Six types of events can be logged in an event queue.
- */
-typedef enum {
-        /** An incoming GET operation has completed on the MD. */
-        LNET_EVENT_GET,
-        /**
-         * An incoming PUT operation has completed on the MD. The
-         * underlying layers will not alter the memory (on behalf of this
-         * operation) once this event has been logged.
-         */
-        LNET_EVENT_PUT,
-        /**
-         * A REPLY operation has completed. This event is logged after the
-         * data (if any) from the REPLY has been written into the MD.
-         */
-        LNET_EVENT_REPLY,
-        /** An acknowledgment has been received. */
-        LNET_EVENT_ACK,
-        /**
-         * An outgoing send (PUT or GET) operation has completed. This event
-         * is logged after the entire buffer has been sent and it is safe for
-         * the caller to reuse the buffer.
-         *
-         * Note:
-         * - The LNET_EVENT_SEND doesn't guarantee message delivery. It can
-         *   happen even when the message has not yet been put out on wire.
-         * - It's unsafe to assume that in an outgoing GET operation
-         *   the LNET_EVENT_SEND event would happen before the
-         *   LNET_EVENT_REPLY event. The same holds for LNET_EVENT_SEND and
-         *   LNET_EVENT_ACK events in an outgoing PUT operation.
-         */
-        LNET_EVENT_SEND,
-        /**
-         * A MD has been unlinked. Note that LNetMDUnlink() does not
-         * necessarily trigger an LNET_EVENT_UNLINK event.
-         * \see LNetMDUnlink
-         */
-        LNET_EVENT_UNLINK,
-} lnet_event_kind_t;
-
-#define LNET_SEQ_BASETYPE       long
-typedef unsigned LNET_SEQ_BASETYPE lnet_seq_t;
-#define LNET_SEQ_GT(a,b)        (((signed LNET_SEQ_BASETYPE)((a) - (b))) > 0)
-
-/* XXX
- * cygwin need the pragma line, not clear if it's needed in other places.
- * checking!!!
- */
-#ifdef __CYGWIN__
-#pragma pack(push, 4)
-#endif
-
-/**
- * Information about an event on a MD.
- */
-typedef struct {
-        /** The identifier (nid, pid) of the target. */
-        lnet_process_id_t   target;
-        /** The identifier (nid, pid) of the initiator. */
-        lnet_process_id_t   initiator;
-        /**
-         * The NID of the immediate sender. If the request has been forwarded
-         * by routers, this is the NID of the last hop; otherwise it's the
-         * same as the initiator.
-         */
-        lnet_nid_t          sender;
-        /** Indicates the type of the event. */
-        lnet_event_kind_t   type;
-        /** The portal table index specified in the request */
-        unsigned int        pt_index;
-        /** A copy of the match bits specified in the request. */
-        __u64               match_bits;
-        /** The length (in bytes) specified in the request. */
-        unsigned int        rlength;
-        /**
-         * The length (in bytes) of the data that was manipulated by the
-         * operation. For truncated operations, the manipulated length will be
-         * the number of bytes specified by the MD (possibly with an offset,
-         * see lnet_md_t). For all other operations, the manipulated length
-         * will be the length of the requested operation, i.e. rlength.
-         */
-        unsigned int        mlength;
-        /**
-         * The handle to the MD associated with the event. The handle may be
-         * invalid if the MD has been unlinked.
-         */
-        lnet_handle_md_t    md_handle;
-        /**
-         * A snapshot of the state of the MD immediately after the event has
-         * been processed. In particular, the threshold field in md will
-         * reflect the value of the threshold after the operation occurred.
-         */
-        lnet_md_t           md;
-        /**
-         * 64 bits of out-of-band user data. Only valid for LNET_EVENT_PUT.
-         * \see LNetPut
-         */
-        __u64               hdr_data;
-        /**
-         * Indicates the completion status of the operation. It's 0 for
-         * successful operations, otherwise it's an error code.
-         */
-        int                 status;
-        /**
-         * Indicates whether the MD has been unlinked. Note that:
-         * - An event with unlinked set is the last event on the MD.
-         * - This field is also set for an explicit LNET_EVENT_UNLINK event.
-         * \see LNetMDUnlink
-         */
-        int                 unlinked;
-        /**
-         * The displacement (in bytes) into the memory region that the
-         * operation used. The offset can be determined by the operation for
-         * a remote managed MD or by the local MD.
-         * \see lnet_md_t::options
-         */
-        unsigned int        offset;
-#ifdef CRAY_XT3
-        lnet_uid_t          uid;
-#endif
-
-        /**
-         * The sequence number for this event. Sequence numbers are unique
-         * to each event.
-         */
-        volatile lnet_seq_t sequence;
-} lnet_event_t;
-#ifdef __CYGWIN__
-#pragma pop
-#endif
-
-/**
- * Event queue handler function type.
- *
- * The EQ handler runs for each event that is deposited into the EQ. The
- * handler is supplied with a pointer to the event that triggered the
- * handler invocation.
- *
- * The handler must not block, must be reentrant, and must not call any LNet
- * API functions. It should return as quickly as possible.
- */
-typedef void (*lnet_eq_handler_t)(lnet_event_t *event);
-#define LNET_EQ_HANDLER_NONE NULL
-/** @} lnet_eq */
-
-/** \addtogroup lnet_data
- * @{ */
-
-/**
- * Specify whether an acknowledgment should be sent by target when the PUT
- * operation completes (i.e., when the data has been written to a MD of the
- * target process).
- *
- * \see lnet_md_t::options for the discussion on LNET_MD_ACK_DISABLE by which
- * acknowledgments can be disabled for a MD.
- */
-typedef enum {
-        /** Request an acknowledgment */
-        LNET_ACK_REQ,
-        /** Request that no acknowledgment should be generated. */
-        LNET_NOACK_REQ
-} lnet_ack_req_t;
-/** @} lnet_data */
-
-/** @} lnet */
-#endif
diff --git a/lnet/include/lnet/types.h.in b/lnet/include/lnet/types.h.in
new file mode 100644
index 0000000..6d9c4cf
--- /dev/null
+++ b/lnet/include/lnet/types.h.in
@@ -0,0 +1,505 @@
+/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
+ * vim:expandtab:shiftwidth=8:tabstop=8:
+ *
+ * GPL HEADER START
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * 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.
+ *
+ * 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).
+ *
+ * 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
+ *
+ * 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 (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Use is subject to license terms.
+ */
+/*
+ * This file is part of Lustre, http://www.lustre.org/
+ * Lustre is a trademark of Sun Microsystems, Inc.
+ */
+
+#ifndef __LNET_TYPES_H__
+#define __LNET_TYPES_H__
+
+/** \addtogroup lnet
+ * @{ */
+
+#include <libcfs/libcfs.h>
+
+/** \addtogroup lnet_addr
+ * @{ */
+
+/** Portal reserved for LNet's own use.
+ * \see lustre/include/lustre/lustre_idl.h for Lustre portal assignments.
+ */
+#define LNET_RESERVED_PORTAL      0
+
+/**
+ * Address of an end-point in an LNet network.
+ *
+ * A node can have multiple end-points and hence multiple addresses.
+ * An LNet network can be a simple network (e.g. tcp0) or a network of
+ * LNet networks connected by LNet routers. Therefore an end-point address
+ * has two parts: network ID, and address within a network.
+ *
+ * \see LNET_NIDNET, LNET_NIDADDR, and LNET_MKNID.
+ */
+typedef __u64 lnet_nid_t;
+/**
+ * ID of a process in a node. Shortened as PID to distinguish from
+ * lnet_process_id_t, the global process ID.
+ */
+typedef __u32 lnet_pid_t;
+
+/** wildcard NID that matches any end-point address */
+#define LNET_NID_ANY      ((lnet_nid_t) -1)
+/** wildcard PID that matches any lnet_pid_t */
+#define LNET_PID_ANY      ((lnet_pid_t) -1)
+
+#ifdef CRAY_XT3
+typedef __u32 lnet_uid_t;
+#define LNET_UID_ANY      ((lnet_uid_t) -1)
+#endif
+
+#define LNET_PID_RESERVED 0xf0000000 /* reserved bits in PID */
+#define LNET_PID_USERFLAG 0x80000000 /* set in userspace peers */
+
+#define LNET_TIME_FOREVER    (-1)
+
+/**
+ * Objects maintained by the LNet are accessed through handles. Handle types
+ * have names of the form lnet_handle_xx_t, where xx is one of the two letter
+ * object type codes ('eq' for event queue, 'md' for memory descriptor, and
+ * 'me' for match entry).
+ * Each type of object is given a unique handle type to enhance type checking.
+ * The type lnet_handle_any_t can be used when a generic handle is needed.
+ * Every handle value can be converted into a value of type lnet_handle_any_t
+ * without loss of information.
+ */
+typedef struct {
+        __u64         cookie;
+} lnet_handle_any_t;
+
+typedef lnet_handle_any_t lnet_handle_eq_t;
+typedef lnet_handle_any_t lnet_handle_md_t;
+typedef lnet_handle_any_t lnet_handle_me_t;
+
+#define LNET_WIRE_HANDLE_COOKIE_NONE   (-1)
+
+/**
+ * Invalidate handle \a h.
+ */
+static inline void LNetInvalidateHandle(lnet_handle_any_t *h)
+{
+        h->cookie = LNET_WIRE_HANDLE_COOKIE_NONE;
+}
+
+/**
+ * Compare handles \a h1 and \a h2.
+ *
+ * \return 1 if handles are equal, 0 if otherwise.
+ */
+static inline int LNetHandleIsEqual (lnet_handle_any_t h1, lnet_handle_any_t h2)
+{
+        return (h1.cookie == h2.cookie);
+}
+
+/**
+ * Check whether handle \a h is invalid.
+ *
+ * \return 1 if handle is invalid, 0 if valid.
+ */
+static inline int LNetHandleIsInvalid(lnet_handle_any_t h)
+{
+        return (LNET_WIRE_HANDLE_COOKIE_NONE == h.cookie);
+}
+
+/**
+ * Global process ID.
+ */
+typedef struct {
+        /** node id */
+        lnet_nid_t nid;
+        /** process id */
+        lnet_pid_t pid;
+} lnet_process_id_t;
+/** @} lnet_addr */
+
+/** \addtogroup lnet_me
+ * @{ */
+
+/**
+ * Specifies whether the match entry or memory descriptor should be unlinked
+ * automatically (LNET_UNLINK) or not (LNET_RETAIN).
+ */
+typedef enum {
+        LNET_RETAIN = 0,
+        LNET_UNLINK
+} lnet_unlink_t;
+
+/**
+ * Values of the type lnet_ins_pos_t are used to control where a new match
+ * entry is inserted. The value LNET_INS_BEFORE is used to insert the new
+ * entry before the current entry or before the head of the list. The value
+ * LNET_INS_AFTER is used to insert the new entry after the current entry
+ * or after the last item in the list.
+ */
+typedef enum {
+        LNET_INS_BEFORE,
+        LNET_INS_AFTER
+} lnet_ins_pos_t;
+
+/** @} lnet_me */
+
+/** \addtogroup lnet_md
+ * @{ */
+
+/**
+ * Defines the visible parts of a memory descriptor. Values of this type
+ * are used to initialize memory descriptors.
+ */
+typedef struct {
+        /**
+         * Specify the memory region associated with the memory descriptor.
+         * If the options field has:
+         * - LNET_MD_KIOV bit set: The start field points to the starting
+         * address of an array of lnet_kiov_t and the length field specifies
+         * the number of entries in the array. The length can't be bigger
+         * than LNET_MAX_IOV. The lnet_kiov_t is used to describe page-based
+         * fragments that are not necessarily mapped in virtal memory.
+         * - LNET_MD_IOVEC bit set: The start field points to the starting
+         * address of an array of struct iovec and the length field specifies
+         * the number of entries in the array. The length can't be bigger
+         * than LNET_MAX_IOV. The struct iovec is used to describe fragments
+         * that have virtual addresses.
+         * - Otherwise: The memory region is contiguous. The start field
+         * specifies the starting address for the memory region and the
+         * length field specifies its length.
+         *
+         * When the memory region is fragmented, all fragments but the first
+         * one must start on page boundary, and all but the last must end on
+         * page boundary.
+         */
+        void            *start;
+        unsigned int     length;
+        /**
+         * Specifies the maximum number of operations that can be performed
+         * on the memory descriptor. An operation is any action that could
+         * possibly generate an event. In the usual case, the threshold value
+         * is decremented for each operation on the MD. When the threshold
+         * drops to zero, the MD becomes inactive and does not respond to
+         * operations. A threshold value of LNET_MD_THRESH_INF indicates that
+         * there is no bound on the number of operations that may be applied
+         * to a MD.
+         */
+        int              threshold;
+        /**
+         * Specifies the largest incoming request that the memory descriptor
+         * should respond to. When the unused portion of a MD (length -
+         * local offset) falls below this value, the MD becomes inactive and
+         * does not respond to further operations. This value is only used
+         * if the LNET_MD_MAX_SIZE option is set.
+         */
+        int              max_size;
+        /**
+         * Specifies the behavior of the memory descriptor. A bitwise OR
+         * of the following values can be used:
+         * - LNET_MD_OP_PUT: The LNet PUT operation is allowed on this MD.
+         * - LNET_MD_OP_GET: The LNet GET operation is allowed on this MD.
+         * - LNET_MD_MANAGE_REMOTE: The offset used in accessing the memory
+         *   region is provided by the incoming request. By default, the
+         *   offset is maintained locally. When maintained locally, the
+         *   offset is incremented by the length of the request so that
+         *   the next operation (PUT or GET) will access the next part of
+         *   the memory region. Note that only one offset variable exists
+         *   per memory descriptor. If both PUT and GET operations are
+         *   performed on a memory descriptor, the offset is updated each time.
+         * - LNET_MD_TRUNCATE: The length provided in the incoming request can
+         *   be reduced to match the memory available in the region (determined
+         *   by subtracting the offset from the length of the memory region).
+         *   By default, if the length in the incoming operation is greater
+         *   than the amount of memory available, the operation is rejected.
+         * - LNET_MD_ACK_DISABLE: An acknowledgment should not be sent for
+         *   incoming PUT operations, even if requested. By default,
+         *   acknowledgments are sent for PUT operations that request an
+         *   acknowledgment. Acknowledgments are never sent for GET operations.
+         *   The data sent in the REPLY serves as an implicit acknowledgment.
+         * - LNET_MD_KIOV: The start and length fields specify an array of
+         *   lnet_kiov_t.
+         * - LNET_MD_IOVEC: The start and length fields specify an array of
+         *   struct iovec.
+         * - LNET_MD_MAX_SIZE: The max_size field is valid.
+         *
+         * Note:
+         * - LNET_MD_KIOV or LNET_MD_IOVEC allows for a scatter/gather
+         *   capability for memory descriptors. They can't be both set.
+         * - When LNET_MD_MAX_SIZE is set, the total length of the memory
+         *   region (i.e. sum of all fragment lengths) must not be less than
+         *   \a max_size.
+         */
+        unsigned int     options;
+        /**
+         * A user-specified value that is associated with the memory
+         * descriptor. The value does not need to be a pointer, but must fit
+         * in the space used by a pointer. This value is recorded in events
+         * associated with operations on this MD.
+         */
+        void            *user_ptr;
+        /**
+         * A handle for the event queue used to log the operations performed on
+         * the memory region. If this argument is a NULL handle (i.e. nullified
+         * by LNetInvalidateHandle()), operations performed on this memory
+         * descriptor are not logged.
+         */
+        lnet_handle_eq_t eq_handle;
+} lnet_md_t;
+
+/* Max Transfer Unit (minimum supported everywhere) */
+#define LNET_MTU_BITS   20
+#define LNET_MTU        (1<<LNET_MTU_BITS)
+
+/** limit on the number of fragments in discontiguous MDs */
+#define LNET_MAX_IOV    256
+
+/* Max payload size - must be compile time constant */
+#define LNET_MAX_PAYLOAD @LNET_MAX_PAYLOAD@
+
+#if (LNET_MAX_PAYLOAD < LNET_MTU)
+# error "LNET_MAX_PAYLOAD too small - error in configure --with-max-payload-mb"
+
+#elif defined(__KERNEL__) && (LNET_MAX_PAYLOAD > (PAGE_SIZE * LNET_MAX_IOV))
+# error "LNET_MAX_PAYLOAD too large - error in configure --with-max-payload-mb"
+#endif
+
+/**
+ * Options for the MD structure. See lnet_md_t::options.
+ */
+#define LNET_MD_OP_PUT               (1 << 0)
+/** See lnet_md_t::options. */
+#define LNET_MD_OP_GET               (1 << 1)
+/** See lnet_md_t::options. */
+#define LNET_MD_MANAGE_REMOTE        (1 << 2)
+/* unused                            (1 << 3) */
+/** See lnet_md_t::options. */
+#define LNET_MD_TRUNCATE             (1 << 4)
+/** See lnet_md_t::options. */
+#define LNET_MD_ACK_DISABLE          (1 << 5)
+/** See lnet_md_t::options. */
+#define LNET_MD_IOVEC                (1 << 6)
+/** See lnet_md_t::options. */
+#define LNET_MD_MAX_SIZE             (1 << 7)
+/** See lnet_md_t::options. */
+#define LNET_MD_KIOV                 (1 << 8)
+
+/* For compatibility with Cray Portals */
+#define LNET_MD_PHYS                         0
+
+/** Infinite threshold on MD operations. See lnet_md_t::threshold */
+#define LNET_MD_THRESH_INF       (-1)
+
+/* NB lustre portals uses struct iovec internally! */
+typedef struct iovec lnet_md_iovec_t;
+
+/**
+ * A page-based fragment of a MD.
+ */
+typedef struct {
+        /** Pointer to the page where the fragment resides */
+        cfs_page_t      *kiov_page;
+        /** Length in bytes of the fragment */
+        unsigned int     kiov_len;
+        /**
+         * Starting offset of the fragment within the page. Note that the
+         * end of the fragment must not pass the end of the page; i.e.,
+         * kiov_len + kiov_offset <= CFS_PAGE_SIZE.
+         */
+        unsigned int     kiov_offset;
+} lnet_kiov_t;
+/** @} lnet_md */
+
+/** \addtogroup lnet_eq
+ * @{ */
+
+/**
+ * Six types of events can be logged in an event queue.
+ */
+typedef enum {
+        /** An incoming GET operation has completed on the MD. */
+        LNET_EVENT_GET,
+        /**
+         * An incoming PUT operation has completed on the MD. The
+         * underlying layers will not alter the memory (on behalf of this
+         * operation) once this event has been logged.
+         */
+        LNET_EVENT_PUT,
+        /**
+         * A REPLY operation has completed. This event is logged after the
+         * data (if any) from the REPLY has been written into the MD.
+         */
+        LNET_EVENT_REPLY,
+        /** An acknowledgment has been received. */
+        LNET_EVENT_ACK,
+        /**
+         * An outgoing send (PUT or GET) operation has completed. This event
+         * is logged after the entire buffer has been sent and it is safe for
+         * the caller to reuse the buffer.
+         *
+         * Note:
+         * - The LNET_EVENT_SEND doesn't guarantee message delivery. It can
+         *   happen even when the message has not yet been put out on wire.
+         * - It's unsafe to assume that in an outgoing GET operation
+         *   the LNET_EVENT_SEND event would happen before the
+         *   LNET_EVENT_REPLY event. The same holds for LNET_EVENT_SEND and
+         *   LNET_EVENT_ACK events in an outgoing PUT operation.
+         */
+        LNET_EVENT_SEND,
+        /**
+         * A MD has been unlinked. Note that LNetMDUnlink() does not
+         * necessarily trigger an LNET_EVENT_UNLINK event.
+         * \see LNetMDUnlink
+         */
+        LNET_EVENT_UNLINK,
+} lnet_event_kind_t;
+
+#define LNET_SEQ_BASETYPE       long
+typedef unsigned LNET_SEQ_BASETYPE lnet_seq_t;
+#define LNET_SEQ_GT(a,b)        (((signed LNET_SEQ_BASETYPE)((a) - (b))) > 0)
+
+/* XXX
+ * cygwin need the pragma line, not clear if it's needed in other places.
+ * checking!!!
+ */
+#ifdef __CYGWIN__
+#pragma pack(push, 4)
+#endif
+
+/**
+ * Information about an event on a MD.
+ */
+typedef struct {
+        /** The identifier (nid, pid) of the target. */
+        lnet_process_id_t   target;
+        /** The identifier (nid, pid) of the initiator. */
+        lnet_process_id_t   initiator;
+        /**
+         * The NID of the immediate sender. If the request has been forwarded
+         * by routers, this is the NID of the last hop; otherwise it's the
+         * same as the initiator.
+         */
+        lnet_nid_t          sender;
+        /** Indicates the type of the event. */
+        lnet_event_kind_t   type;
+        /** The portal table index specified in the request */
+        unsigned int        pt_index;
+        /** A copy of the match bits specified in the request. */
+        __u64               match_bits;
+        /** The length (in bytes) specified in the request. */
+        unsigned int        rlength;
+        /**
+         * The length (in bytes) of the data that was manipulated by the
+         * operation. For truncated operations, the manipulated length will be
+         * the number of bytes specified by the MD (possibly with an offset,
+         * see lnet_md_t). For all other operations, the manipulated length
+         * will be the length of the requested operation, i.e. rlength.
+         */
+        unsigned int        mlength;
+        /**
+         * The handle to the MD associated with the event. The handle may be
+         * invalid if the MD has been unlinked.
+         */
+        lnet_handle_md_t    md_handle;
+        /**
+         * A snapshot of the state of the MD immediately after the event has
+         * been processed. In particular, the threshold field in md will
+         * reflect the value of the threshold after the operation occurred.
+         */
+        lnet_md_t           md;
+        /**
+         * 64 bits of out-of-band user data. Only valid for LNET_EVENT_PUT.
+         * \see LNetPut
+         */
+        __u64               hdr_data;
+        /**
+         * Indicates the completion status of the operation. It's 0 for
+         * successful operations, otherwise it's an error code.
+         */
+        int                 status;
+        /**
+         * Indicates whether the MD has been unlinked. Note that:
+         * - An event with unlinked set is the last event on the MD.
+         * - This field is also set for an explicit LNET_EVENT_UNLINK event.
+         * \see LNetMDUnlink
+         */
+        int                 unlinked;
+        /**
+         * The displacement (in bytes) into the memory region that the
+         * operation used. The offset can be determined by the operation for
+         * a remote managed MD or by the local MD.
+         * \see lnet_md_t::options
+         */
+        unsigned int        offset;
+#ifdef CRAY_XT3
+        lnet_uid_t          uid;
+#endif
+
+        /**
+         * The sequence number for this event. Sequence numbers are unique
+         * to each event.
+         */
+        volatile lnet_seq_t sequence;
+} lnet_event_t;
+#ifdef __CYGWIN__
+#pragma pop
+#endif
+
+/**
+ * Event queue handler function type.
+ *
+ * The EQ handler runs for each event that is deposited into the EQ. The
+ * handler is supplied with a pointer to the event that triggered the
+ * handler invocation.
+ *
+ * The handler must not block, must be reentrant, and must not call any LNet
+ * API functions. It should return as quickly as possible.
+ */
+typedef void (*lnet_eq_handler_t)(lnet_event_t *event);
+#define LNET_EQ_HANDLER_NONE NULL
+/** @} lnet_eq */
+
+/** \addtogroup lnet_data
+ * @{ */
+
+/**
+ * Specify whether an acknowledgment should be sent by target when the PUT
+ * operation completes (i.e., when the data has been written to a MD of the
+ * target process).
+ *
+ * \see lnet_md_t::options for the discussion on LNET_MD_ACK_DISABLE by which
+ * acknowledgments can be disabled for a MD.
+ */
+typedef enum {
+        /** Request an acknowledgment */
+        LNET_ACK_REQ,
+        /** Request that no acknowledgment should be generated. */
+        LNET_NOACK_REQ
+} lnet_ack_req_t;
+/** @} lnet_data */
+
+/** @} lnet */
+#endif
diff --git a/lustre.spec.in b/lustre.spec.in
index cd914af..45b480b 100644
--- a/lustre.spec.in
+++ b/lustre.spec.in
@@ -1,18 +1,52 @@
 # lustre.spec
 %{!?version: %define version @VERSION@}
 %{!?kver: %define kver ""}
-%{!?kdir: %define kdir %(dir=$(echo "%configure_args" | sed -ne 's/.*--with-linux=\\([^ ][^ ]*\\).*$/\\1/p'); if [ -n "$dir" ]; then echo "$dir"; else if [ -n "%kver" ]; then kversion="%kver"; else kversion="$(uname -r)"; fi; echo "/lib/modules/$kversion/source"; fi)}
-
-%{!?kobjdir: %define kobjdir %(dir=$(echo "%configure_args" | sed -ne 's/.*--with-linux-obj=\\([^ ][^ ]*\\).*$/\\1/p'); if [ -n "$dir" ]; then echo "$dir"; else if [ -n "%kver" ]; then kversion="%kver"; else kversion="$(uname -r)"; fi; if [ "%kdir" = "/lib/modules/$kversion/source" ]; then echo "/lib/modules/$kversion/build"; else echo "%kdir"; fi; fi)}
-
-# as an alternative to this implementation we could simply "make -C $kdir kernelversion"
-%{!?kversion: %define kversion %(if test -s %kobjdir/include/linux/utsrelease.h ; then LINUXRELEASEHEADER=utsrelease.h; else LINUXRELEASEHEADER=version.h; fi; sed -ne '/^#define UTS_RELEASE/s/.*"\\(.*\\)"$/\\1/p' %kobjdir/include/linux/$LINUXRELEASEHEADER)}
+%{!?kdir: %define kdir %(dir=$(\
+    echo "%configure_args" | \
+        sed -ne 's/.*--with-linux=\\([^ ][^ ]*\\).*$/\\1/p'); \
+    if [ -n "$dir" ]; then \
+        echo "$dir"; \
+    else \
+        if [ -n "%kver" ]; then \
+            kversion="%kver"; \
+        else kversion="$(uname -r)"; \
+        fi; \
+        echo "/lib/modules/$kversion/source"; \
+    fi)}
+
+%{!?kobjdir: %define kobjdir %(dir=$(\
+    echo "%configure_args" | \
+        sed -ne 's/.*--with-linux-obj=\\([^ ][^ ]*\\).*$/\\1/p'); \
+    if [ -n "$dir" ]; then \
+        echo "$dir"; \
+    else \
+        if [ -n "%kver" ]; then \
+            kversion="%kver"; \
+        else kversion="$(uname -r)"; \
+        fi; \
+        if [ "%kdir" = "/lib/modules/$kversion/source" ]; then \
+            echo "/lib/modules/$kversion/build"; \
+        else echo "%kdir"; \
+        fi; \
+    fi)}
+
+# as an alternative to this implementation we could simply:
+#   "make -C $kdir kernelversion"
+%{!?kversion: %define kversion %(\
+    relhdr=%kobjdir/include/linux/utsrelease.h ; \
+    test -s $relhdr || \
+        relhdr=${relhdr%utsrelease.h}version.h; \
+    sed -ne '/^#define UTS_RELEASE/s/.*"\\(.*\\)"$/\\1/p' $relhdr)}
 
 %{!?downstream_release: %define downstream_release "@DOWNSTREAM_RELEASE@"}
 
 %define buildid %(if [ -n "@BUILDID@" ]; then echo "_@BUILDID@"; fi)
 
-%{!?myrelease: %define myrelease %(if [ -n "%downstream_release" ]; then echo -n "%{downstream_release}_"; fi; echo %kversion | tr '-' '_')}
+%{!?myrelease: %define myrelease %(\
+    if [ -n "%downstream_release" ]; then \
+        echo -n "%{downstream_release}_"; \
+    fi; \
+    echo %kversion | tr '-' '_')}
 
 # always append the buildid, even when the caller defines %release
 %define fullrelease %{myrelease}%{buildid}
@@ -89,6 +123,13 @@ Group: Development/Kernel
 %description modules
 Lustre file system, server and network drivers for Linux %{kversion}.
 
+%package devel
+Summary: User space Lustre development libraries and headers
+Group: Development/Kernel
+
+%description devel
+User space Lustre development libraries and headers.
+
 %package source
 Summary: Object-Based Disk storage driver source
 Group: Development/Kernel
@@ -216,70 +257,85 @@ ln -s $RPM_BUILD_ROOT/usr/src lustre-source
 make distdir distdir=lustre-source/lustre-%{version}
 chmod -R go-w lustre-source/lustre-%{version}
 
-cat >lustre.files <<EOF
-%attr(-, root, root) /sbin/mount.lustre
-%attr(-, root, root) /usr/sbin/*
-%attr(-, root, root) /usr/bin/*
+exec 4> lustre.files 5> lustre-devel.files
+cat >&4 <<- EOF
+	%attr(-, root, root) /sbin/mount.lustre
+	%attr(-, root, root) /usr/sbin/*
+	%attr(-, root, root) /usr/bin/*
 
-%attr(-, root, root) /usr/share/lustre
+	%attr(-, root, root) %{_mandir}/man1/*
+	%attr(-, root, root) %{_mandir}/man7/*
+	%attr(-, root, root) %{_mandir}/man8/*
 
-%attr(-, root, root) %{_libdir}/libptlctl.a
-%attr(-, root, root) %{_libdir}/liblustreapi.a
-%attr(-, root, root) /usr/include/lustre
-%attr(-, root, root) /usr/include/libcfs
+	%attr(-, root, root) %{_libexecdir}/lustre/lc_common
 
-%attr(-, root, root) %{_mandir}/man?/*
+	%attr(-, root, root) %{_sysconfdir}/udev/rules.d/99-lustre.rules
+	EOF
 
-%attr(-, root, root) %{_libexecdir}/lustre/lc_common
+cat >&5 <<- EOF
+	%attr(-, root, root) /usr/share/lustre
 
-%attr(-, root, root) %{_sysconfdir}/udev/rules.d/99-lustre.rules
-EOF
+	%attr(-, root, root) %{_mandir}/man3/*
+	%attr(-, root, root) %{_libdir}/libptlctl.a
+	%attr(-, root, root) %{_libdir}/liblustreapi.a
+	%attr(-, root, root) /usr/include/lustre/*
 
-if [ -f $RPM_BUILD_ROOT%{_libdir}/libcfsutil.a ] ; then
-  echo '%attr(-, root, root) %{_libdir}/libcfsutil.a' >>lustre.files
-fi
+	%attr(-, root, root) /usr/include/libcfs/*
+	EOF
 
-if [ -f $RPM_BUILD_ROOT%{_libdir}/liblustre.so ] ; then
-  echo '%attr(-, root, root) %{_libdir}/liblustre.a' >>lustre.files
-  echo '%attr(-, root, root) %{_libdir}/liblustre.so' >>lustre.files
-fi
+{
+    lustre_inc_dir=$RPM_BUILD_DIR/lustre-%{version}/lustre/include
+    test -f $RPM_BUILD_ROOT%{_libdir}/libcfsutil.a && \
+        echo '%attr(-, root, root) %{_libdir}/libcfsutil.a'
 
-if [ -f $RPM_BUILD_DIR/lustre-%{version}/lustre/utils/libiam.c ] ; then
-  echo '%attr(-, root, root) %{_libdir}/libiam.a' >>lustre.files
-fi
+    if [ -f $RPM_BUILD_ROOT%{_libdir}/liblustre.so ] ; then
+        echo '%attr(-, root, root) %{_libdir}/liblustre.a'
+        echo '%attr(-, root, root) %{_libdir}/liblustre.so'
+    fi
 
-if [ -d $RPM_BUILD_ROOT%{_libdir}/lustre/snmp ] ; then
-  echo '%attr(-, root, root) %{_libdir}/lustre/snmp' >>lustre.files
-  echo '%attr(-, root, root) %{_datadir}/lustre/snmp/mibs' >>lustre.files
-fi
+    test -f $RPM_BUILD_DIR/lustre-%{version}/lustre/utils/libiam.c && \
+        echo '%attr(-, root, root) %{_libdir}/libiam.a'
 
-# Have universal lustre headers 
-if [ -f $RPM_BUILD_DIR/lustre-%{version}/lustre/include/lustre/lustre_idl.h ] ; then
-  echo '%attr(-, root, root) /usr/include/linux/lustre_user.h' >>lustre.files
-else
-  echo '%attr(-, root, root) /usr/include/linux/lustre_idl.h' >>lustre.files
-fi
+    # Have universal lustre headers 
+    if [ -f ${lustre_inc_dir}/lustre/lustre_idl.h ] ; then
+        echo '%attr(-, root, root) /usr/include/linux/lustre_user.h'
+    else
+        echo '%attr(-, root, root) /usr/include/linux/lustre_idl.h'
+    fi
+    test -f ${lustre_inc_dir}/linux/lustre_types.h && \
+        echo '%attr(-, root, root) /usr/include/linux/lustre_types.h'
+} >&5
 
-if [ -f $RPM_BUILD_DIR/lustre-%{version}/lustre/include/linux/lustre_types.h ] ; then
-  echo '%attr(-, root, root) /usr/include/linux/lustre_types.h' >>lustre.files
-fi
+if [ -d $RPM_BUILD_ROOT%{_libdir}/lustre/snmp ] ; then
+  echo '%attr(-, root, root) %{_libdir}/lustre/snmp'
+  echo '%attr(-, root, root) %{_datadir}/lustre/snmp/mibs'
+fi  >&4
 
+exec 5>&- 4>&-
 %if %{build_lustre_tests}
-echo '%attr(-, root, root) %{_libdir}/lustre/tests/*' >lustre-tests.files
-echo '%attr(-, root, root) /lib/modules/%{kversion}/updates/kernel/fs/lustre/llog_test.*' >>lustre-tests.files
-modules_excludes="|llog_test"
-if [ -d $RPM_BUILD_ROOT%{_libdir}/lustre/liblustre/tests ] ; then
-  echo '%attr(-, root, root) %{_libdir}/lustre/liblustre/tests/*' >>lustre-tests.files
-fi
+{
+    echo '%attr(-, root, root) %{_libdir}/lustre/tests/*'
+    ltest_dir=/lib/modules/%{kversion}/updates/kernel/fs/lustre
+    echo "%attr(-, root, root) ${ltest_dir}/llog_test.*"
+    modules_excludes="|llog_test"
+    if [ -d $RPM_BUILD_ROOT%{_libdir}/lustre/liblustre/tests ] ; then
+        echo '%attr(-, root, root) %{_libdir}/lustre/liblustre/tests/*'
+    fi
+} > lustre-tests.files
 %endif
 
 pushd $RPM_BUILD_ROOT >/dev/null
 > $RPM_BUILD_DIR/lustre-%{version}/lustre-modules.files
-find lib/modules/%{kversion}/updates -type f | awk "!/(ZZZZZZZZZZ$modules_excludes)/ {print \"%attr(-, root, root) /\"\$0}" >>$RPM_BUILD_DIR/lustre-%{version}/lustre-modules.files
+find lib/modules/%{kversion}/updates -type f | \
+    awk "!/(ZZZZZZZZZZ$modules_excludes)/ {
+        print \"%attr(-, root, root) /\"\$0}" \
+            >> $RPM_BUILD_DIR/lustre-%{version}/lustre-modules.files
 popd >/dev/null
 
 %files -f lustre.files
 
+%files devel -f lustre-devel.files
+
 %files modules -f lustre-modules.files
 %attr(-, root, root) %doc COPYING
 %attr(-, root, root) %doc ChangeLog-lustre
diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4
index 91bf08c..aebec48 100644
--- a/lustre/autoconf/lustre-core.m4
+++ b/lustre/autoconf/lustre-core.m4
@@ -53,9 +53,9 @@ esac
 #
 # the maximum buffer size of lctl ioctls
 #
-AC_DEFUN([LC_CONFIG_OBD_BUFFER_SIZE],
-[AC_MSG_CHECKING([maximum OBD ioctl size])
-AC_ARG_WITH([obd-buffer-size],
+AC_DEFUN([LC_CONFIG_OBD_BUFFER_SIZE],[
+  AC_MSG_CHECKING([maximum OBD ioctl size])
+  AC_ARG_WITH([obd-buffer-size],
 	AC_HELP_STRING([--with-obd-buffer-size=[size]],
 			[set lctl ioctl maximum bytes (default=8192)]),
 	[
@@ -63,8 +63,10 @@ AC_ARG_WITH([obd-buffer-size],
 	],[
 		OBD_BUFFER_SIZE=8192
 	])
-AC_MSG_RESULT([$OBD_BUFFER_SIZE bytes])
-AC_DEFINE_UNQUOTED(OBD_MAX_IOCTL_BUFFER, $OBD_BUFFER_SIZE, [IOCTL Buffer Size])
+  AC_MSG_RESULT([$OBD_BUFFER_SIZE bytes])
+  AC_DEFINE_UNQUOTED(OBD_MAX_IOCTL_BUFFER, $OBD_BUFFER_SIZE, [IOCTL Buffer Size])
+  OBD_MAX_IOCTL_BUFFER=$OBD_BUFFER_SIZE
+  AC_SUBST(OBD_MAX_IOCTL_BUFFER)
 ])
 
 #
@@ -2635,7 +2637,6 @@ lustre/doc/Makefile
 lustre/include/Makefile
 lustre/include/lustre_ver.h
 lustre/include/linux/Makefile
-lustre/include/lustre/Makefile
 lustre/kernel_patches/targets/2.6-rhel6.target
 lustre/kernel_patches/targets/2.6-rhel5.target
 lustre/kernel_patches/targets/2.6-sles10.target
diff --git a/lustre/include/Makefile.am b/lustre/include/Makefile.am
index 19d45ac..85b2589 100644
--- a/lustre/include/Makefile.am
+++ b/lustre/include/Makefile.am
@@ -34,16 +34,63 @@
 # Lustre is a trademark of Sun Microsystems, Inc.
 #
 
-SUBDIRS = linux lustre
+SUBDIRS = linux
 
-EXTRA_DIST = ioctl.h liblustre.h lprocfs_status.h lustre_cfg.h 	\
-	     lustre_debug.h lustre_disk.h lustre_dlm.h lustre_export.h \
-             lustre_fsfilt.h lustre_ha.h lustre_handles.h lustre_import.h \
-             lustre_lib.h lustre_sec.h	lustre_lite.h lustre_log.h lustre_mds.h \
-             lustre_mdc.h lustre_net.h lustre_quota.h lvfs.h \
-             obd_cache.h obd_class.h obd.h obd_lov.h \
-	     obd_ost.h obd_support.h lustre_ver.h lu_object.h lu_time.h  \
-             md_object.h dt_object.h lustre_param.h lustre_mdt.h \
-             lustre_fid.h lustre_fld.h lustre_req_layout.h lustre_capa.h \
-             lustre_idmap.h lustre_eacl.h interval_tree.h obd_cksum.h \
-	     lu_ref.h cl_object.h lustre_acl.h lclient.h lu_target.h
+pkginclude_LIST :=                  lustre/ll_fiemap.h \
+    lustre/lustre_idl.h             lustre/liblustreapi.h \
+    lustre/libiam.h                 lustre/lustre_user.h
+
+nodist_pkginclude_LIST := lustre_ver.h
+nobase_pkginclude_LIST := \
+    cl_object.h                     darwin/lprocfs_status.h \
+    darwin/obd_support.h            darwin/lustre_lite.h \
+    darwin/lustre_dlm.h             darwin/lustre_fsfilt.h \
+    darwin/lustre_handles.h         darwin/lustre_lib.h \
+    darwin/obd_cksum.h              darwin/lustre_quota.h \
+    darwin/lustre_net.h             darwin/lvfs.h \
+    darwin/lustre_log.h             darwin/obd.h \
+    darwin/lustre_debug.h           darwin/lustre_user.h \
+    darwin/obd_class.h              darwin/lustre_compat.h \
+    darwin/lustre_mds.h             dt_object.h \
+    interval_tree.h                 ioctl.h \
+    lclient.h                       liblustre.h \
+    linux/lprocfs_status.h          linux/obd_support.h \
+    linux/lustre_lite.h             linux/lustre_patchless_compat.h \
+    linux/lustre_dlm.h              linux/lustre_fsfilt.h \
+    linux/lustre_handles.h          linux/lustre_lib.h \
+    linux/obd_cksum.h               linux/lustre_quota.h \
+    linux/lustre_net.h              linux/lvfs.h \
+    linux/lustre_log.h              linux/lvfs_linux.h \
+    linux/lustre_compat25.h         linux/lustre_acl.h \
+    linux/obd.h                     linux/lustre_debug.h \
+    linux/lustre_user.h             linux/obd_class.h \
+    linux/lustre_intent.h           linux/lustre_mds.h \
+    lprocfs_status.h                lu_object.h \
+    lu_ref.h        lu_target.h     lu_time.h  \
+    lustre_acl.h                    lustre_capa.h \
+    lustre_cfg.h                    lustre_debug.h \
+    lustre_disk.h                   lustre_dlm.h \
+    lustre_eacl.h                   lustre_export.h \
+    lustre_fid.h                    lustre_fld.h \
+    lustre_fsfilt.h                 lustre_ha.h \
+    lustre_handles.h                lustre_idmap.h \
+    lustre_import.h                 lustre_lib.h \
+    lustre_lite.h                   lustre_log.h \
+    lustre_mdc.h                    lustre_mds.h \
+    lustre_mdt.h                    lustre_net.h \
+    lustre_param.h                  lustre_quota.h \
+    lustre_req_layout.h             lustre_sec.h \
+    lvfs.h                          md_object.h \
+    obd.h                           obd_cache.h \
+    obd_cksum.h                     obd_class.h \
+    obd_lov.h                       obd_ost.h \
+    obd_support.h
+
+if UTILS
+pkginclude_HEADERS        := $(pkginclude_LIST)
+nodist_pkginclude_HEADERS := $(nodist_pkginclude_LIST)
+nobase_pkginclude_HEADERS := $(nobase_pkginclude_LIST)
+else
+EXTRA_DIST                := $(pkginclude_LIST) \
+                             $(nobase_pkginclude_LIST)
+endif
diff --git a/lustre/include/linux/Makefile.am b/lustre/include/linux/Makefile.am
index 690deba..eafa5d6 100644
--- a/lustre/include/linux/Makefile.am
+++ b/lustre/include/linux/Makefile.am
@@ -39,10 +39,3 @@ linuxdir = $(includedir)/linux
 if UTILS
 linux_HEADERS = lustre_user.h
 endif
-
-EXTRA_DIST = lprocfs_status.h lustre_acl.h lustre_debug.h lustre_lib.h \
-     lustre_dlm.h  lustre_handles.h lustre_net.h obd_class.h obd_support.h \
-     lustre_log.h lustre_compat25.h lustre_fsfilt.h lustre_mds.h \
-     obd.h lvfs.h lvfs_linux.h lustre_lite.h lustre_quota.h \
-     lustre_user.h lustre_patchless_compat.h lustre_intent.h \
-     obd_cksum.h
diff --git a/lustre/include/linux/lustre_acl.h b/lustre/include/linux/lustre_acl.h
index e47f811..73af9d3 100644
--- a/lustre/include/linux/lustre_acl.h
+++ b/lustre/include/linux/lustre_acl.h
@@ -43,7 +43,7 @@
 #define _LUSTRE_LINUX_ACL_H
 
 #ifndef	_LUSTRE_ACL_H
-#error	Shoud not include direectly. use #include <lustre_acl.h> instead
+#error	Should not include directly. use #include <lustre_acl.h> instead
 #endif
 
 #ifdef __KERNEL__
diff --git a/lustre/include/lustre/Makefile.am b/lustre/include/lustre/Makefile.am
deleted file mode 100644
index 23d7ebe..0000000
--- a/lustre/include/lustre/Makefile.am
+++ /dev/null
@@ -1,42 +0,0 @@
-#
-# GPL HEADER START
-#
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# 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.
-#
-# 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).
-#
-# 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
-#
-# 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 (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
-# Use is subject to license terms.
-#
-
-#
-# This file is part of Lustre, http://www.lustre.org/
-# Lustre is a trademark of Sun Microsystems, Inc.
-#
-
-if UTILS
-pkginclude_HEADERS = lustre_idl.h lustre_user.h liblustreapi.h libiam.h \
-	 ll_fiemap.h
-endif
-
-EXTRA_DIST = lustre_idl.h lustre_user.h liblustreapi.h libiam.h ll_fiemap.h
diff --git a/lustre/include/lustre_sec.h b/lustre/include/lustre_sec.h
index 6a0da67..eb594f9 100644
--- a/lustre/include/lustre_sec.h
+++ b/lustre/include/lustre_sec.h
@@ -363,8 +363,8 @@ void sptlrpc_target_choose_flavor(struct sptlrpc_rule_set *rset,
 
 
 struct vfs_cred {
-        uint32_t        vc_uid;
-        uint32_t        vc_gid;
+        __u32       vc_uid;
+        __u32       vc_gid;
 };
 
 struct ptlrpc_ctx_ops {
diff --git a/lustre/include/lustre_ver.h.in b/lustre/include/lustre_ver.h.in
index 1553f68..45a7ddc 100644
--- a/lustre/include/lustre_ver.h.in
+++ b/lustre/include/lustre_ver.h.in
@@ -14,22 +14,27 @@
 #define MGS_URN "@AC_LUSTRE_MGS_URN@"
 #define OSS_URN "@AC_LUSTRE_OSS_URN@"
 
-#define LUSTRE_VERSION_CODE OBD_OCD_VERSION(LUSTRE_MAJOR,LUSTRE_MINOR,LUSTRE_PATCH,LUSTRE_FIX)
+#define LUSTRE_VERSION_CODE \
+    OBD_OCD_VERSION(LUSTRE_MAJOR,LUSTRE_MINOR,LUSTRE_PATCH,LUSTRE_FIX)
 
 /* liblustre clients are only allowed to connect if their LUSTRE_FIX mismatches
  * by this amount (set in lustre/autoconf/lustre-version.ac). */
 #define LUSTRE_VERSION_ALLOWED_OFFSET @AC_LUSTRE_VER_ALLOWED_OFFSET@
 
 #ifdef __KERNEL__
-/* If lustre version of client and servers it connects to differs by more
- * than this amount, client would issue a warning.
- * (set in lustre/autoconf/lustre-version.ac) */
-#define LUSTRE_VERSION_OFFSET_WARN @AC_LUSTRE_CLI_VER_OFFSET_WARN@
+  /* If lustre version of client and servers it connects to differs by more
+   * than this amount, client would issue a warning.
+   * (set in lustre/autoconf/lustre-version.ac) */
+# define LUSTRE_VERSION_OFFSET_WARN @AC_LUSTRE_CLI_VER_OFFSET_WARN@
+
 #else
-/* If liblustre version of client and servers it connects to differs by more
- * than this amount, client would issue a warning.
- * (set in lustre/autoconf/lustre-version.ac) */
-#define LUSTRE_VERSION_OFFSET_WARN @AC_LUSTRE_LIB_VER_OFFSET_WARN@
+  /* If liblustre version of client and servers it connects to differs by more
+   * than this amount, client would issue a warning.
+   * (set in lustre/autoconf/lustre-version.ac) */
+# define LUSTRE_VERSION_OFFSET_WARN @AC_LUSTRE_LIB_VER_OFFSET_WARN@
 #endif
 
+/* IOCTL Buffer Size */
+#define OBD_MAX_IOCTL_BUFFER @OBD_MAX_IOCTL_BUFFER@
+
 #endif
diff --git a/lustre/utils/Makefile.am b/lustre/utils/Makefile.am
index f6c234b..dd5fa7c 100644
--- a/lustre/utils/Makefile.am
+++ b/lustre/utils/Makefile.am
@@ -31,21 +31,22 @@ bin_SCRIPTS = $(bin_scripts)
 sbin_SCRIPTS = $(sbin_scripts)
 endif # UTILS
 
+pkginclude_HEADERS = obdctl.h
 lib_LIBRARIES = liblustreapi.a libiam.a
 
-lctl_SOURCES = obd.c lustre_cfg.c lctl.c obdctl.h
+lctl_SOURCES = lctl.c $(pkginclude_HEADERS)
 lctl_LDADD := $(LIBREADLINE) liblustreapi.a $(LIBPTLCTL)
 lctl_DEPENDENCIES := $(LIBPTLCTL) liblustreapi.a
 
-lfs_SOURCES = lfs.c obd.c lustre_cfg.c
+lfs_SOURCES = lfs.c
 lfs_LDADD := $(LIBREADLINE) liblustreapi.a $(LIBPTLCTL)
 lfs_DEPENDENCIES := $(LIBPTLCTL) liblustreapi.a 
 
-loadgen_SOURCES = loadgen.c lustre_cfg.c obd.c
+loadgen_SOURCES = loadgen.c
 loadgen_LDADD := $(LIBREADLINE) liblustreapi.a $(LIBPTLCTL) $(PTHREAD_LIBS)
 loadgen_DEPENDENCIES := $(LIBPTLCTL) liblustreapi.a
 
-lustre_rsync_SOURCES = lustre_rsync.c obd.c lustre_cfg.c lustre_rsync.h
+lustre_rsync_SOURCES = lustre_rsync.c lustre_rsync.h
 lustre_rsync_LDADD :=  $(LIBREADLINE) liblustreapi.a $(LIBPTLCTL)
 lustre_rsync_DEPENDENCIES := $(LIBPTLCTL) liblustreapi.a
 
@@ -75,7 +76,8 @@ llverdev_LDADD := $(EXT2FSLIB) $(BLKIDLIB)
 
 L_IOCTL := $(top_builddir)/libcfs/libcfs/util/l_ioctl.c
 L_KERNELCOMM := $(top_builddir)/libcfs/libcfs/kernel_user_comm.c
-liblustreapi_a_SOURCES = liblustreapi.c $(L_IOCTL) $(L_KERNELCOMM)
+liblustreapi_a_SOURCES = liblustreapi.c obd.c lustre_cfg.c \
+	$(L_IOCTL) $(L_KERNELCOMM)
 
 libiam_a_SOURCES = libiam.c
 
-- 
1.7.3.4

